linux-stable/arch
Sean Christopherson a955cad84c KVM: x86/mmu: Retry page fault if root is invalidated by memslot update
Bail from the page fault handler if the root shadow page was obsoleted by
a memslot update.  Do the check _after_ acuiring mmu_lock, as the TDP MMU
doesn't rely on the memslot/MMU generation, and instead relies on the
root being explicit marked invalid by kvm_mmu_zap_all_fast(), which takes
mmu_lock for write.

For the TDP MMU, inserting a SPTE into an obsolete root can leak a SP if
kvm_tdp_mmu_zap_invalidated_roots() has already zapped the SP, i.e. has
moved past the gfn associated with the SP.

For other MMUs, the resulting behavior is far more convoluted, though
unlikely to be truly problematic.  Installing SPs/SPTEs into the obsolete
root isn't directly problematic, as the obsolete root will be unloaded
and dropped before the vCPU re-enters the guest.  But because the legacy
MMU tracks shadow pages by their role, any SP created by the fault can
can be reused in the new post-reload root.  Again, that _shouldn't_ be
problematic as any leaf child SPTEs will be created for the current/valid
memslot generation, and kvm_mmu_get_page() will not reuse child SPs from
the old generation as they will be flagged as obsolete.  But, given that
continuing with the fault is pointess (the root will be unloaded), apply
the check to all MMUs.

Fixes: b7cccd397f ("KVM: x86/mmu: Fast invalidation for TDP MMU")
Cc: stable@vger.kernel.org
Cc: Ben Gardon <bgardon@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211120045046.3940942-5-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-12-02 04:12:12 -05:00
..
alpha Merge branch 'akpm' (patches from Andrew) 2021-11-09 10:11:53 -08:00
arc Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2021-11-10 16:15:54 -08:00
arm kmap_local: don't assume kmap PTEs are linear arrays in memory 2021-11-20 10:35:54 -08:00
arm64 KVM/arm64 fixes for 5.16, take #2 2021-11-26 05:42:56 -05:00
csky asm-generic: asm/syscall.h cleanup 2021-11-10 11:22:03 -08:00
h8300 Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
hexagon hexagon: ignore vmlinux.lds 2021-11-20 10:35:54 -08:00
ia64 asm-generic: asm/syscall.h cleanup 2021-11-10 11:22:03 -08:00
m68k signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-19 09:15:58 -06:00
microblaze asm-generic: asm/syscall.h cleanup 2021-11-10 11:22:03 -08:00
mips Selftest changes: 2021-11-18 12:05:22 -08:00
nds32 Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2021-11-10 16:15:54 -08:00
nios2 asm-generic: asm/syscall.h cleanup 2021-11-10 11:22:03 -08:00
openrisc Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2021-11-10 16:15:54 -08:00
parisc parisc: Enable CONFIG_PRINTK_TIME=y in 32bit defconfig 2021-11-18 09:02:32 +01:00
powerpc powerpc fixes for 5.16 #2 2021-11-21 10:26:35 -08:00
riscv RISC-V: KVM: Fix incorrect KVM_MAX_VCPUS value 2021-11-22 10:36:19 +05:30
s390 s390 updates for 5.16-rc2 2021-11-20 10:55:50 -08:00
sh arch/sh updates for 5.16 2021-11-14 11:37:49 -08:00
sparc signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-19 09:15:58 -06:00
um Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2021-11-10 16:15:54 -08:00
x86 KVM: x86/mmu: Retry page fault if root is invalidated by memslot update 2021-12-02 04:12:12 -05:00
xtensa Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2021-11-10 16:15:54 -08:00
.gitignore
Kconfig Tracing updates for 5.16: 2021-11-01 20:05:19 -07:00