Skip to content

Commit 762b33e

Browse files
Like Xusean-jc
authored andcommitted
KVM: x86/mmu: Assert on @mmu in the __kvm_mmu_invalidate_addr()
Add assertion to track that "mmu == vcpu->arch.mmu" is always true in the context of __kvm_mmu_invalidate_addr(). for_each_shadow_entry_using_root() and kvm_sync_spte() operate on vcpu->arch.mmu, but the only reason that doesn't cause explosions is because handle_invept() frees roots instead of doing a manual invalidation. As of now, there are no major roadblocks to switching INVEPT emulation over to use kvm_mmu_invalidate_addr(). Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Like Xu <likexu@tencent.com> Link: https://lore.kernel.org/r/20230523032947.60041-1-likexu@tencent.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 12ced09 commit 762b33e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5797,6 +5797,14 @@ static void __kvm_mmu_invalidate_addr(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu
57975797

57985798
vcpu_clear_mmio_info(vcpu, addr);
57995799

5800+
/*
5801+
* Walking and synchronizing SPTEs both assume they are operating in
5802+
* the context of the current MMU, and would need to be reworked if
5803+
* this is ever used to sync the guest_mmu, e.g. to emulate INVEPT.
5804+
*/
5805+
if (WARN_ON_ONCE(mmu != vcpu->arch.mmu))
5806+
return;
5807+
58005808
if (!VALID_PAGE(root_hpa))
58015809
return;
58025810

0 commit comments

Comments
 (0)