]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf, riscv: Remove redundant bpf_flush_icache() after pack allocator finalize
authorPuranjay Mohan <puranjay@kernel.org>
Mon, 13 Apr 2026 19:11:09 +0000 (12:11 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 15 Apr 2026 19:09:46 +0000 (12:09 -0700)
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 48a8f78c50bd ("bpf, riscv: use prog pack allocator in the
BPF JIT"), this flush is redundant.

bpf_jit_binary_pack_finalize() copies the JITed instructions to the ROX
region via bpf_arch_text_copy() -> patch_text_nosync(), and
patch_text_nosync() already calls flush_icache_range() on the written
range. The subsequent bpf_flush_icache() repeats the same cache
maintenance on an overlapping range.

Remove the redundant bpf_flush_icache() call and its now-unused
definition.

Fixes: 48a8f78c50bd ("bpf, riscv: use prog pack allocator in the BPF JIT")
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Reviewed-by: Pu Lehui <pulehui@huawei.com>
Tested-by: Paul Chaignon <paul.chaignon@gmail.com>
Link: https://lore.kernel.org/r/20260413191111.3426023-3-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/riscv/net/bpf_jit.h
arch/riscv/net/bpf_jit_core.c

index 632ced07bca4420197bbda76fb5fb19874d697b5..da02717902442158e196acbddb161a9d06d72315 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/bpf.h>
 #include <linux/filter.h>
-#include <asm/cacheflush.h>
 
 /* verify runtime detection extension status */
 #define rv_ext_enabled(ext) \
@@ -105,11 +104,6 @@ static inline void bpf_fill_ill_insns(void *area, unsigned int size)
        memset(area, 0, size);
 }
 
-static inline void bpf_flush_icache(void *start, void *end)
-{
-       flush_icache_range((unsigned long)start, (unsigned long)end);
-}
-
 /* Emit a 4-byte riscv instruction. */
 static inline void emit(const u32 insn, struct rv_jit_context *ctx)
 {
index b3581e9264362942141bae41330c8c6ccfdabdf4..f7fd4afc3ca3f4496794a628f0acf83a8bc4aa29 100644 (file)
@@ -183,13 +183,6 @@ skip_init_ctx:
                        prog = orig_prog;
                        goto out_offset;
                }
-               /*
-                * The instructions have now been copied to the ROX region from
-                * where they will execute.
-                * Write any modified data cache blocks out to memory and
-                * invalidate the corresponding blocks in the instruction cache.
-                */
-               bpf_flush_icache(jit_data->ro_header, ctx->ro_insns + ctx->ninsns);
                for (i = 0; i < prog->len; i++)
                        ctx->offset[i] = ninsns_rvoff(ctx->offset[i]);
                bpf_prog_fill_jited_linfo(prog, ctx->offset);