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

Kris Van Hees kris.van.hees at oracle.com
Wed Apr 8 13:43:02 PDT 2020


On Wed, Apr 08, 2020 at 01:04:57PM -0700, Eugene Loh wrote:
> 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.

Not for this because this is only used when we are looking at instructions that
may need patching during relocation processing.  IF we were to use this in a
more generic fashion then yes, we'd need to implement this in a different way.

Incidentally, there is no computed call instruction in BPF, so no calls using
a delta that is read fromn a register value.

> >   #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 &&			\
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list