[DTrace-devel] [PATCH 04/12] options: report EDT_NOREG for iregs < DIF_DIR_NREGS

Kris Van Hees kris.van.hees at oracle.com
Sat Jan 6 01:11:56 UTC 2024


On Fri, Jan 05, 2024 at 04:22:09PM -0500, Eugene Loh via DTrace-devel wrote:
> See my comments to the 03/12 patch.

As you say in the comments there, -xiregs has become effectively obsolete,
but since it is an option DTrace accepts, we probably should continue to
accept it.  This patch ensure sthat the only valid value is DIF_DIR_NREGS.

As some point we can and shouold change this to be the number of BPF regs
that are available for general use.  But even then, we cannot really support
lowering that limit because there are so few BPF registers we can really use
anyway due to the function call clobberingh of %r0-%r5.

But this patch is the minimal change needed to ensure dtrace continues to
work.

> On 1/5/24 00:26, Kris Van Hees via DTrace-devel wrote:
> > The trampoline generation code hardcodes the use of %r7 and %r8, which
> > means that iregs cannot be less than 8 (DIF_DIR_NREGS).
> > 
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   libdtrace/dt_options.c            |  4 +++-
> >   test/unittest/options/tst.iregs.r | 26 +++++++-------------------
> >   2 files changed, 10 insertions(+), 20 deletions(-)
> > 
> > diff --git a/libdtrace/dt_options.c b/libdtrace/dt_options.c
> > index 6f7cf9e2..18b8f43a 100644
> > --- a/libdtrace/dt_options.c
> > +++ b/libdtrace/dt_options.c
> > @@ -1,6 +1,6 @@
> >   /*
> >    * Oracle Linux DTrace.
> > - * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
> > + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
> >    * Licensed under the Universal Permissive License v 1.0 as shown at
> >    * http://oss.oracle.com/licenses/upl.
> >    */
> > @@ -266,6 +266,8 @@ dt_opt_iregs(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
> >   	if (arg == NULL || (n = atoi(arg)) <= 0 || n > DIF_DIR_NREGS)
> >   		return dt_set_errno(dtp, EDT_BADOPTVAL);
> > +	if (n < DIF_DIR_NREGS)
> > +		return dt_set_errno(dtp, EDT_NOREG);
> >   	dtp->dt_conf.dtc_difintregs = n;
> >   	return 0;
> > diff --git a/test/unittest/options/tst.iregs.r b/test/unittest/options/tst.iregs.r
> > index 4926b28d..f67e7b07 100644
> > --- a/test/unittest/options/tst.iregs.r
> > +++ b/test/unittest/options/tst.iregs.r
> > @@ -1,25 +1,13 @@
> >   7
> >   iregs 8 gives 0
> > -7
> > -iregs 7 gives 0
> > -7
> > -iregs 6 gives 0
> > +iregs 7 gives 1
> > +iregs 6 gives 1
> >   iregs 5 gives 1
> >   iregs 4 gives 1
> >   iregs 3 gives 1
> >   -- @@stderr --
> > -dtrace: invalid probe specifier BEGIN {
> > -        a = b = c = d = e = f = g = h = i = j = k = l = 1;
> > -        trace(a + b * (c + d * (e + f * (g + h * (i + j * (k + l))))));
> > -        exit(0);
> > -    }: Insufficient registers to generate code
> > -dtrace: invalid probe specifier BEGIN {
> > -        a = b = c = d = e = f = g = h = i = j = k = l = 1;
> > -        trace(a + b * (c + d * (e + f * (g + h * (i + j * (k + l))))));
> > -        exit(0);
> > -    }: Insufficient registers to generate code
> > -dtrace: invalid probe specifier BEGIN {
> > -        a = b = c = d = e = f = g = h = i = j = k = l = 1;
> > -        trace(a + b * (c + d * (e + f * (g + h * (i + j * (k + l))))));
> > -        exit(0);
> > -    }: Insufficient registers to generate code
> > +dtrace: failed to set -x iregs: Insufficient registers to generate code
> > +dtrace: failed to set -x iregs: Insufficient registers to generate code
> > +dtrace: failed to set -x iregs: Insufficient registers to generate code
> > +dtrace: failed to set -x iregs: Insufficient registers to generate code
> > +dtrace: failed to set -x iregs: Insufficient registers to generate code
> 
> _______________________________________________
> 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