Skip to content

Commit 3172505

Browse files
puranjaymohangregkh
authored andcommitted
bpf, arm64: Remove redundant bpf_flush_icache() after pack allocator finalize
[ Upstream commit 42f18ae ] bpf_flush_icache() calls flush_icache_range() to clean the data cache and invalidate the instruction cache for the JITed code region. However, since commit 1dad391 ("bpf, arm64: use bpf_prog_pack for memory management"), this flush is redundant. bpf_jit_binary_pack_finalize() copies the JITed instructions to the ROX region via bpf_arch_text_copy() -> aarch64_insn_copy() -> __text_poke(), and __text_poke() already calls flush_icache_range() on the written range. The subsequent bpf_flush_icache() repeats the same cache maintenance on an overlapping range, including an unnecessary second synchronous IPI to all CPUs via kick_all_cpus_sync(). Remove the redundant bpf_flush_icache() call and its now-unused definition. Fixes: 1dad391 ("bpf, arm64: use bpf_prog_pack for memory management") Acked-by: Song Liu <song@kernel.org> Signed-off-by: Puranjay Mohan <puranjay@kernel.org> Acked-by: Breno Leitao <leitao@debian.org> Link: https://lore.kernel.org/r/20260413191111.3426023-2-puranjay@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fb74def commit 3172505

1 file changed

Lines changed: 0 additions & 12 deletions

File tree

arch/arm64/net/bpf_jit_comp.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include <asm/asm-extable.h>
2020
#include <asm/byteorder.h>
21-
#include <asm/cacheflush.h>
2221
#include <asm/cpufeature.h>
2322
#include <asm/debug-monitors.h>
2423
#include <asm/insn.h>
@@ -1961,11 +1960,6 @@ static int validate_ctx(struct jit_ctx *ctx)
19611960
return 0;
19621961
}
19631962

1964-
static inline void bpf_flush_icache(void *start, void *end)
1965-
{
1966-
flush_icache_range((unsigned long)start, (unsigned long)end);
1967-
}
1968-
19691963
static void priv_stack_init_guard(void __percpu *priv_stack_ptr, int alloc_size)
19701964
{
19711965
int cpu, underflow_idx = (alloc_size - PRIV_STACK_GUARD_SZ) >> 3;
@@ -2204,12 +2198,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
22042198
prog = orig_prog;
22052199
goto out_off;
22062200
}
2207-
/*
2208-
* The instructions have now been copied to the ROX region from
2209-
* where they will execute. Now the data cache has to be cleaned to
2210-
* the PoU and the I-cache has to be invalidated for the VAs.
2211-
*/
2212-
bpf_flush_icache(ro_header, ctx.ro_image + ctx.idx);
22132201
} else {
22142202
jit_data->ctx = ctx;
22152203
jit_data->ro_image = ro_image_ptr;

0 commit comments

Comments
 (0)