mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00

In current implementation, the length of hartindex_to_context_table[] array is fixed as SBI_HARTMASK_MAX_BITS. However, the number of harts supported by the platform might not be SBI_HARTMASK_MAX_BITS and is usually smaller than SBI_HARTMASK_MAX_BITS. This means it is unnecessary to allocate such fixed-length array here. Precisely, current implementation always allocates 1024 bytes for hartindex_to_context_table[128] on RV64 platform. However, a platform supports two harts only needs hartindex_to_context_table[2], which only needs 16 bytes. This commit calculates needed size of hartindex_to_context_table[] according to supported number of harts on the platform when registering per-domain data, so that memory usage of per-domain context data can be reduced. Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250326062051.3763530-1-alvinga@andestech.com Signed-off-by: Anup Patel <anup@brainfault.org>