KVM: x86/mmu: Assert on @mmu in the __kvm_mmu_invalidate_addr()
PATCH v2 1/1 KVM: x86/mmu: Assert on @mmu in the __kvm_mmu_invalidate_addr()
From: Like Xu <[email protected]>
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().
---
V1 -> V2 Changelog:
- Better to assert on @mmu instead of deleting it. (Sean)
V1: https://lore.kernel.org/kvm/[email protected]/
arch/x86/kvm/mmu/mmu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/kvm/mmu/mmu.c +8 -0
@@ -5797,6 +5797,14 @@ static void __kvm_mmu_invalidate_addr(struct kvm_vcpu *vcpu, struct kvm_mmu *mmuvcpu_clear_mmio_info (vcpu, addr); +/* +* Walking and synchronizing SPTEs both assume they are operating in +* the context of the current MMU, and would need to be reworked if +* this is ever used to sync the guest_mmu, e.g. to emulate INVEPT. +*/ +if (WARN_ON_ONCE (mmu != vcpu->arch.mmu)) +return ; +if (!VALID_PAGE (root_hpa))return ;
base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
Signature · 1 line
2.40.1
Quoted 8 lines · Like Xu
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()andkvm_sync_spte()operate onvcpu->arch.mmu, but the only reason that doesn't cause explosions is becausehandle_invept()frees roots instead of doing a manual invalidation. As of now, there are no major roadblocks to switching INVEPT emulation over to usekvm_mmu_invalidate_addr().[...]
Applied to kvm-x86 mmu, thanks!
[1/1] KVM: x86/mmu: Assert on @mmu in the __kvm_mmu_invalidate_addr()
https://github.com/kvm-x86/linux/commit/762b33eb90c9
--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes