Re: [PATCH bpf-next] selftests/bpf: Fix the invalid operand for instruction issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2025-08-27 at 16:24 +0800, Feng Yang wrote:

[...]

> I don't know much about assembly language. Could you tell me if the following changes are correct?

Looks correct, should be similar to verifier_search_pruning.c:short_loop1().

Unfortunately, I'm afraid that the best source for assembly syntax doc
are llvm backend tests and sources, e.g.:
- https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/BPF/assembler-disassembler.s
- https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/BPF/assembler-disassembler-v4.s
- https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/BPF/BPFInstrInfo.td

The directives should gas compatible (subset supported by llvm):
- https://sourceware.org/binutils/docs/as/8byte.html

> 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);
>  }
> 





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux