[PATCH v2 0/3] KVM: nSVM: fix #TF from CR3 switch when entering guest

From: Vitaly Kuznetsov
Date: Wed Jul 08 2020 - 05:36:22 EST


This is a succesor of "[PATCH] KVM: x86: drop erroneous mmu_check_root()
from fast_pgd_switch()".

Undesired triple fault gets injected to L1 guest on SVM when L2 is
launched with certain CR3 values. #TF is raised by mmu_check_root()
check in fast_pgd_switch() and the root cause is that when
kvm_set_cr3() is called from nested_prepare_vmcb_save() with NPT
enabled CR3 points to a nGPA so we can't check it with
kvm_is_visible_gfn().

Fix the issue by moving kvm_mmu_new_pgd() to the right place when switching
to nested guest and drop the unneeded mmu_check_root() check from
fast_pgd_switch().

Vitaly Kuznetsov (3):
KVM: nSVM: split kvm_init_shadow_npt_mmu() from kvm_init_shadow_mmu()
KVM: nSVM: properly call kvm_mmu_new_pgd() upon switching to guest
KVM: x86: drop superfluous mmu_check_root() from fast_pgd_switch()

arch/x86/include/asm/kvm_host.h | 7 ++++++-
arch/x86/kvm/mmu.h | 3 ++-
arch/x86/kvm/mmu/mmu.c | 36 ++++++++++++++++++++++++---------
arch/x86/kvm/svm/nested.c | 5 +++--
arch/x86/kvm/x86.c | 8 +++++---
5 files changed, 43 insertions(+), 16 deletions(-)

--
2.25.4