On Wed, 2025-08-27 at 11:15 +0800, Feng Yang wrote:
> From: Feng Yang <yangf...@kylinos.cn>
> 
> The following issue occurs when compiling with clang version 17.0.6,
> but not with version 18.1.8. Add a version restriction to fix this problem.
> 
> 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.
> 
> Fixes: 4a4b84ba9e453 ("selftests/bpf: verify jset handling in CFG 
> computation")
> Signed-off-by: Feng Yang <yangf...@kylinos.cn>
> ---
>  tools/testing/selftests/bpf/progs/compute_live_registers.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/progs/compute_live_registers.c 
> b/tools/testing/selftests/bpf/progs/compute_live_registers.c
> index 6884ab99a421..56aec43f206f 100644
> --- a/tools/testing/selftests/bpf/progs/compute_live_registers.c
> +++ b/tools/testing/selftests/bpf/progs/compute_live_registers.c
> @@ -240,6 +240,7 @@ __naked void if2(void)
>               ::: __clobber_all);
>  }
>  
> +#if __clang_major__ >= 18

Instead of guarding this with compiler version, could you please use
progs/bpf_misc.h:__imm_insn() macro for the jset instruction?

>  /* Verifier misses that r2 is alive if jset is not handled properly */
>  SEC("socket")
>  __log_level(2)
> @@ -255,6 +256,7 @@ __naked void if3_jset_bug(void)
>               "exit;"
>               ::: __clobber_all);
>  }
> +#endif
>  
>  SEC("socket")
>  __log_level(2)

Reply via email to