[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230326044019.2139628-1-guodongtai@kylinos.cn>
Date: Sun, 26 Mar 2023 12:40:19 +0800
From: George Guo <guodongtai@...inos.cn>
To: chenhuacai@...nel.org, masahiroy@...nel.org,
michal.lkml@...kovi.net
Cc: kernel@...0n.name, ndesaulniers@...gle.com, daniel@...earbox.net,
ast@...nel.org, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org,
bpf@...r.kernel.org
Subject: [PATCH] loongarch/bpf: Fix bpf load failed with CONFIG_BPF_JIT_ALWAYS_ON, caused by jit (BPF_ST | BPF_NOSPEC) code
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@...inos.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
Powered by blists - more mailing lists