[PATCH bpf-next 5/6] bpf, arm64: Defer trampoline creation instruction sync
From: Xu Kuohai
Date: Sun Dec 06 2026 - 04:51:51 EST
From: Xu Kuohai <xukuohai@xxxxxxxxxx>
Use bpf_arch_text_copy_nosync() to copy trampoline images since the
generic code handles the instruction sync. Also return immediately on
trampoline generation failure, to avoid copying a discarded partial
image.
Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
---
arch/arm64/net/bpf_jit_comp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 76d25947ace6..7b5519f1159c 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -4002,6 +4002,8 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *ro_image,
if (ret)
goto out;
ret = prepare_trampoline(&ctx, im, tnodes, func_addr, m, &aaux, flags);
+ if (ret < 0)
+ goto out;
if (ret > 0 && validate_code(&ctx) < 0) {
ret = -EINVAL;
@@ -4011,7 +4013,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *ro_image,
if (ret > 0)
ret *= AARCH64_INSN_SIZE;
- tmp = bpf_arch_text_copy(ro_image, image, size);
+ tmp = bpf_arch_text_copy_nosync(ro_image, image, size);
if (IS_ERR(tmp)) {
ret = PTR_ERR(tmp);
goto out;
--
2.47.3