* [PATCH 1/1] riscv: fix NR_CPUS range leaking 64-bit default onto 32-bit builds
@ 2026-10-07 4:52 Leo Yu-Chi Liang
2026-10-07 15:11 ` Paul Walmsley
0 siblings, 1 reply; 2+ messages in thread
From: Leo Yu-Chi Liang @ 2026-10-07 4:52 UTC (permalink / raw)
To: linux-riscv, pjw
Cc: palmer, aou, alex, wangruikang, linux-kernel, Leo Yu-Chi Liang
rv32_defconfig is built in two stages:
- the generic (64-bit-oriented) "defconfig" target runs first
and resolves a concrete NR_CPUS value using the 64BIT default.
- then 32-bit.config is merged on top via merge_config.sh,
which does not touch NR_CPUS.
The final "make olddefconfig" pass sees NR_CPUS=256 is still within
the "2 512" range therefore never recalculates it against the 32BIT
default of 32, silently keeping the leaked 64-bit-stage value.
The NR_CPUS-scaled regions (percpu areas, ...etc) of the resulting
CONFIG_NR_CPUS=256 on a 32-bit build bloats and does not fit in the
percpu/stack layout for rv32 and hangs early boot on QEMU's virt machine.
Fix this by explicitly specify the range for 32/64 and SBI_V01/!SBI_V01.
Fixes: 0fa749771993 ("riscv: Raise default NR_CPUS for 64BIT to 256")
Signed-off-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
---
arch/riscv/Kconfig | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index d6c2dbf8455..5874ca30f4f 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -453,9 +453,10 @@ config SMP
config NR_CPUS
int "Maximum number of CPUs (2-512)"
depends on SMP
- range 2 512 if !RISCV_SBI_V01
- range 2 32 if RISCV_SBI_V01 && 32BIT
+ range 2 512 if !RISCV_SBI_V01 && 64BIT
+ range 2 128 if !RISCV_SBI_V01 && 32BIT
range 2 64 if RISCV_SBI_V01 && 64BIT
+ range 2 32 if RISCV_SBI_V01 && 32BIT
default "32" if 32BIT
default "64" if RISCV_SBI_V01 && 64BIT
default "256" if !RISCV_SBI_V01 && 64BIT
--
2.43.7
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] riscv: fix NR_CPUS range leaking 64-bit default onto 32-bit builds
2026-10-07 4:52 [PATCH 1/1] riscv: fix NR_CPUS range leaking 64-bit default onto 32-bit builds Leo Yu-Chi Liang
@ 2026-10-07 15:11 ` Paul Walmsley
0 siblings, 0 replies; 2+ messages in thread
From: Paul Walmsley @ 2026-10-07 15:11 UTC (permalink / raw)
To: Leo Yu-Chi Liang
Cc: linux-riscv, pjw, palmer, aou, alex, wangruikang, linux-kernel
On Tue, 6 Oct 2026, Leo Yu-Chi Liang wrote:
> rv32_defconfig is built in two stages:
>
> - the generic (64-bit-oriented) "defconfig" target runs first
> and resolves a concrete NR_CPUS value using the 64BIT default.
> - then 32-bit.config is merged on top via merge_config.sh,
> which does not touch NR_CPUS.
>
> The final "make olddefconfig" pass sees NR_CPUS=256 is still within
> the "2 512" range therefore never recalculates it against the 32BIT
> default of 32, silently keeping the leaked 64-bit-stage value.
>
> The NR_CPUS-scaled regions (percpu areas, ...etc) of the resulting
> CONFIG_NR_CPUS=256 on a 32-bit build bloats and does not fit in the
> percpu/stack layout for rv32 and hangs early boot on QEMU's virt machine.
>
> Fix this by explicitly specify the range for 32/64 and SBI_V01/!SBI_V01.
>
> Fixes: 0fa749771993 ("riscv: Raise default NR_CPUS for 64BIT to 256")
> Signed-off-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
Thanks, queued for v7.3-rc.
- Paul
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-07 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07 4:52 [PATCH 1/1] riscv: fix NR_CPUS range leaking 64-bit default onto 32-bit builds Leo Yu-Chi Liang
2026-10-07 15:11 ` Paul Walmsley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®