]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
KVM: PPC: Book3S HV: Fix race in starting secondary threads
authorGautham R. Shenoy <ego@linux.vnet.ibm.com>
Wed, 2 Sep 2015 16:18:58 +0000 (21:48 +0530)
committerPaul Mackerras <paulus@samba.org>
Thu, 3 Sep 2015 06:07:42 +0000 (16:07 +1000)
commit7f23532866f931be626e69ff55caf39e54516047
treeed81d64702e8c84f3744d9176a6d8b67188e062a
parente3dbc572fe11a5231568e106fa3dcedd1d1bec0f
KVM: PPC: Book3S HV: Fix race in starting secondary threads

The current dynamic micro-threading code has a race due to which a
secondary thread naps when it is supposed to be running a vcpu. As a
side effect of this, on a guest exit, the primary thread in
kvmppc_wait_for_nap() finds that this secondary thread hasn't cleared
its vcore pointer. This results in "CPU X seems to be stuck!"
warnings.

The race is possible since the primary thread on exiting the guests
only waits for all the secondaries to clear its vcore pointer. It
subsequently expects the secondary threads to enter nap while it
unsplits the core. A secondary thread which hasn't yet entered the nap
will loop in kvm_no_guest until its vcore pointer and the do_nap flag
are unset. Once the core has been unsplit, a new vcpu thread can grab
the core and set the do_nap flag *before* setting the vcore pointers
of the secondary. As a result, the secondary thread will now enter nap
via kvm_unsplit_nap instead of running the guest vcpu.

Fix this by setting the do_nap flag after setting the vcore pointer in
the PACA of the secondary in kvmppc_run_core. Also, ensure that a
secondary thread doesn't nap in kvm_unsplit_nap when the vcore pointer
in its PACA struct is set.

Fixes: b4deba5c41e9
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S