All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Guo <guodongtai@kylinos.cn>
To: daniel@iogearbox.net
Cc: ast@kernel.org, bpf@vger.kernel.org, chenhuacai@kernel.org,
	guodongtai@kylinos.cn, kernel@xen0n.name,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	loongarch@lists.linux.dev, masahiroy@kernel.org,
	michal.lkml@markovi.net, ndesaulniers@google.com
Subject: [PATCH v2] loongarch/bpf: Skip speculation barrier opcode, which caused ltp testcase bpf_prog02 to fail
Date: Tue, 28 Mar 2023 15:13:35 +0800	[thread overview]
Message-ID: <20230328071335.2664966-1-guodongtai@kylinos.cn> (raw)
In-Reply-To: <c1932d0d-cf3f-5005-958d-7e08dddf42c9@iogearbox.net>

Here just skip the opcode(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>

---
Changelog:
v2:
	- place it to build_insn
	- add printing for skipping bpf_jit the opcode
---
 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..d3c6b1c4ccbb 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -1022,6 +1022,11 @@ 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:
+		pr_info_once("bpf_jit: skip speculation barrier opcode %0x2x\n", code);
+		break;
+
 	default:
 		pr_err("bpf_jit: unknown opcode %02x\n", code);
 		return -EINVAL;
-- 
2.34.1


  reply	other threads:[~2023-03-28  7:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` George Guo [this message]
2023-03-28  7:22     ` [PATCH v2] loongarch/bpf: Skip speculation barrier opcode, which caused ltp testcase bpf_prog02 to fail Daniel Borkmann
2023-03-28  7:52       ` WANG Xuerui
2023-03-28  8:37         ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230328071335.2664966-1-guodongtai@kylinos.cn \
    --to=guodongtai@kylinos.cn \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel@xen0n.name \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.