Skip to content

Commit a6f6a95

Browse files
georgejguoborkmann
authored andcommitted
LoongArch, bpf: Fix jit to skip speculation barrier opcode
Just skip the opcode(BPF_ST | BPF_NOSPEC) in the BPF JIT instead of failing to JIT the entire program, given LoongArch currently has no couterpart of a speculation barrier instruction. To verify the issue, use the ltp testcase as shown below. Also, Wang says: I can confirm there's currently no speculation barrier equivalent on LonogArch. (Loongson says there are builtin mitigations for Spectre-V1 and V2 on their chips, and AFAIK efforts to port the exploits to mips/LoongArch have all failed a few years ago.) Without this patch: $ ./bpf_prog02 [...] bpf_common.c:123: TBROK: Failed verification: ??? (524) [...] Summary: passed 0 failed 0 broken 1 skipped 0 warnings 0 With this patch: $ ./bpf_prog02 [...] Summary: passed 0 failed 0 broken 0 skipped 0 warnings 0 Fixes: 5dc6155 ("LoongArch: Add BPF JIT support") Signed-off-by: George Guo <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: WANG Xuerui <[email protected]> Cc: Tiezhu Yang <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 580031f commit a6f6a95

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/loongarch/net/bpf_jit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
10221022
emit_atomic(insn, ctx);
10231023
break;
10241024

1025+
/* Speculation barrier */
1026+
case BPF_ST | BPF_NOSPEC:
1027+
break;
1028+
10251029
default:
10261030
pr_err("bpf_jit: unknown opcode %02x\n", code);
10271031
return -EINVAL;

0 commit comments

Comments
 (0)