lib: sbi: Make per-HART stack size configurable via Kconfig

Oriol Catalan | OPENCHIP oriol.catalan at openchip.com
Tue May 19 01:58:45 PDT 2026


lib: sbi: Make per-HART stack size configurable via Kconfig

The per-HART stack size for exception/interrupt handling is currently
hardcoded to 8192 bytes in SBI_PLATFORM_DEFAULT_HART_STACK_SIZE. This
may not be sufficient for platforms with deeper call stacks (e.g., those
enabling additional SBI extensions) or may be wasteful for minimal
platforms.

Introduce a HART_STACK_SIZE Kconfig option in lib/sbi/Kconfig with a
valid range of 8192 to 1048576 bytes and a default of 8192 bytes to
preserve existing behavior. The SBI_PLATFORM_DEFAULT_HART_STACK_SIZE
macro now resolves to CONFIG_HART_STACK_SIZE, allowing all platforms
to benefit from a single configuration knob without any source changes.

Signed-off-by: Oriol Catalan <oriol.catalan at openchip.com>

diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index fe382b56..7ea9b961 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -160,7 +160,7 @@ struct sbi_platform_operations {
 };

 /** Platform default per-HART stack size for exception/interrupt handling */
-#define SBI_PLATFORM_DEFAULT_HART_STACK_SIZE   8192
+#define SBI_PLATFORM_DEFAULT_HART_STACK_SIZE   CONFIG_HART_STACK_SIZE

 /** Platform default heap size */
 #define SBI_PLATFORM_DEFAULT_HEAP_SIZE(__num_hart)     \
diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig
index c6cc04bc..2f6fa3a4 100644
--- a/lib/sbi/Kconfig
+++ b/lib/sbi/Kconfig
@@ -2,6 +2,11 @@

 menu "Generic SBI Support"

+config HART_STACK_SIZE
+       int "Per-HART stack size (bytes)"
+       range 8192 1048576
+       default 8192
+
 config CONSOLE_EARLY_BUFFER_SIZE
        int "Early console buffer size (bytes)"
        default 256


The content, data, and any attached documents to this email are addressed exclusively to the addressee and are confidential and/or may be subject to a non-disclosure agreement. Any use, forwarding, disclosure, and/or copying, in whole or in part, without authorization is prohibited. If you have received this email in error, we apologize and, please notify the sender or Openchip immediately, and delete it from your system.

El contenido, los datos y cualquier documento adjunto a este correo electrónico están dirigidos exclusivamente al destinatario y son confidenciales y/o pueden estar sujetas a un acuerdo de no revelación. Está prohibido cualquier uso, reenvío, divulgación o copia, total o parcial, sin autorización. Si has recibido este correo por error, te pedimos disculpas y agradecemos que lo notifiques de inmediato al remitente o a Openchip, y lo elimines de tu sistema.

El contingut, les dades i qualsevol document adjunt a aquest correu electrònic estan dirigits exclusivament al destinatari i són confidencials i/o poden estar subjectes a un acord de no revelació. Està prohibit qualsevol ús, reenviament, divulgació o còpia, total o parcial, sense autorització. Si has rebut aquest correu per error, et demanem disculpes i agraïm que ho notifiquis d'immediat al remitent o a Openchip, i l'eliminis del teu sistema



More information about the opensbi mailing list