]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
powerpc/bpf: Add support for instruction array
authorAbhishek Dubey <adubey@linux.ibm.com>
Wed, 1 Apr 2026 15:21:30 +0000 (11:21 -0400)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Fri, 3 Apr 2026 08:44:25 +0000 (14:14 +0530)
On loading the BPF program, the verifier might adjust/omit some
instructions. The adjusted instruction offset is accounted in the
map containing original instruction -> xlated mapping. This patch
add ppc64 JIT support to additionally build the xlated->jitted
mapping for every instruction present in instruction array. This
change is needed to enable support for indirect jumps, added in a
subsequent patch.

Invoke bpf_prog_update_insn_ptrs() with offset pair of xlated_offset
and jited_offset. The offset mapping is already available, which is
being used for bpf_prog_fill_jited_linfo() and can be directly used
for bpf_prog_update_insn_ptrs() as well.

Additional details present at:

commit b4ce5923e780 ("bpf, x86: add new map type: instructions array")

Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260401152133.42544-2-adubey@linux.ibm.com
arch/powerpc/net/bpf_jit_comp.c

index b2fdf8ff9c604836595e86f84f7d0d83132b7c75..50103b3794fb7314d3ba14b17eb9a287b4081107 100644 (file)
@@ -373,6 +373,13 @@ skip_init_ctx:
                        goto out_addrs;
                }
                bpf_prog_fill_jited_linfo(fp, addrs);
+               /*
+                * On ABI V1, executable code starts after the function
+                * descriptor, so adjust base accordingly.
+                */
+               bpf_prog_update_insn_ptrs(fp, addrs,
+                               (void *)fimage + FUNCTION_DESCR_SIZE);
+
 out_addrs:
                if (!image && priv_stack_ptr) {
                        fp->aux->priv_stack_ptr = NULL;