]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf, arm64: Map BPF_REG_0 to x8 instead of x7
authorPuranjay Mohan <puranjay@kernel.org>
Wed, 13 May 2026 04:51:53 +0000 (21:51 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 13 May 2026 16:27:32 +0000 (09:27 -0700)
Move the BPF return value register from x7 to x8, freeing x7 for use
as an argument register. AAPCS64 designates x8 as the indirect result
location register; it is caller-saved and not used for argument
passing, making it a suitable home for BPF_REG_0.

This is a prerequisite for stack argument support, which needs x5-x7
to pass arguments 6-8 to native kfuncs following the AAPCS64 calling
convention.

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20260513045153.2402197-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm64/net/bpf_jit_comp.c
arch/arm64/net/bpf_timed_may_goto.S
tools/testing/selftests/bpf/progs/verifier_jit_inline.c
tools/testing/selftests/bpf/progs/verifier_ldsx.c
tools/testing/selftests/bpf/progs/verifier_private_stack.c

index 0816c40fc7af95b46da39a171b848b17c5d606e8..085e650662e3dd7c5e57453c7e48e467fda5edfd 100644 (file)
@@ -47,7 +47,7 @@
 /* Map BPF registers to A64 registers */
 static const int bpf2a64[] = {
        /* return value from in-kernel function, and exit value from eBPF */
-       [BPF_REG_0] = A64_R(7),
+       [BPF_REG_0] = A64_R(8),
        /* arguments from eBPF program to in-kernel function */
        [BPF_REG_1] = A64_R(0),
        [BPF_REG_2] = A64_R(1),
@@ -1048,7 +1048,7 @@ static void build_epilogue(struct jit_ctx *ctx, bool was_classic)
        /* Restore FP/LR registers */
        emit(A64_POP(A64_FP, A64_LR, A64_SP), ctx);
 
-       /* Move the return value from bpf:r0 (aka x7) to x0 */
+       /* Move the return value from bpf:r0 (aka x8) to x0 */
        emit(A64_MOV(1, A64_R(0), r0), ctx);
 
        /* Authenticate lr */
index 894cfcd7b2416dd738521e0245ed6e17fca2be28..a9a802711a7f9dc84b7d3644112e9577a7c4cebd 100644 (file)
@@ -8,8 +8,8 @@ SYM_FUNC_START(arch_bpf_timed_may_goto)
        stp     x29, x30, [sp, #-64]!
        mov     x29, sp
 
-       /* Save BPF registers R0 - R5 (x7, x0-x4)*/
-       stp     x7, x0, [sp, #16]
+       /* Save BPF registers R0 - R5 (x8, x0-x4)*/
+       stp     x8, x0, [sp, #16]
        stp     x1, x2, [sp, #32]
        stp     x3, x4, [sp, #48]
 
@@ -28,8 +28,8 @@ SYM_FUNC_START(arch_bpf_timed_may_goto)
        /* BPF_REG_AX(x9) will be stored into count, so move return value to it. */
        mov     x9, x0
 
-       /* Restore BPF registers R0 - R5 (x7, x0-x4) */
-       ldp     x7, x0, [sp, #16]
+       /* Restore BPF registers R0 - R5 (x8, x0-x4) */
+       ldp     x8, x0, [sp, #16]
        ldp     x1, x2, [sp, #32]
        ldp     x3, x4, [sp, #48]
 
index 4ea25406364674a6a4d0be109c276f48cf3cb173..885ff69a3a620428550e785263ce427a476735fe 100644 (file)
@@ -9,7 +9,7 @@ __success __retval(0)
 __arch_x86_64
 __jited("      addq    %gs:{{.*}}, %rax")
 __arch_arm64
-__jited("      mrs     x7, SP_EL0")
+__jited("      mrs     x8, SP_EL0")
 int inline_bpf_get_current_task(void)
 {
        bpf_get_current_task();
index 1026524a1983c60cad9f670c1d8493ed028ef704..41340877dc9d97a75b127b3808fa7c047039115c 100644 (file)
@@ -274,11 +274,11 @@ __jited("movslq   0x10(%rdi,%r12), %r15")
 __jited("movswq        0x18(%rdi,%r12), %r15")
 __jited("movsbq        0x20(%rdi,%r12), %r15")
 __arch_arm64
-__jited("add   x11, x7, x28")
+__jited("add   x11, x8, x28")
 __jited("ldrsw x21, [x11, #0x10]")
-__jited("add   x11, x7, x28")
+__jited("add   x11, x8, x28")
 __jited("ldrsh x21, [x11, #0x18]")
-__jited("add   x11, x7, x28")
+__jited("add   x11, x8, x28")
 __jited("ldrsb x21, [x11, #0x20]")
 __jited("add   x11, x0, x28")
 __jited("ldrsw x22, [x11, #0x10]")
index 646e8ef820510d017a655d63b719a065a43d2aa5..c5078face38dadac9a68f859e8471d79843a3cd9 100644 (file)
@@ -170,12 +170,12 @@ __jited(" mrs     x10, TPIDR_EL{{[0-1]}}")
 __jited("      add     x27, x27, x10")
 __jited("      add     x25, x27, {{.*}}")
 __jited("      bl      0x{{.*}}")
-__jited("      mov     x7, x0")
+__jited("      mov     x8, x0")
 __jited("      mov     x0, #0x2a")
 __jited("      str     x0, [x27]")
 __jited("      bl      0x{{.*}}")
-__jited("      mov     x7, x0")
-__jited("      mov     x7, #0x0")
+__jited("      mov     x8, x0")
+__jited("      mov     x8, #0x0")
 __jited("      ldp     x25, x27, [sp], {{.*}}")
 __naked void private_stack_callback(void)
 {
@@ -220,7 +220,7 @@ __jited("   mov     x0, #0x2a")
 __jited("      str     x0, [x27]")
 __jited("      mov     x0, #0x0")
 __jited("      bl      0x{{.*}}")
-__jited("      mov     x7, x0")
+__jited("      mov     x8, x0")
 __jited("      ldp     x27, x28, [sp], #0x10")
 int private_stack_exception_main_prog(void)
 {
@@ -258,7 +258,7 @@ __jited("   add     x25, x27, {{.*}}")
 __jited("      mov     x0, #0x2a")
 __jited("      str     x0, [x27]")
 __jited("      bl      0x{{.*}}")
-__jited("      mov     x7, x0")
+__jited("      mov     x8, x0")
 __jited("      ldp     x27, x28, [sp], #0x10")
 int private_stack_exception_sub_prog(void)
 {