Commit f4a66cf1 authored by Puranjay Mohan's avatar Puranjay Mohan Committed by Alexei Starovoitov
Browse files

bpf: arm64: Add support for indirect jumps



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 assures that the Rx
register contains a value (or a range of values) loaded from a
correct jump table – map of type instruction array.

ARM64 JIT supports indirect jumps to all registers through the A64_BR()
macro, use it to implement this new instruction.

Signed-off-by: default avatarPuranjay Mohan <puranjay@kernel.org>
Reviewed-by: default avatarAnton Protopopov <a.s.protopopov@gmail.com>
Acked-by: default avatarXu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/r/20251117130732.11107-3-puranjay@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 84b1c40d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1452,6 +1452,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
		emit(A64_ASR(is64, dst, dst, imm), ctx);
		break;

	/* JUMP reg */
	case BPF_JMP | BPF_JA | BPF_X:
		emit(A64_BR(dst), ctx);
		break;
	/* JUMP off */
	case BPF_JMP | BPF_JA:
	case BPF_JMP32 | BPF_JA: