Skip to content

Commit 471f3d4

Browse files
puranjaymohanAlexei Starovoitov
authored and
Alexei Starovoitov
committed
arm32, bpf: add support for 32-bit offset jmp instruction
The cpuv4 adds unconditional jump with 32-bit offset where the immediate field of the instruction is to be used to calculate the jump offset. BPF_JA | BPF_K | BPF_JMP32 => gotol +imm => PC += imm. Signed-off-by: Puranjay Mohan <puranjay12@gmail.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://lore.kernel.org/r/20230907230550.1417590-2-puranjay12@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 9b2b863 commit 471f3d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/arm/net/bpf_jit_32.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,10 +1761,15 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
17611761
break;
17621762
/* JMP OFF */
17631763
case BPF_JMP | BPF_JA:
1764+
case BPF_JMP32 | BPF_JA:
17641765
{
1765-
if (off == 0)
1766+
if (BPF_CLASS(code) == BPF_JMP32 && imm != 0)
1767+
jmp_offset = bpf2a32_offset(i + imm, i, ctx);
1768+
else if (BPF_CLASS(code) == BPF_JMP && off != 0)
1769+
jmp_offset = bpf2a32_offset(i + off, i, ctx);
1770+
else
17661771
break;
1767-
jmp_offset = bpf2a32_offset(i+off, i, ctx);
1772+
17681773
check_imm24(jmp_offset);
17691774
emit(ARM_B(jmp_offset), ctx);
17701775
break;

0 commit comments

Comments
 (0)