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

Eugene Loh eugene.loh at oracle.com
Mon Dec 13 00:58:41 UTC 2021


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

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.

*)  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);

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);



More information about the DTrace-devel mailing list