mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
LoongArch, bpf: Fix jit to skip speculation barrier opcode
[ Upstream commita6f6a95f25
] 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:5dc615520c
("LoongArch: Add BPF JIT support") Signed-off-by: George Guo <guodongtai@kylinos.cn> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: WANG Xuerui <git@xen0n.name> Cc: Tiezhu Yang <yangtiezhu@loongson.cn> Link: https://lore.kernel.org/bpf/20230328071335.2664966-1-guodongtai@kylinos.cn Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2b4468f334
commit
d9263793f7
1 changed files with 4 additions and 0 deletions
|
@ -1022,6 +1022,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
|
|||
emit_atomic(insn, ctx);
|
||||
break;
|
||||
|
||||
/* Speculation barrier */
|
||||
case BPF_ST | BPF_NOSPEC:
|
||||
break;
|
||||
|
||||
default:
|
||||
pr_err("bpf_jit: unknown opcode %02x\n", code);
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Reference in a new issue