Skip to content

Commit 1fb3a8b

Browse files
committed
xen/spinlock: Fix locking path engaging too soon under PVHVM.
The xen_lock_spinning has a check for the kicker interrupts and if it is not initialized it will spin normally (not enter the slowpath). But for PVHVM case we would initialize the kicker interrupt before the CPU came online. This meant that if the booting CPU used a spinlock and went in the slowpath - it would enter the slowpath and block forever. The forever part because during bootup: the spinlock would be taken _before_ the CPU sets itself to be online (more on this further), and we enter to poll on the event channel forever. The bootup CPU (see commit fc78d34 "xen/smp: initialize IPI vectors before marking CPU online" for details) and the CPU that started the bootup consult the cpu_online_mask to determine whether the booting CPU should get an IPI. The booting CPU has to set itself in this mask via: set_cpu_online(smp_processor_id(), true); However, if the spinlock is taken before this (and it is) and it polls on an event channel - it will never be woken up as the kernel will never send an IPI to an offline CPU. Note that the PVHVM logic in sending IPIs is using the HVM path which has numerous checks using the cpu_online_mask and cpu_active_mask. See above mention git commit for details. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: David Vrabel <david.vrabel@citrix.com>
1 parent 65320fc commit 1fb3a8b

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

arch/x86/xen/enlighten.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,6 @@ static int xen_hvm_cpu_notify(struct notifier_block *self, unsigned long action,
16921692
case CPU_UP_PREPARE:
16931693
xen_vcpu_setup(cpu);
16941694
if (xen_have_vector_callback) {
1695-
xen_init_lock_cpu(cpu);
16961695
if (xen_feature(XENFEAT_hvm_safe_pvclock))
16971696
xen_setup_timer(cpu);
16981697
}

arch/x86/xen/smp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,15 @@ static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
709709
WARN_ON(rc);
710710
if (!rc)
711711
rc = native_cpu_up(cpu, tidle);
712+
713+
/*
714+
* We must initialize the slowpath CPU kicker _after_ the native
715+
* path has executed. If we initialized it before none of the
716+
* unlocker IPI kicks would reach the booting CPU as the booting
717+
* CPU had not set itself 'online' in cpu_online_mask. That mask
718+
* is checked when IPIs are sent (on HVM at least).
719+
*/
720+
xen_init_lock_cpu(cpu);
712721
return rc;
713722
}
714723

0 commit comments

Comments
 (0)