From b54b825e6fa1dbcfa9ea9de5e285441dd6649989 Mon Sep 17 00:00:00 2001 From: Oleksii Kurochko Date: Mon, 2 Jun 2025 12:41:36 +0200 Subject: [PATCH] xen/riscv: introduce smp_prepare_boot_cpu() Initialize cpu_{possible, online}_map by using smp_prepare_boot_cpu(). Drop DEFINE_PER_CPU(unsigned int, cpu_id) from stubs.c as this variable isn't expected to be used in RISC-V at all. Move declaration of cpu_{possible,online}_map from stubs.c to smpboot.c as now smpboot.c is now introduced. Other defintions keep in stubs.c as they are not initialized and not needed, at the moment. Drop cpu_present_map as it is enough to have cpu_possible_map. Also, ask linker to provide symbol for cpu_present_map as common code references it. Move call of set_processor_id(0) to smp_prepare_boot_cpu(). Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/setup.c | 4 ++-- xen/arch/riscv/smpboot.c | 16 ++++++++++++++++ xen/arch/riscv/stubs.c | 6 ------ xen/arch/riscv/xen.lds.S | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 xen/arch/riscv/smpboot.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index d882c57528..f42cf3dfa6 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -10,6 +10,7 @@ obj-y += sbi.o obj-y += setup.o obj-y += shutdown.o obj-y += smp.o +obj-y += smpboot.o obj-y += stubs.o obj-y += time.o obj-y += traps.o diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 4e416f6e44..a9c0c61fb6 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -19,7 +20,6 @@ #include #include #include -#include #include /* Xen stack for bringing up the first CPU. */ @@ -72,7 +72,7 @@ void __init noreturn start_xen(unsigned long bootcpu_id, remove_identity_mapping(); - set_processor_id(0); + smp_prepare_boot_cpu(); set_cpuid_to_hartid(0, bootcpu_id); diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c new file mode 100644 index 0000000000..0f9c2cc54a --- /dev/null +++ b/xen/arch/riscv/smpboot.c @@ -0,0 +1,16 @@ +#include +#include +#include + +#include + +cpumask_t __read_mostly cpu_online_map; +cpumask_t __ro_after_init cpu_possible_map; + +void __init smp_prepare_boot_cpu(void) +{ + set_processor_id(0); + + cpumask_set_cpu(0, &cpu_possible_map); + cpumask_set_cpu(0, &cpu_online_map); +} diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index 83416d3350..fdcf91054e 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -11,12 +11,6 @@ /* smpboot.c */ -cpumask_t cpu_online_map; -cpumask_t cpu_present_map; -cpumask_t cpu_possible_map; - -/* ID of the PCPU we're running on */ -DEFINE_PER_CPU(unsigned int, cpu_id); /* XXX these seem awfully x86ish... */ /* representing HT siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_mask); diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S index 818aa43669..8c3c06de01 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -165,6 +165,8 @@ SECTIONS ELF_DETAILS_SECTIONS } +PROVIDE(cpu_present_map = cpu_possible_map); + ASSERT(IS_ALIGNED(__bss_start, POINTER_ALIGN), "__bss_start is misaligned") ASSERT(IS_ALIGNED(__bss_end, POINTER_ALIGN), "__bss_end is misaligned")