diff options
author | Xu Kuohai <xukuohai@huawei.com> | 2023-08-15 17:41:54 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-08-18 15:45:58 +0200 |
commit | bb0a1d6b49cb8293b09d290536315b4a134ef1e7 (patch) | |
tree | 363b297ca0a1461c8ac0a4572468be6e465a9c43 /arch/arm64/net/bpf_jit_comp.c | |
parent | bpf, arm64: Support sign-extension load instructions (diff) | |
download | linux-bb0a1d6b49cb8293b09d290536315b4a134ef1e7.tar.xz linux-bb0a1d6b49cb8293b09d290536315b4a134ef1e7.zip |
bpf, arm64: Support sign-extension mov instructions
Add JIT support for BPF sign-extension mov instructions with arm64
SXTB/SXTH/SXTW instructions.
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Florent Revest <revest@chromium.org>
Acked-by: Florent Revest <revest@chromium.org>
Link: https://lore.kernel.org/bpf/20230815154158.717901-4-xukuohai@huaweicloud.com
Diffstat (limited to 'arch/arm64/net/bpf_jit_comp.c')
-rw-r--r-- | arch/arm64/net/bpf_jit_comp.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 22f1b0d5fb3c..9b796e74ef42 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -786,7 +786,20 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, /* dst = src */ case BPF_ALU | BPF_MOV | BPF_X: case BPF_ALU64 | BPF_MOV | BPF_X: - emit(A64_MOV(is64, dst, src), ctx); + switch (insn->off) { + case 0: + emit(A64_MOV(is64, dst, src), ctx); + break; + case 8: + emit(A64_SXTB(is64, dst, src), ctx); + break; + case 16: + emit(A64_SXTH(is64, dst, src), ctx); + break; + case 32: + emit(A64_SXTW(is64, dst, src), ctx); + break; + } break; /* dst = dst OP src */ case BPF_ALU | BPF_ADD | BPF_X: |