[PATCH bpf-next 4/6] bpf, arm64: Defer JIT instruction sync

From: Xu Kuohai

Date: Sun Dec 06 2026 - 04:51:31 EST


From: Xu Kuohai <xukuohai@xxxxxxxxxx>

Override bpf_arch_text_copy_nosync() and bpf_arch_text_synchronize()
on arm64 to enable deferred instruction sync for JIT. Also switch the
JIT error path to the nosync text copy.

Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
---
arch/arm64/net/bpf_jit_comp.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 3ac287580d22..76d25947ace6 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -3231,8 +3231,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
prog->jited_len = 0;
}
if (header) {
- bpf_arch_text_copy(&ro_header->size, &header->size,
- sizeof(header->size));
+ bpf_arch_text_copy_nosync(&ro_header->size, &header->size,
+ sizeof(header->size));
bpf_jit_binary_pack_free(ro_header, header);
/* The private stack goes with the image, see out_off */
ro_header = NULL;
@@ -3288,6 +3288,18 @@ void *bpf_arch_text_copy(void *dst, void *src, size_t len)
return dst;
}

+void *bpf_arch_text_copy_nosync(void *dst, void *src, size_t len)
+{
+ if (!aarch64_insn_copy_nosync(dst, src, len))
+ return ERR_PTR(-EINVAL);
+ return dst;
+}
+
+void bpf_arch_text_synchronize(void)
+{
+ kick_all_cpus_sync();
+}
+
u64 bpf_jit_alloc_exec_limit(void)
{
return VMALLOC_END - VMALLOC_START;
--
2.47.3