Skip to content

Commit 77ad43a

Browse files
puranjaymohangregkh
authored andcommitted
bpf, riscv: Remove redundant bpf_flush_icache() after pack allocator finalize
[ Upstream commit 46ee134 ] 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 48a8f78 ("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: 48a8f78 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ca51684 commit 77ad43a

2 files changed

Lines changed: 0 additions & 13 deletions

File tree

arch/riscv/net/bpf_jit.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <linux/bpf.h>
1313
#include <linux/filter.h>
14-
#include <asm/cacheflush.h>
1514

1615
/* verify runtime detection extension status */
1716
#define rv_ext_enabled(ext) \
@@ -105,11 +104,6 @@ static inline void bpf_fill_ill_insns(void *area, unsigned int size)
105104
memset(area, 0, size);
106105
}
107106

108-
static inline void bpf_flush_icache(void *start, void *end)
109-
{
110-
flush_icache_range((unsigned long)start, (unsigned long)end);
111-
}
112-
113107
/* Emit a 4-byte riscv instruction. */
114108
static inline void emit(const u32 insn, struct rv_jit_context *ctx)
115109
{

arch/riscv/net/bpf_jit_core.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
183183
prog = orig_prog;
184184
goto out_offset;
185185
}
186-
/*
187-
* The instructions have now been copied to the ROX region from
188-
* where they will execute.
189-
* Write any modified data cache blocks out to memory and
190-
* invalidate the corresponding blocks in the instruction cache.
191-
*/
192-
bpf_flush_icache(jit_data->ro_header, ctx->ro_insns + ctx->ninsns);
193186
for (i = 0; i < prog->len; i++)
194187
ctx->offset[i] = ninsns_rvoff(ctx->offset[i]);
195188
bpf_prog_fill_jited_linfo(prog, ctx->offset);

0 commit comments

Comments
 (0)