diff options
author | 2024-02-13 22:06:00 +0100 | |
---|---|---|
committer | 2024-02-15 22:07:44 +0100 | |
commit | c8f808231f1fb63553f90d4b3796cb6804d1e693 (patch) | |
tree | 93ea4ada541ca2fab34a9ef7af9b1a3adf8a6922 /arch/x86/xen/smp_pv.c | |
parent | x86/cpu/topology: Assign hotpluggable CPUIDs during init (diff) | |
download | wireguard-linux-c8f808231f1fb63553f90d4b3796cb6804d1e693.tar.xz wireguard-linux-c8f808231f1fb63553f90d4b3796cb6804d1e693.zip |
x86/xen/smp_pv: Count number of vCPUs early
XEN/PV has a completely broken vCPU enumeration scheme, which just works by
chance and provides zero topology information. Each vCPU ends up being a
single core package.
Dom0 provides MADT which can be used for topology information, but that
table is the unmodified host table, which means that there can be more CPUs
registered than the number of vCPUs XEN provides for the dom0 guest.
DomU does not have ACPI and both rely on counting the possible vCPUs via an
hypercall.
To prepare for using CPUID topology information either via MADT or via fake
APIC IDs count the number of possible CPUs during early boot and adjust
nr_cpu_ids() accordingly.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Link: https://lore.kernel.org/r/20240213210252.571795063@linutronix.de
Diffstat (limited to 'arch/x86/xen/smp_pv.c')
-rw-r--r-- | arch/x86/xen/smp_pv.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c index 98849b3f5eac..44706f01bb9b 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -411,6 +411,20 @@ static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +void __init xen_smp_count_cpus(void) +{ + unsigned int cpus; + + for (cpus = 0; cpus < nr_cpu_ids; cpus++) { + if (HYPERVISOR_vcpu_op(VCPUOP_is_up, cpus, NULL) < 0) + break; + } + + pr_info("Xen PV: Detected %u vCPUS\n", cpus); + if (cpus < nr_cpu_ids) + set_nr_cpu_ids(cpus); +} + static const struct smp_ops xen_smp_ops __initconst = { .smp_prepare_boot_cpu = xen_pv_smp_prepare_boot_cpu, .smp_prepare_cpus = xen_pv_smp_prepare_cpus, |