]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86/mmu: Reconstruct shadow page root if the guest PDPTEs is changed
authorLai Jiangshan <laijs@linux.alibaba.com>
Thu, 16 Dec 2021 02:19:37 +0000 (10:19 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Jan 2022 15:44:40 +0000 (10:44 -0500)
commit011751a15fd63ed7775bf94737a17dbed02a0a7b
tree80a6e9ea2343152757364d93edc09b46f6a2fd57
parentc82796df27a5aea057d20e4a878cc4a122a22e16
KVM: x86/mmu: Reconstruct shadow page root if the guest PDPTEs is changed

For shadow paging, the page table needs to be reconstructed before the
coming VMENTER if the guest PDPTEs is changed.

But not all paths that call load_pdptrs() will cause the page tables to be
reconstructed. Normally, kvm_mmu_reset_context() and kvm_mmu_free_roots()
are used to launch later reconstruction.

The commit 22ab2e6b66fd("KVM: x86: do not reset mmu if CR0.CD and
CR0.NW are changed") skips kvm_mmu_reset_context() after load_pdptrs()
when changing CR0.CD and CR0.NW.

The commit 6d53f7590773("KVM: x86: Invalidate all PGDs for the current
PCID on MOV CR3 w/ flush") skips kvm_mmu_free_roots() after
load_pdptrs() when rewriting the CR3 with the same value.

The commit c56815a0d51b("KVM: X86: Don't reset mmu context when
toggling X86_CR4_PGE") skips kvm_mmu_reset_context() after
load_pdptrs() when changing CR4.PGE.

Guests like linux would keep the PDPTEs unchanged for every instance of
pagetable, so this missing reconstruction has no problem for linux
guests.

Fixes: 22ab2e6b66fd("KVM: x86: do not reset mmu if CR0.CD and CR0.NW are changed")
Fixes: 6d53f7590773("KVM: x86: Invalidate all PGDs for the current PCID on MOV CR3 w/ flush")
Fixes: c56815a0d51b("KVM: X86: Don't reset mmu context when toggling X86_CR4_PGE")
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Message-Id: <20211216021938.11752-3-jiangshanlai@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c