[DTrace-devel] [PATCH] Fix %r0 register leak

Kris Van Hees kris.van.hees at oracle.com
Mon Dec 13 05:43:23 UTC 2021


On Sun, Dec 12, 2021 at 07:58:41PM -0500, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

Thanks.

> BTW (I don't know where to draw the line on this patch), there are other
> oddities in the dt_cg_load_var() TLS code, even if not strictly speaking
> correctness issues.  E.g.,
> 
> *)  The TLS code path always allocates the lbl_done and lbl_notnull labels
> even though only !DT_NF_REF uses them.

Fixed in a follow-up patch that will be posted soon (was still testing another
cleanup in that area).

> *)  The TLS !DT_NF_REF code path also has
>                         emitl(dlp, lbl_notnull,
>                                    BPF_MOV_REG(dst->dn_reg, BPF_REG_0));
>                         dt_regset_free(drp, BPF_REG_0);
>                         emit(dlp, BPF_LOAD(ldstw[size], dst->dn_reg,
> dst->dn_reg, 0));
> Couldn't one just say
>                         emitl(dlp, lbl_notnull,
>                                    BPF_LOAD(ldstw[size], dst->dn_reg,
> BPF_REG_0, 0));
>                         dt_regset_free(drp, BPF_REG_0);

Yes, good idea.  I'll integrate that in my follow-up patch since it is in the
same code fragment.

> I can throw these into a different patch if you like.
> 
> On 12/11/21 12:55 AM, Kris Van Hees via DTrace-devel wrote:
> > The dt_cg_load_var() function was not properly freeing the %r0 register
> > for by-ref loads.  This caused a spill/fill pair to be generated for the
> > dt_cg_check_notnull() invocation.
> > 
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   libdtrace/dt_cg.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> > index 46aaba65..296fcd42 100644
> > --- a/libdtrace/dt_cg.c
> > +++ b/libdtrace/dt_cg.c
> > @@ -2086,6 +2086,7 @@ dt_cg_load_var(dt_node_t *dst, dt_irlist_t *dlp, dt_regset_t *drp)
> >   		if (dst->dn_flags & DT_NF_REF) {
> >   			emit(dlp,  BPF_MOV_REG(dst->dn_reg, BPF_REG_0));
> > +			dt_regset_free(drp, BPF_REG_0);
> >   			dt_cg_check_notnull(dlp, drp, dst->dn_reg);
> >   		} else {
> >   			size_t	size = dt_node_type_size(dst);
> 
> _______________________________________________
> 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