]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: x86/mmu: load new PGD after the shadow MMU is initialized
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 4 Feb 2022 09:12:31 +0000 (04:12 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 21 Feb 2022 14:34:33 +0000 (09:34 -0500)
commita5ad3cc514e1741c7101e96fa5b741cb8dd4017e
tree9cbc2dfcbbbbdf279295612e3e2fe367de7b94ae
parent231e492a25549c7ac46deb0f4f7c9bc44f89390d
KVM: x86/mmu: load new PGD after the shadow MMU is initialized

Now that __kvm_mmu_new_pgd does not look at the MMU's root_level and
shadow_root_level anymore, pull the PGD load after the initialization of
the shadow MMUs.

Besides being more intuitive, this enables future simplifications
and optimizations because it's not necessary anymore to compute the
role outside kvm_init_mmu.  In particular, kvm_mmu_reset_context was not
attempting to use a cached PGD to avoid having to figure out the new role.
With this change, it could follow what nested_{vmx,svm}_load_cr3 are doing,
and avoid unloading all the cached roots.

Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/svm/nested.c
arch/x86/kvm/vmx/nested.c