[PATCH] lib: sbi: dbtr: Fix shared memory layout

Jesse Taube jesse at rivosinc.com
Wed Jun 4 06:37:52 PDT 2025


On Tue, Jun 3, 2025 at 8:35 PM Himanshu Chauhan
<hchauhan at ventanamicro.com> wrote:
>
>
>
> > On 27 May 2025, at 11:57 PM, Jesse Taube <jesse at rivosinc.com> wrote:
> >
> > The existing sbi_dbtr_shmem_entry has a size of 5 * XLEN with the final
> > entry being idx. This is in contrast to the SBI v3.0-rc7 Chapter 19.
> > Debug Triggers Extension [0] where idx and trig_state share the same
> > offset (0) in shared memory, with a total size of 4 * XLEN for all the
> > SBI calls.
> >
> > Add union to match memory layout described in SBI.
> >
> > [0] https://github.com/riscv-non-isa/riscv-sbi-doc/tree/v3.0-rc7/src/ext-debug-triggers.adoc
> >
> > Fixes: 97f234f15c96 ("lib: sbi: Introduce the SBI debug triggers extension support")
> > Signed-off-by: Jesse Taube <jesse at rivosinc.com>
> > ---
> > include/sbi/sbi_dbtr.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/sbi/sbi_dbtr.h b/include/sbi/sbi_dbtr.h
> > index a8b3a02..8cb776c 100644
> > --- a/include/sbi/sbi_dbtr.h
> > +++ b/include/sbi/sbi_dbtr.h
> > @@ -91,8 +91,10 @@ struct sbi_dbtr_hart_triggers_state {
> >
> > /** SBI shared mem messages layout */
> > struct sbi_dbtr_shmem_entry {
> > - struct sbi_dbtr_data_msg data;
> > - struct sbi_dbtr_id_msg id;
> > + union {
>
> I think better to have just the union instead of union inside the structure since it is controlled by the SBI spec.

Agreed. I added an anonymous union as it was a 6 line change vs 50 lines.

Thanks,
Jesse Taube

>
> Regards
> Himanshu
>
>
> > + struct sbi_dbtr_data_msg data;
> > + struct sbi_dbtr_id_msg id;
> > + };
> > };
> >
> > #define SBI_DBTR_SHMEM_ALIGN_MASK ((__riscv_xlen / 8) - 1)
> > --
> > 2.43.0
> >
>



More information about the opensbi mailing list