diff options
author | Puranjay Mohan | 2024-03-24 18:32:26 +0000 |
---|---|---|
committer | Alexei Starovoitov | 2024-03-25 09:10:51 -0700 |
commit | 770546ae9f4c1ae1ebcaf0874f0dd9631d77ec97 (patch) | |
tree | 3a7bbdf305e2c5ab7154fdd2c40216f17f3e4e69 /arch | |
parent | a8497506cd2c0fc90a64f6f5d2744a0ddb2c81eb (diff) |
bpf: implement insn_is_cast_user() helper for JITs
Implement a helper function to check if an instruction is
addr_space_cast from as(0) to as(1). Use this helper in the x86 JIT.
Other JITs can use this helper when they add support for this instruction.
Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
Link: https://lore.kernel.org/r/20240324183226.29674-1-puranjay12@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/net/bpf_jit_comp.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 4900b1ee019f..3b639d6f2f54 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -1351,8 +1351,7 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, u8 *rw_image break; case BPF_ALU64 | BPF_MOV | BPF_X: - if (insn->off == BPF_ADDR_SPACE_CAST && - insn->imm == 1U << 16) { + if (insn_is_cast_user(insn)) { if (dst_reg != src_reg) /* 32-bit mov */ emit_mov_reg(&prog, false, dst_reg, src_reg); |