All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] lib: sbi: dbtr: Fix shared memory layout
@ 2025-06-04 13:52 Jesse Taube
  2025-06-05 10:28 ` Himanshu Chauhan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jesse Taube @ 2025-06-04 13:52 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.

Replace struct with 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>
---
V1 -> V2:
 - Remove anonymous union
 - Replace struct with union
 - Update commit description
---
 include/sbi/sbi_dbtr.h | 2 +-
 lib/sbi/sbi_dbtr.c     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/sbi/sbi_dbtr.h b/include/sbi/sbi_dbtr.h
index a8b3a02..9b87968 100644
--- a/include/sbi/sbi_dbtr.h
+++ b/include/sbi/sbi_dbtr.h
@@ -90,7 +90,7 @@ struct sbi_dbtr_hart_triggers_state {
 	}while (0);
 
 /** SBI shared mem messages layout */
-struct sbi_dbtr_shmem_entry {
+union sbi_dbtr_shmem_entry {
 	struct sbi_dbtr_data_msg data;
 	struct sbi_dbtr_id_msg id;
 };
diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
index f0e9128..cfb6b2a 100644
--- a/lib/sbi/sbi_dbtr.c
+++ b/lib/sbi/sbi_dbtr.c
@@ -506,7 +506,7 @@ int sbi_dbtr_read_trig(unsigned long smode,
 {
 	struct sbi_dbtr_data_msg *xmit;
 	struct sbi_dbtr_trigger *trig;
-	struct sbi_dbtr_shmem_entry *entry;
+	union sbi_dbtr_shmem_entry *entry;
 	void *shmem_base = NULL;
 	struct sbi_dbtr_hart_triggers_state *hs = NULL;
 
@@ -541,7 +541,7 @@ int sbi_dbtr_install_trig(unsigned long smode,
 			  unsigned long trig_count, unsigned long *out)
 {
 	void *shmem_base = NULL;
-	struct sbi_dbtr_shmem_entry *entry;
+	union sbi_dbtr_shmem_entry *entry;
 	struct sbi_dbtr_data_msg *recv;
 	struct sbi_dbtr_id_msg *xmit;
 	unsigned long ctrl;
@@ -659,7 +659,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
 	struct sbi_dbtr_data_msg *recv;
 	unsigned long uidx = 0;
 	struct sbi_dbtr_trigger *trig;
-	struct sbi_dbtr_shmem_entry *entry;
+	union sbi_dbtr_shmem_entry *entry;
 	void *shmem_base = NULL;
 	struct sbi_dbtr_hart_triggers_state *hs = NULL;
 
-- 
2.43.0


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

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

* Re: [PATCH v2] lib: sbi: dbtr: Fix shared memory layout
  2025-06-04 13:52 [PATCH v2] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
@ 2025-06-05 10:28 ` Himanshu Chauhan
  2025-06-05 18:12 ` Charlie Jenkins
  2025-06-16  4:45 ` Anup Patel
  2 siblings, 0 replies; 4+ messages in thread
From: Himanshu Chauhan @ 2025-06-05 10:28 UTC (permalink / raw)
  To: Jesse Taube; +Cc: opensbi, Anup Patel, Charlie Jenkins

On Wed, Jun 04, 2025 at 06:52:25AM -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.
> 
> Replace struct with 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>
> ---
> V1 -> V2:
>  - Remove anonymous union
>  - Replace struct with union
>  - Update commit description
> ---
>  include/sbi/sbi_dbtr.h | 2 +-
>  lib/sbi/sbi_dbtr.c     | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/sbi/sbi_dbtr.h b/include/sbi/sbi_dbtr.h
> index a8b3a02..9b87968 100644
> --- a/include/sbi/sbi_dbtr.h
> +++ b/include/sbi/sbi_dbtr.h
> @@ -90,7 +90,7 @@ struct sbi_dbtr_hart_triggers_state {
>  	}while (0);
>  
>  /** SBI shared mem messages layout */
> -struct sbi_dbtr_shmem_entry {
> +union sbi_dbtr_shmem_entry {
>  	struct sbi_dbtr_data_msg data;
>  	struct sbi_dbtr_id_msg id;
>  };
> diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
> index f0e9128..cfb6b2a 100644
> --- a/lib/sbi/sbi_dbtr.c
> +++ b/lib/sbi/sbi_dbtr.c
> @@ -506,7 +506,7 @@ int sbi_dbtr_read_trig(unsigned long smode,
>  {
>  	struct sbi_dbtr_data_msg *xmit;
>  	struct sbi_dbtr_trigger *trig;
> -	struct sbi_dbtr_shmem_entry *entry;
> +	union sbi_dbtr_shmem_entry *entry;
>  	void *shmem_base = NULL;
>  	struct sbi_dbtr_hart_triggers_state *hs = NULL;
>  
> @@ -541,7 +541,7 @@ int sbi_dbtr_install_trig(unsigned long smode,
>  			  unsigned long trig_count, unsigned long *out)
>  {
>  	void *shmem_base = NULL;
> -	struct sbi_dbtr_shmem_entry *entry;
> +	union sbi_dbtr_shmem_entry *entry;
>  	struct sbi_dbtr_data_msg *recv;
>  	struct sbi_dbtr_id_msg *xmit;
>  	unsigned long ctrl;
> @@ -659,7 +659,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
>  	struct sbi_dbtr_data_msg *recv;
>  	unsigned long uidx = 0;
>  	struct sbi_dbtr_trigger *trig;
> -	struct sbi_dbtr_shmem_entry *entry;
> +	union sbi_dbtr_shmem_entry *entry;
>  	void *shmem_base = NULL;
>  	struct sbi_dbtr_hart_triggers_state *hs = NULL;
>

Reviewed-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
Tested-by: Himanshu Chauhan <hchauhan@ventanamicro.com>

> -- 
> 2.43.0
> 

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

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

* Re: [PATCH v2] lib: sbi: dbtr: Fix shared memory layout
  2025-06-04 13:52 [PATCH v2] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
  2025-06-05 10:28 ` Himanshu Chauhan
@ 2025-06-05 18:12 ` Charlie Jenkins
  2025-06-16  4:45 ` Anup Patel
  2 siblings, 0 replies; 4+ messages in thread
From: Charlie Jenkins @ 2025-06-05 18:12 UTC (permalink / raw)
  To: Jesse Taube; +Cc: opensbi, Himanshu Chauhan, Anup Patel

On Wed, Jun 04, 2025 at 06:52:25AM -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.
> 
> Replace struct with 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>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Charlie Jenkins <charlie@rivosinc.com>

> ---
> V1 -> V2:
>  - Remove anonymous union
>  - Replace struct with union
>  - Update commit description
> ---
>  include/sbi/sbi_dbtr.h | 2 +-
>  lib/sbi/sbi_dbtr.c     | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/sbi/sbi_dbtr.h b/include/sbi/sbi_dbtr.h
> index a8b3a02..9b87968 100644
> --- a/include/sbi/sbi_dbtr.h
> +++ b/include/sbi/sbi_dbtr.h
> @@ -90,7 +90,7 @@ struct sbi_dbtr_hart_triggers_state {
>  	}while (0);
>  
>  /** SBI shared mem messages layout */
> -struct sbi_dbtr_shmem_entry {
> +union sbi_dbtr_shmem_entry {
>  	struct sbi_dbtr_data_msg data;
>  	struct sbi_dbtr_id_msg id;
>  };
> diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
> index f0e9128..cfb6b2a 100644
> --- a/lib/sbi/sbi_dbtr.c
> +++ b/lib/sbi/sbi_dbtr.c
> @@ -506,7 +506,7 @@ int sbi_dbtr_read_trig(unsigned long smode,
>  {
>  	struct sbi_dbtr_data_msg *xmit;
>  	struct sbi_dbtr_trigger *trig;
> -	struct sbi_dbtr_shmem_entry *entry;
> +	union sbi_dbtr_shmem_entry *entry;
>  	void *shmem_base = NULL;
>  	struct sbi_dbtr_hart_triggers_state *hs = NULL;
>  
> @@ -541,7 +541,7 @@ int sbi_dbtr_install_trig(unsigned long smode,
>  			  unsigned long trig_count, unsigned long *out)
>  {
>  	void *shmem_base = NULL;
> -	struct sbi_dbtr_shmem_entry *entry;
> +	union sbi_dbtr_shmem_entry *entry;
>  	struct sbi_dbtr_data_msg *recv;
>  	struct sbi_dbtr_id_msg *xmit;
>  	unsigned long ctrl;
> @@ -659,7 +659,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
>  	struct sbi_dbtr_data_msg *recv;
>  	unsigned long uidx = 0;
>  	struct sbi_dbtr_trigger *trig;
> -	struct sbi_dbtr_shmem_entry *entry;
> +	union sbi_dbtr_shmem_entry *entry;
>  	void *shmem_base = NULL;
>  	struct sbi_dbtr_hart_triggers_state *hs = NULL;
>  
> -- 
> 2.43.0
> 

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

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

* Re: [PATCH v2] lib: sbi: dbtr: Fix shared memory layout
  2025-06-04 13:52 [PATCH v2] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
  2025-06-05 10:28 ` Himanshu Chauhan
  2025-06-05 18:12 ` Charlie Jenkins
@ 2025-06-16  4:45 ` Anup Patel
  2 siblings, 0 replies; 4+ messages in thread
From: Anup Patel @ 2025-06-16  4:45 UTC (permalink / raw)
  To: Jesse Taube; +Cc: opensbi, Himanshu Chauhan, Charlie Jenkins

On Wed, Jun 4, 2025 at 7:22 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.
>
> Replace struct with 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>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
> V1 -> V2:
>  - Remove anonymous union
>  - Replace struct with union
>  - Update commit description
> ---
>  include/sbi/sbi_dbtr.h | 2 +-
>  lib/sbi/sbi_dbtr.c     | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/sbi/sbi_dbtr.h b/include/sbi/sbi_dbtr.h
> index a8b3a02..9b87968 100644
> --- a/include/sbi/sbi_dbtr.h
> +++ b/include/sbi/sbi_dbtr.h
> @@ -90,7 +90,7 @@ struct sbi_dbtr_hart_triggers_state {
>         }while (0);
>
>  /** SBI shared mem messages layout */
> -struct sbi_dbtr_shmem_entry {
> +union sbi_dbtr_shmem_entry {
>         struct sbi_dbtr_data_msg data;
>         struct sbi_dbtr_id_msg id;
>  };
> diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
> index f0e9128..cfb6b2a 100644
> --- a/lib/sbi/sbi_dbtr.c
> +++ b/lib/sbi/sbi_dbtr.c
> @@ -506,7 +506,7 @@ int sbi_dbtr_read_trig(unsigned long smode,
>  {
>         struct sbi_dbtr_data_msg *xmit;
>         struct sbi_dbtr_trigger *trig;
> -       struct sbi_dbtr_shmem_entry *entry;
> +       union sbi_dbtr_shmem_entry *entry;
>         void *shmem_base = NULL;
>         struct sbi_dbtr_hart_triggers_state *hs = NULL;
>
> @@ -541,7 +541,7 @@ int sbi_dbtr_install_trig(unsigned long smode,
>                           unsigned long trig_count, unsigned long *out)
>  {
>         void *shmem_base = NULL;
> -       struct sbi_dbtr_shmem_entry *entry;
> +       union sbi_dbtr_shmem_entry *entry;
>         struct sbi_dbtr_data_msg *recv;
>         struct sbi_dbtr_id_msg *xmit;
>         unsigned long ctrl;
> @@ -659,7 +659,7 @@ int sbi_dbtr_update_trig(unsigned long smode,
>         struct sbi_dbtr_data_msg *recv;
>         unsigned long uidx = 0;
>         struct sbi_dbtr_trigger *trig;
> -       struct sbi_dbtr_shmem_entry *entry;
> +       union sbi_dbtr_shmem_entry *entry;
>         void *shmem_base = NULL;
>         struct sbi_dbtr_hart_triggers_state *hs = NULL;
>
> --
> 2.43.0
>

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

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

end of thread, other threads:[~2025-06-16  6:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-04 13:52 [PATCH v2] lib: sbi: dbtr: Fix shared memory layout Jesse Taube
2025-06-05 10:28 ` Himanshu Chauhan
2025-06-05 18:12 ` Charlie Jenkins
2025-06-16  4:45 ` Anup Patel

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.