]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: x86/xen: Maintain valid mapping of Xen shared_info page
authorDavid Woodhouse <dwmw@amazon.co.uk>
Sat, 30 Oct 2021 18:53:23 +0000 (19:53 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 1 Nov 2021 15:05:15 +0000 (15:05 +0000)
commitcebc2fd2e9d6ad98f464844d38a01873a10551cd
tree04f9e4014d9a6ae6ef36effa80a83fdf50abf889
parente900edcd087876d05fb70bf75f6af1971cab3027
KVM: x86/xen: Maintain valid mapping of Xen shared_info page

In order to allow for event channel delivery, we would like to have a
kernel mapping of the shared_info page which can be accessed in atomic
context in the common case.

The gfn_to_pfn_cache only automatically handles invalidation when the
KVM memslots change; it doesn't handle a change in the userspace HVA
to host PFN mappings. So hook into the MMU notifiers to invalidate the
shared_info pointer on demand.

The shared_info can be accessed while holding the shinfo_lock, with a
slow path which takes the kvm->lock mutex to refresh the mapping.
I'd like to use RCU for the invalidation but I don't think we can
always sleep in the invalidate_range notifier. Having a true kernel
mapping of the page means that our access to it can be atomic anyway,
so holding a spinlock is OK.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/xen.c
include/linux/kvm_host.h
include/linux/kvm_types.h