* [PATCH v2 bpf-next] selftests/bpf: Fix the invalid operand for instruction issue
@ 2025-08-28 2:01 Feng Yang
2025-09-04 15:48 ` Eduard Zingerman
0 siblings, 1 reply; 3+ messages in thread
From: Feng Yang @ 2025-08-28 2:01 UTC (permalink / raw)
To: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
yonghong.song, kpsingh, sdf, haoluo, jolsa
Cc: bpf, linux-kernel, linux-kselftest, llvm
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 bpf-next] selftests/bpf: Fix the invalid operand for instruction issue
2025-08-28 2:01 [PATCH v2 bpf-next] selftests/bpf: Fix the invalid operand for instruction issue Feng Yang
@ 2025-09-04 15:48 ` Eduard Zingerman
2025-09-05 6:00 ` Feng Yang
0 siblings, 1 reply; 3+ messages in thread
From: Eduard Zingerman @ 2025-09-04 15:48 UTC (permalink / raw)
To: Feng Yang, ast, daniel, john.fastabend, andrii, martin.lau, song,
yonghong.song, kpsingh, sdf, haoluo, jolsa
Cc: bpf, linux-kernel, linux-kselftest, llvm
On Thu, 2025-08-28 at 10:01 +0800, Feng Yang wrote:
> 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>
> ---
Hi Feng,
This message felt through cracks a bit. It's a minor thing, of
course, but there is a legit question of how much backward we'd like
to support clang versions for the test suite.
Could you please provide some detail on your build environment,
why do you want to run the tests with older clang?
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 bpf-next] selftests/bpf: Fix the invalid operand for instruction issue
2025-09-04 15:48 ` Eduard Zingerman
@ 2025-09-05 6:00 ` Feng Yang
0 siblings, 0 replies; 3+ messages in thread
From: Feng Yang @ 2025-09-05 6:00 UTC (permalink / raw)
To: eddyz87
Cc: andrii, ast, bpf, daniel, haoluo, john.fastabend, jolsa, kpsingh,
linux-kernel, linux-kselftest, llvm, martin.lau, sdf, song,
yangfeng59949, yonghong.song
On Thu, 04 Sep 2025 08:48:45 -0700 Eduard Zingerman wrote:
> On Thu, 2025-08-28 at 10:01 +0800, Feng Yang wrote:
> > 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>
> > ---
>
> Hi Feng,
>
> This message felt through cracks a bit. It's a minor thing, of
> course, but there is a legit question of how much backward we'd like
> to support clang versions for the test suite.
>
> Could you please provide some detail on your build environment,
> why do you want to run the tests with older clang?
Hi Eduard,
Actually, there is no specific reason to test with an older version of Clang.
It's just that the Clang downloaded from the source is this version,
and installing a newer version by myself would be rather troublesome.
clang version 17.0.6
GNU Make 4.4.1
gcc (GCC) 12.3.1
linux version: 6.6
arch: x86-64
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-05 6:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 2:01 [PATCH v2 bpf-next] selftests/bpf: Fix the invalid operand for instruction issue Feng Yang
2025-09-04 15:48 ` Eduard Zingerman
2025-09-05 6:00 ` Feng Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).