RE: [PATCH bpf-next] selftests/bpf: Using llvm may_goto inline asm for cond_break macro

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

 



Yonghong Song wrote:
> Currently, cond_break macro uses bytes to encode the may_goto insn.
> Patch [1] in llvm implemented may_goto insn in BPF backend.
> Replace byte-level encoding with llvm inline asm for better usability.
> Using llvm may_goto insn is controlled by macro __BPF_FEATURE_MAY_GOTO.
> 
>   [1] https://github.com/llvm/llvm-project/commit/0e0bfacff71859d1f9212205f8f873d47029d3fb
> 
> Signed-off-by: Yonghong Song <yonghong.song@xxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/bpf_experimental.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
> index a5b9df38c162..3329ea080865 100644
> --- a/tools/testing/selftests/bpf/bpf_experimental.h
> +++ b/tools/testing/selftests/bpf/bpf_experimental.h
> @@ -326,6 +326,16 @@ l_true:												\
>         })
>  #endif
>  
> +#ifdef __BPF_FEATURE_MAY_GOTO
> +#define cond_break					\
> +	({ __label__ l_break, l_continue;		\
> +	 asm volatile goto("may_goto %l[l_break]"	\
> +		      :::: l_break);			\
> +	goto l_continue;				\
> +	l_break: break;					\
> +	l_continue:;					\
> +	})
> +#else
>  #define cond_break					\
>  	({ __label__ l_break, l_continue;		\
>  	 asm volatile goto("1:.byte 0xe5;			\
> @@ -337,6 +347,7 @@ l_true:												\
>  	l_break: break;					\
>  	l_continue:;					\
>  	})
> +#endif
>  
>  #ifndef bpf_nop_mov
>  #define bpf_nop_mov(var) \
> -- 
> 2.43.0
> 
> 

Acked-by: John Fastabend <john.fastabend@xxxxxxxxx>




[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