Skip to content

Commit 7c9471e

Browse files
kknjhKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix the invalid operand for instruction issue
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: 4a4b84b ("selftests/bpf: verify jset handling in CFG computation") Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
1 parent 2990ade commit 7c9471e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/testing/selftests/bpf/progs/compute_live_registers.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,13 @@ __naked void if3_jset_bug(void)
249249
asm volatile (
250250
"r0 = 1;"
251251
"r2 = 2;"
252-
"if r1 & 0x7 goto +1;"
252+
".8byte %[jset];" /* same as 'if r1 & 0x7 goto +1;' */
253253
"exit;"
254254
"r0 = r2;"
255255
"exit;"
256-
::: __clobber_all);
256+
:
257+
: __imm_insn(jset, BPF_JMP_IMM(BPF_JSET, BPF_REG_1, 0x7, 1))
258+
: __clobber_all);
257259
}
258260

259261
SEC("socket")

0 commit comments

Comments
 (0)