mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] loongarch/bpf: Fix bpf load failed with CONFIG_BPF_JIT_ALWAYS_ON, caused by jit (BPF_ST | BPF_NOSPEC) code
@ 2023-03-26  4:40 George Guo
  2023-03-27  9:29 ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: George Guo @ 2023-03-26  4:40 UTC (permalink / raw)
  To: chenhuacai, masahiroy, michal.lkml
  Cc: kernel, ndesaulniers, daniel, ast, loongarch, linux-kernel,
	linux-kbuild, bpf

Here just skip the code(BPF_ST | BPF_NOSPEC) that has no couterpart to the loongarch.

To verify, use ltp testcase:

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

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 arch/loongarch/net/bpf_jit.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index 288003a9f0ca..745d344385ed 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -1046,6 +1046,11 @@ static int build_body(struct jit_ctx *ctx, bool extra_pass)
 		if (ctx->image == NULL)
 			ctx->offset[i] = ctx->idx;
 
+		/* skip the code that has no couterpart to the host arch */
+		if(insn->code == (BPF_ST | BPF_NOSPEC)) {
+			continue;
+		}
+
 		ret = build_insn(insn, ctx, extra_pass);
 		if (ret > 0) {
 			i++;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-28  8:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-26  4:40 [PATCH] loongarch/bpf: Fix bpf load failed with CONFIG_BPF_JIT_ALWAYS_ON, caused by jit (BPF_ST | BPF_NOSPEC) code George Guo
2023-03-27  9:29 ` Daniel Borkmann
2023-03-28  7:13   ` [PATCH v2] loongarch/bpf: Skip speculation barrier opcode, which caused ltp testcase bpf_prog02 to fail George Guo
2023-03-28  7:22     ` Daniel Borkmann
2023-03-28  7:52       ` WANG Xuerui
2023-03-28  8:37         ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®