[DTrace-devel] [PATCH] Add BPF_IS_CALL(x) macro

Eugene Loh eugene.loh at oracle.com
Wed Apr 8 13:04:57 PDT 2020


On 04/08/2020 08:00 AM, Kris Van Hees wrote:

> Adding a BPF_IS_CALL(x) macro to conveniently determine whether a BPF
> instruction is a function call.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   include/bpf_asm.h | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/include/bpf_asm.h b/include/bpf_asm.h
> index d3f95d55..7891a597 100644
> --- a/include/bpf_asm.h
> +++ b/include/bpf_asm.h
> @@ -144,7 +144,9 @@
>   
>   #define BPF_NOP()	BPF_JUMP(0)
>   
> +#define BPF_IS_CALL(x)	((x).code == (BPF_JMP | BPF_CALL))

Sorry for the dumb question, but might we care someday about the case of 
BPF_CALL | BPF_X | BPF_JMP?  That is, use src_reg as the source?  I have 
no idea.  Just asking.

>   #define BPF_IS_NOP(x)	((x).code == (BPF_JMP | BPF_JA) && (x).off == 0)
> +
>   #define BPF_EQUAL(x, y)	((x).code == (y).code &&			\
>   			 (x).dst_reg == (y).dst_reg &&			\
>   			 (x).src_reg == (y).src_reg &&			\




More information about the DTrace-devel mailing list