Skip to contentSkip to conversation

lib: sbi: Add missing sscrind and sscfg extensions in sbi_hart_ext[]

PATCH New Clément Léger 3 participants 3 messages Mar 20, 2024 – Apr 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib: sbi: Add missing sscrind and sscfg extensions in sbi_hart_ext[]

The sbi_hart_ext[] array is missing these two extensions ids. It is expected that this array contains all the extensions declaration at the same index of the SBI_HART_EXT_* define. Without this, when adding a new extension, there is a mismatch between ids and extension names and it can even display corrupted extension names.

---

Changes in v2:
- Add _Static_assert() to check sbi_hart_ext[] array size

---
 lib/sbi/sbi_hart.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/sbi/sbi_hart.c +5 -0
index 3d13694..80efeaa 100644
@@ -666,8 +666,13 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
 	__SBI_HART_EXT_DATA(sdtrig, SBI_HART_EXT_SDTRIG),
 	__SBI_HART_EXT_DATA(smcsrind, SBI_HART_EXT_SMCSRIND),
 	__SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG),
+	__SBI_HART_EXT_DATA(sscsrind, SBI_HART_EXT_SSCSRIND),
+	__SBI_HART_EXT_DATA(ssccfg, SBI_HART_EXT_SSCCFG),
 };
 
+_Static_assert(array_size(sbi_hart_ext) == SBI_HART_EXT_MAX,
+	       "sbi_hart_ext[] array should contain all extensions ids");
+
 /**
  * Get the hart extensions in string format
  *
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/1 lib: sbi: Add missing sscrind and sscfg extensions in sbi_hart_ext[]

Quoted 23 lines · On Wed, Mar 20, 2024 at 8:45?AM Cl?ment L?ger <[email protected]> wrote:

The sbi_hart_ext[] array is missing these two extensions ids. It is expected that this array contains all the extensions declaration at the same index of the SBI_HART_EXT_* define. Without this, when adding a new extension, there is a mismatch between ids and extension names and it can even display corrupted extension names.

---

Changes in v2:
- Add _Static_assert() to check sbi_hart_ext[] array size

---
 lib/sbi/sbi_hart.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/sbi/sbi_hart.c +0 -0
index 3d13694..80efeaa 100644

lib/sbi/sbi_hart.c const struct sbi_hart_ext_data sbi_hart_ext[] = { · line 672

Quoted 7 lines
lib/sbi/sbi_hart.c +2 -0
@@ -666,8 +666,13 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
        __SBI_HART_EXT_DATA(sdtrig, SBI_HART_EXT_SDTRIG),
        __SBI_HART_EXT_DATA(smcsrind, SBI_HART_EXT_SMCSRIND),
        __SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG),
+       __SBI_HART_EXT_DATA(sscsrind, SBI_HART_EXT_SSCSRIND),
+       __SBI_HART_EXT_DATA(ssccfg, SBI_HART_EXT_SSCCFG),
 };
 

Good catch. I had this included in an earlier version of the patch. But I was in two minds whether to
add S-mode only extensions which M-mode doesn't control any states. I removed it here but forgot to remove it from the SBI_HART_EXT_* defines.

@Anup:
As a general rule, should we include these types of extensions? I just fear it may blow up in the future.

Quoted 14 lines
lib/sbi/sbi_hart.c +3 -1
+_Static_assert(array_size(sbi_hart_ext) == SBI_HART_EXT_MAX,
+              "sbi_hart_ext[] array should contain all extensions ids");
+
 /**
  * Get the hart extensions in string format
  *
--

2.43.0

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

Signature · 2 lines
Regards,
Atish
#2 lore raw

PATCH v2 1/1 lib: sbi: Add missing sscrind and sscfg extensions in sbi_hart_ext[]

In reply to Clément Léger
Quoted 24 lines · Cl?ment L?ger

The sbi_hart_ext[] array is missing these two extensions ids. It is expected that this array contains all the extensions declaration at the same index of the SBI_HART_EXT_* define. Without this, when adding a new extension, there is a mismatch between ids and extension names and it can even display corrupted extension names.

---

Changes in v2:
- Add _Static_assert() to check sbi_hart_ext[] array size

---
  lib/sbi/sbi_hart.c | 5 +++++
  1 file changed, 5 insertions(+)
lib/sbi/sbi_hart.c +0 -0
index 3d13694..80efeaa 100644
@@ -666,8 +666,13 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
  	__SBI_HART_EXT_DATA(sdtrig, SBI_HART_EXT_SDTRIG),
  	__SBI_HART_EXT_DATA(smcsrind, SBI_HART_EXT_SMCSRIND),
  	__SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG),

lib/sbi/sbi_hart.c const struct sbi_hart_ext_data sbi_hart_ext[] = { · line 678

Quoted 10 lines
lib/sbi/sbi_hart.c +5 -0
+	__SBI_HART_EXT_DATA(sscsrind, SBI_HART_EXT_SSCSRIND),
+	__SBI_HART_EXT_DATA(ssccfg, SBI_HART_EXT_SSCCFG),
  };
 
+_Static_assert(array_size(sbi_hart_ext) == SBI_HART_EXT_MAX,
+	       "sbi_hart_ext[] array should contain all extensions ids");
+
  /**
   * Get the hart extensions in string format
   *