[PATCH] riscv: smp: set CPU 0 possible in setup_smp()
From: Paul Sherman
Date: Sat May 30 2026 - 05:49:56 EST
setup_smp() calls set_cpu_possible() for CPUs 1..nr_cpu_ids-1 but
never for CPU 0 (the boot CPU). x86 handles this via
init_cpu_possible(cpumask_of(0)); RISC-V has no equivalent.
Without CPU 0 in cpu_possible_mask, rcu_init_one()'s
for_each_possible_cpu() loop skips it, leaving rdp->mynode=NULL.
rcutree_prepare_cpu() then dereferences NULL and hangs.
Exposed on Sophgo SG2042 (64-hart, 4-NUMA) with Linux 7.0-rc2.
Fixes: a4166aec1130 ("riscv: Deduplicate code in setup_smp()")
Signed-off-by: Paul Sherman <shermanpauldylan@xxxxxxxxx>
---
arch/riscv/kernel/smpboot.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 601a321e0f17..71662f6bb1db 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -169,6 +169,15 @@ void __init setup_smp(void)
for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++)
if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
set_cpu_possible(cpuid, true);
+
+ /*
+ * Boot CPU (cpuid=0) is never set possible by the loop above.
+ * x86 and arm64 call init_cpu_possible(cpumask_of(0)) explicitly;
+ * RISC-V was missing this. Without it, rcu_init_one()'s
+ * for_each_possible_cpu loop skips CPU 0, leaving rdp->mynode=NULL,
+ * causing rcutree_prepare_cpu() to dereference NULL and hang.
+ */
+ set_cpu_possible(0, true);
}
static int start_secondary_cpu(int cpu, struct task_struct *tidle)
--
2.53.0