Skip to content

Commit a32325c

Browse files
Abhishek Dubeymaddy-kerneldev
authored andcommitted
powerpc64/bpf: Add support for indirect jump
Add support for a new instruction BPF_JMP|BPF_X|BPF_JA, SRC=0, DST=Rx, off=0, imm=0 which does an indirect jump to a location stored in Rx. The register Rx should have type PTR_TO_INSN. This new type ensures that the Rx register contains a value (or a range of values) loaded from a correct jump table – map of type instruction array. Support indirect jump to all registers in powerpc64 JIT using the ctr register. Move Rx content to ctr register, then invoke bctr instruction to branch to address stored in ctr register. Skip save and restore of TOC as the jump is always within the program context. 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-4-adubey@linux.ibm.com
1 parent 66cad93 commit a32325c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

arch/powerpc/net/bpf_jit_comp64.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,14 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code
17081708
addrs[++i] = ctx->idx * 4;
17091709
break;
17101710

1711+
/*
1712+
* JUMP reg
1713+
*/
1714+
case BPF_JMP | BPF_JA | BPF_X:
1715+
EMIT(PPC_RAW_MTCTR(dst_reg));
1716+
EMIT(PPC_RAW_BCTR());
1717+
break;
1718+
17111719
/*
17121720
* Return/Exit
17131721
*/

0 commit comments

Comments
 (0)