]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: nSVM: fix switch to guest mmu
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 19 Dec 2018 16:25:14 +0000 (17:25 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 19 Dec 2018 21:19:22 +0000 (22:19 +0100)
commit1ca7f1cb1da982eb6753dfc017e686dc4eae1c64
treece8aae5b8f1bc9328af30fb3c8bb67e976dc49ac
parentf141a825a13a434b0b0a676143495b7472ea63a8
KVM: x86: nSVM: fix switch to guest mmu

Recent optimizations in MMU code broke nested SVM with NPT in L1
completely: when we do nested_svm_{,un}init_mmu_context() we want
to switch from TDP MMU to shadow MMU, both init_kvm_tdp_mmu() and
kvm_init_shadow_mmu() check if re-configuration is needed by looking
at cache source data. The data, however, doesn't change - it's only
the type of the MMU which changes. We end up not re-initializing
guest MMU as shadow and everything goes off the rails.

The issue could have been fixed by putting MMU type into extended MMU
role but this is not really needed. We can just split root and guest MMUs
the exact same way we did for nVMX, their types never change in the
lifetime of a vCPU.

There is still room for improvement: currently, we reset all MMU roots
when switching from L1 to L2 and back and this is not needed.

Fixes: 22e08c018391 ("x86/kvm/mmu: check if tdp/shadow MMU reconfiguration is needed")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm.c