linux-stable/arch/x86
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
..
boot - Do not #GP on userspace use of CLI/STI but pretend it was a NOP to 2021-11-02 07:56:47 -07:00
configs configs: remove the obsolete CONFIG_INPUT_POLLDEV 2021-09-08 11:50:28 -07:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2021-11-01 21:24:02 -07:00
entry signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-19 09:15:58 -06:00
events x86/perf: Fix snapshot_branch_stack warning in VM 2021-11-17 14:48:43 +01:00
hyperv x86/hyperv: Move required MSRs check to initial platform probing 2021-11-15 12:37:08 +00:00
ia32 audit/stable-5.16 PR 20211101 2021-11-01 21:17:39 -07:00
include KVM: ensure APICv is considered inactive if there is no APIC 2021-12-02 04:12:11 -05:00
kernel Two X86 fixes: 2021-11-21 11:25:19 -08:00
kvm KVM: x86/mmu: Retry page fault if root is invalidated by memslot update 2021-12-02 04:12:12 -05:00
lib - Do not #GP on userspace use of CLI/STI but pretend it was a NOP to 2021-11-02 07:56:47 -07:00
math-emu x86/math-emu: Convert to fpstate 2021-10-20 23:57:54 +02:00
mm Merge branch 'kvm-guest-sev-migration' into kvm-master 2021-11-11 07:40:26 -05:00
net Core: 2021-11-02 06:20:58 -07:00
pci xen: branch for v5.16-rc1 2021-11-10 11:14:21 -08:00
platform Add an interface called cc_platform_has() which is supposed to be used 2021-11-01 15:16:52 -07:00
power x86/fpu: Replace the includes of fpu/internal.h 2021-10-20 15:27:29 +02:00
purgatory kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
ras
realmode x86/sev: Replace occurrences of sev_es_active() with cc_platform_has() 2021-10-04 11:47:09 +02:00
tools Driver core changes for 5.16-rc1 2021-11-04 08:32:38 -07:00
um um: fix stub location calculation 2021-08-26 22:28:03 +02:00
video
xen x86/smp: Factor out parts of native_smp_prepare_cpus() 2021-11-11 13:09:32 +01:00
.gitignore
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig ftrace/samples: add missing Kconfig option for ftrace direct multi sample 2021-11-18 17:50:54 +01:00
Kconfig.assembler
Kconfig.cpu x86/CPU: Add support for Vortex CPUs 2021-10-21 15:49:07 +02:00
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
Makefile.um
Makefile_32.cpu x86/build: Do not add -falign flags unconditionally for clang 2021-09-19 10:35:53 +09:00