mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Feng Yang <yangfeng59949@163.com>
To: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
	andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
	song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
	sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH v2 bpf-next] selftests/bpf: Fix the invalid operand for instruction issue
Date: Thu, 28 Aug 2025 10:01:35 +0800	[thread overview]
Message-ID: <20250828020135.248869-1-yangfeng59949@163.com> (raw)

From: Feng Yang <yangfeng@kylinos.cn>

The following issue occurs when compiling with clang version 17.0.6:
progs/compute_live_registers.c:251:3: error: invalid operand for instruction
  251 |                 "r0 = 1;"
      |                 ^
<inline asm>:1:22: note: instantiated into assembly here
    1 |         r0 = 1;r2 = 2;if r1 & 0x7 goto +1;exit;r0 = r2;exit;
      |                             ^
1 error generated.

Use __imm_insn to fix this issue.

Fixes: 4a4b84ba9e453 ("selftests/bpf: verify jset handling in CFG computation")
Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
---
Changes in v2:
- Use __imm_insn, thanks: Eduard Zingerman.
- Link to v1: https://lore.kernel.org/all/20250827031540.461017-1-yangfeng59949@163.com/
---
 tools/testing/selftests/bpf/progs/compute_live_registers.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/compute_live_registers.c b/tools/testing/selftests/bpf/progs/compute_live_registers.c
index 6884ab99a421..01d73ad76faf 100644
--- a/tools/testing/selftests/bpf/progs/compute_live_registers.c
+++ b/tools/testing/selftests/bpf/progs/compute_live_registers.c
@@ -249,11 +249,13 @@ __naked void if3_jset_bug(void)
 	asm volatile (
 		"r0 = 1;"
 		"r2 = 2;"
-		"if r1 & 0x7 goto +1;"
+		".8byte %[jset];" /* same as 'if r1 & 0x7 goto +1;' */
 		"exit;"
 		"r0 = r2;"
 		"exit;"
-		::: __clobber_all);
+		:
+		: __imm_insn(jset, BPF_JMP_IMM(BPF_JSET, BPF_REG_1, 0x7, 1))
+		: __clobber_all);
 }
 
 SEC("socket")
-- 
2.43.0


             reply	other threads:[~2025-08-28  2:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-28  2:01 Feng Yang [this message]
2025-09-04 15:48 ` Eduard Zingerman
2025-09-05  6:00   ` Feng Yang

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=20250828020135.248869-1-yangfeng59949@163.com \
    --to=yangfeng59949@163.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 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®