KVM: PPC: Book3s HV: Don't access runnable threads list without vcore lock
authorPaul Mackerras <paulus@samba.org>
Mon, 15 Oct 2012 01:16:48 +0000 (01:16 +0000)
committerAlexander Graf <agraf@suse.de>
Tue, 30 Oct 2012 09:54:55 +0000 (10:54 +0100)
commit913d3ff9a3c3a13c3115eb4b3265aa35a9e0a7ad
tree93e66d12f6b475919ecc567dce9fc81313138d98
parent7b444c6710c6c4994e31eb19216ce055836e65c4
KVM: PPC: Book3s HV: Don't access runnable threads list without vcore lock

There were a few places where we were traversing the list of runnable
threads in a virtual core, i.e. vc->runnable_threads, without holding
the vcore spinlock.  This extends the places where we hold the vcore
spinlock to cover everywhere that we traverse that list.

Since we possibly need to sleep inside kvmppc_book3s_hv_page_fault,
this moves the call of it from kvmppc_handle_exit out to
kvmppc_vcpu_run, where we don't hold the vcore lock.

In kvmppc_vcore_blocked, we don't actually need to check whether
all vcpus are ceded and don't have any pending exceptions, since the
caller has already done that.  The caller (kvmppc_run_vcpu) wasn't
actually checking for pending exceptions, so we add that.

The change of if to while in kvmppc_run_vcpu is to make sure that we
never call kvmppc_remove_runnable() when the vcore state is RUNNING or
EXITING.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/include/asm/kvm_asm.h
arch/powerpc/kvm/book3s_hv.c