KVM: Move x86's MMU notifier memslot walkers to generic code
authorSean Christopherson <seanjc@google.com>
Fri, 2 Apr 2021 00:56:50 +0000 (17:56 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 17 Apr 2021 12:31:06 +0000 (08:31 -0400)
commit3039bcc744980afe87c612122e47a27306483bc2
tree2ebb8a15b5a2221d776dada8d9169e6da5dfdb18
parentc13fda237f08a388ba8a0849785045944bf39834
KVM: Move x86's MMU notifier memslot walkers to generic code

Move the hva->gfn lookup for MMU notifiers into common code.  Every arch
does a similar lookup, and some arch code is all but identical across
multiple architectures.

In addition to consolidating code, this will allow introducing
optimizations that will benefit all architectures without incurring
multiple walks of the memslots, e.g. by taking mmu_lock if and only if a
relevant range exists in the memslots.

The use of __always_inline to avoid indirect call retpolines, as done by
x86, may also benefit other architectures.

Consolidating the lookups also fixes a wart in x86, where the legacy MMU
and TDP MMU each do their own memslot walks.

Lastly, future enhancements to the memslot implementation, e.g. to add an
interval tree to track host address, will need to touch far less arch
specific code.

MIPS, PPC, and arm64 will be converted one at a time in future patches.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210402005658.3024832-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/tdp_mmu.c
arch/x86/kvm/mmu/tdp_mmu.h
include/linux/kvm_host.h
virt/kvm/kvm_main.c