From d936372eab7f2cdd93d21f67d2381914589d9dd9 Mon Sep 17 00:00:00 2001 From: Oriol Catalan Date: Tue, 16 Jun 2026 19:09:33 +0530 Subject: [PATCH] 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 Reviewed-by: Anup Patel Link: https://lore.kernel.org/r/VI0P192MB3062735A6194BB6DA72083499E002@VI0P192MB3062.EURP192.PROD.OUTLOOK.COM Signed-off-by: Anup Patel --- include/sbi/sbi_platform.h | 2 +- lib/sbi/Kconfig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 5cbc1bc3..1e9a23c1 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -164,7 +164,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_DEFAULT_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 89245a25..e76aecca 100644 --- a/lib/sbi/Kconfig +++ b/lib/sbi/Kconfig @@ -2,6 +2,11 @@ menu "Generic SBI Support" +config DEFAULT_HART_STACK_SIZE + int "Default per-HART stack size (bytes)" + range 8192 1048576 + default 8192 + config CONSOLE_EARLY_BUFFER_SIZE int "Early console buffer size (bytes)" default 256