Skip to content

Commit 965e05f

Browse files
committed
x86/apic: Fake primary thread mask for XEN/PV
The SMT control mechanism got added as speculation attack vector mitigation. The implemented logic relies on the primary thread mask to be set up properly. This turns out to be an issue with XEN/PV guests because their CPU hotplug mechanics do not enumerate APICs and therefore the mask is never correctly populated. This went unnoticed so far because by chance XEN/PV ends up with smp_num_siblings == 2. So cpu_smt_control stays at its default value CPU_SMT_ENABLED and the primary thread mask is never evaluated in the context of CPU hotplug. This stopped "working" with the upcoming overhaul of the topology evaluation which legitimately provides a fake topology for XEN/PV. That sets smp_num_siblings to 1, which causes the core CPU hot-plug core to refuse to bring up the APs. This happens because cpu_smt_control is set to CPU_SMT_NOT_SUPPORTED which causes cpu_bootable() to evaluate the unpopulated primary thread mask with the conclusion that all non-boot CPUs are not valid to be plugged. The core code has already been made more robust against this kind of fail, but the primary thread mask really wants to be populated to avoid other issues all over the place. Just fake the mask by pretending that all XEN/PV vCPUs are primary threads, which is consistent because all of XEN/PVs topology is fake or non-existent. Fixes: 6a4d265 ("x86/smp: Provide topology_is_primary_thread()") Fixes: f54d443 ("x86/apic: Provide cpu_primary_thread mask") Reported-by: Juergen Gross <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Juergen Gross <[email protected]> Tested-by: Sohil Mehta <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Zhang Rui <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d91bdd9 commit 965e05f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include <linux/smp.h>
3737
#include <linux/mm.h>
3838

39+
#include <xen/xen.h>
40+
3941
#include <asm/trace/irq_vectors.h>
4042
#include <asm/irq_remapping.h>
4143
#include <asm/pc-conf-reg.h>
@@ -2344,6 +2346,15 @@ static int __init smp_init_primary_thread_mask(void)
23442346
{
23452347
unsigned int cpu;
23462348

2349+
/*
2350+
* XEN/PV provides either none or useless topology information.
2351+
* Pretend that all vCPUs are primary threads.
2352+
*/
2353+
if (xen_pv_domain()) {
2354+
cpumask_copy(&__cpu_primary_thread_mask, cpu_possible_mask);
2355+
return 0;
2356+
}
2357+
23472358
for (cpu = 0; cpu < nr_logical_cpuids; cpu++)
23482359
cpu_mark_primary_thread(cpu, cpuid_to_apicid[cpu]);
23492360
return 0;

0 commit comments

Comments
 (0)