lib: sbi: Make per-HART stack size configurable via Kconfig
Anup Patel
anup at brainfault.org
Tue Jun 16 08:07:48 PDT 2026
Hi Oriol Catalan,
On Tue, May 19, 2026 at 2:29 PM Oriol Catalan | OPENCHIP
<oriol.catalan at openchip.com> wrote:
>
> lib: sbi: Make per-HART stack size configurable via Kconfig
No need to repeat the subject in patch description.
>
> 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
> +
I am not sure how you send this patch. It seems all tabs are converted
to spaces and I am unable to apply this patch. I will manually do the
changes at the time of merging.
Please use git format-patch for generating patches and use git send-email
to send patches to the OpenSBI mailing list.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
More information about the opensbi
mailing list