KVM: PPC: Book3S HV: Take the SRCU read lock before looking up memslots
authorPaul Mackerras <paulus@samba.org>
Tue, 11 Sep 2012 13:27:01 +0000 (13:27 +0000)
committerAlexander Graf <agraf@suse.de>
Fri, 5 Oct 2012 21:38:51 +0000 (23:38 +0200)
commit2c9097e4c1340208ef93371abd4b3bd7e989381b
tree941f326bf93ad74e208a26d8d9942b5026e00643
parentd61966fc08b84857b697ebae4489c652dd87e48a
KVM: PPC: Book3S HV: Take the SRCU read lock before looking up memslots

The generic KVM code uses SRCU (sleeping RCU) to protect accesses
to the memslots data structures against updates due to userspace
adding, modifying or removing memory slots.  We need to do that too,
both to avoid accessing stale copies of the memslots and to avoid
lockdep warnings.  This therefore adds srcu_read_lock/unlock pairs
around code that accesses and uses memslots.

Since the real-mode handlers for H_ENTER, H_REMOVE and H_BULK_REMOVE
need to access the memslots, and we don't want to call the SRCU code
in real mode (since we have no assurance that it would only access
the linear mapping), we hold the SRCU read lock for the VM while
in the guest.  This does mean that adding or removing memory slots
while some vcpus are executing in the guest will block for up to
two jiffies.  This tradeoff is acceptable since adding/removing
memory slots only happens rarely, while H_ENTER/H_REMOVE/H_BULK_REMOVE
are performance-critical hot paths.

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