All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: sbi: dbtr: Fix shared memory layout
@ 2025-05-27 18:27 Jesse Taube
  2025-05-28  3:15 ` Charlie Jenkins
  2025-06-04  3:35 ` Himanshu Chauhan
  0 siblings, 2 replies; 5+ messages in thread
From: Jesse Taube @ 2025-05-27 18:27 UTC (permalink / raw)
  To: opensbi; +Cc: Himanshu Chauhan, Anup Patel, Charlie Jenkins, Jesse Taube

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@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 {
+		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


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib: sbi: dbtr: Fix shared memory layout
  2025-05-27 18:27 [PATCH] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
@ 2025-05-28  3:15 ` Charlie Jenkins
  2025-05-28  4:17   ` Himanshu Chauhan
  2025-06-04  3:35 ` Himanshu Chauhan
  1 sibling, 1 reply; 5+ messages in thread
From: Charlie Jenkins @ 2025-05-28  3:15 UTC (permalink / raw)
  To: Jesse Taube; +Cc: opensbi, Himanshu Chauhan, Anup Patel

On Tue, May 27, 2025 at 11:27:13AM -0700, Jesse Taube 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@rivosinc.com>

Thanks!

This will need to be reflected in the linux patch as well.

Tested-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>

[1] https://lore.kernel.org/all/20240222125059.13331-3-hchauhan@ventanamicro.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 {
> +		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
> 

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib: sbi: dbtr: Fix shared memory layout
  2025-05-28  3:15 ` Charlie Jenkins
@ 2025-05-28  4:17   ` Himanshu Chauhan
  0 siblings, 0 replies; 5+ messages in thread
From: Himanshu Chauhan @ 2025-05-28  4:17 UTC (permalink / raw)
  To: Charlie Jenkins; +Cc: Jesse Taube, opensbi, Anup Patel

Thanks! I will take care of that.

On Wed, May 28, 2025 at 8:45 AM Charlie Jenkins <charlie@rivosinc.com> wrote:
>
> On Tue, May 27, 2025 at 11:27:13AM -0700, Jesse Taube 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@rivosinc.com>
>
> Thanks!
>
> This will need to be reflected in the linux patch as well.
>
> Tested-by: Charlie Jenkins <charlie@rivosinc.com>
> Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
>
> [1] https://lore.kernel.org/all/20240222125059.13331-3-hchauhan@ventanamicro.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 {
> > +             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
> >

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib: sbi: dbtr: Fix shared memory layout
  2025-05-27 18:27 [PATCH] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
  2025-05-28  3:15 ` Charlie Jenkins
@ 2025-06-04  3:35 ` Himanshu Chauhan
  2025-06-04 13:37   ` Jesse Taube
  1 sibling, 1 reply; 5+ messages in thread
From: Himanshu Chauhan @ 2025-06-04  3:35 UTC (permalink / raw)
  To: Jesse Taube; +Cc: opensbi, Anup Patel, Charlie Jenkins



> On 27 May 2025, at 11:57 PM, Jesse Taube <jesse@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@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.

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
> 


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib: sbi: dbtr: Fix shared memory layout
  2025-06-04  3:35 ` Himanshu Chauhan
@ 2025-06-04 13:37   ` Jesse Taube
  0 siblings, 0 replies; 5+ messages in thread
From: Jesse Taube @ 2025-06-04 13:37 UTC (permalink / raw)
  To: Himanshu Chauhan; +Cc: opensbi, Anup Patel, Charlie Jenkins

On Tue, Jun 3, 2025 at 8:35 PM Himanshu Chauhan
<hchauhan@ventanamicro.com> wrote:
>
>
>
> > On 27 May 2025, at 11:57 PM, Jesse Taube <jesse@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@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
> >
>

-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-04 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 18:27 [PATCH] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
2025-05-28  3:15 ` Charlie Jenkins
2025-05-28  4:17   ` Himanshu Chauhan
2025-06-04  3:35 ` Himanshu Chauhan
2025-06-04 13:37   ` Jesse Taube

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.