[DTrace-devel] [PATCH 1/2] bpf: add PC to fault reporting using dt_probe_error()

Kris Van Hees kris.van.hees at oracle.com
Thu May 11 17:23:28 UTC 2023


On Thu, May 11, 2023 at 11:50:31AM -0400, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> but surely it's possible to have at least rudimentary tests for this.

Not really - or at least not in the long run because these failure cases are
all situations where something goes wrong that is unexpected.  I.e. we cannot
really create the failure case on purpose.

(OK, right now we can because not all builtin variables are implemented yet,
 and therefore trying to get the value of one not implemented will yield an
 ILLOP fault but that isn't (in th elong run) supposed to happen because we
 should implement all builtin variables.)

> On 5/11/23 01:23, Kris Van Hees via DTrace-devel wrote:
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   bpf/get_bvar.c    | 3 ++-
> >   bpf/speculation.c | 3 ++-
> >   2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/bpf/get_bvar.c b/bpf/get_bvar.c
> > index ef2e2ca6..4fc6b880 100644
> > --- a/bpf/get_bvar.c
> > +++ b/bpf/get_bvar.c
> > @@ -23,13 +23,14 @@ extern struct bpf_map_def cpuinfo;
> >   extern struct bpf_map_def probes;
> >   extern struct bpf_map_def state;
> > +extern uint64_t PC;
> >   extern uint64_t STBSZ;
> >   extern uint64_t STKSIZ;
> >   extern uint64_t BOOTTM;
> >   #define error(dctx, fault, illval) \
> >   	({ \
> > -		dt_probe_error((dctx), -1, (fault), (illval)); \
> > +		dt_probe_error((dctx), (uint64_t)&PC, (fault), (illval)); \
> >   		-1; \
> >   	})
> > diff --git a/bpf/speculation.c b/bpf/speculation.c
> > index 6e032a44..c565c8da 100644
> > --- a/bpf/speculation.c
> > +++ b/bpf/speculation.c
> > @@ -20,6 +20,7 @@
> >   extern struct bpf_map_def specs;
> >   extern struct bpf_map_def state;
> > +extern uint64_t PC;
> >   extern uint64_t NSPEC;
> >   /*
> > @@ -151,7 +152,7 @@ dt_speculation_set_drainable(const dt_dctx_t *dctx, uint32_t id)
> >   	if ((spec = bpf_map_lookup_elem(&specs, &id)) == NULL) {
> >   		if (id <= (uint64_t) &NSPEC)
> >   			return 0;
> > -		dt_probe_error(dctx, -1, DTRACEFLT_ILLOP, 0);
> > +		dt_probe_error(dctx, (uint64_t)&PC, DTRACEFLT_ILLOP, 0);
> >   		return -1;
> >   	}
> >   	spec->draining = 1;
> 
> _______________________________________________
> 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