Skip to content

Commit ed33527

Browse files
Lai Jiangshansean-jc
authored andcommitted
KVM: x86/mmu: Allow the roots to be invalid in FNAME(invlpg)
Don't assume the current root to be valid, just check it and remove the WARN(). Also move the code to check if the root is valid into FNAME(invlpg) to simplify the code. Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com> Link: https://lore.kernel.org/r/20230216235321.735214-2-jiangshanlai@gmail.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 2c86c44 commit ed33527

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5787,8 +5787,7 @@ void kvm_mmu_invalidate_addr(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
57875787
mmu->invlpg(vcpu, addr, mmu->root.hpa);
57885788

57895789
for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) {
5790-
if ((roots & KVM_MMU_ROOT_PREVIOUS(i)) &&
5791-
VALID_PAGE(mmu->prev_roots[i].hpa))
5790+
if (roots & KVM_MMU_ROOT_PREVIOUS(i))
57925791
mmu->invlpg(vcpu, addr, mmu->prev_roots[i].hpa);
57935792
}
57945793
}

arch/x86/kvm/mmu/paging_tmpl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,8 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, u64 addr, hpa_t root_hpa)
863863
*/
864864
mmu_topup_memory_caches(vcpu, true);
865865

866-
if (!VALID_PAGE(root_hpa)) {
867-
WARN_ON(1);
866+
if (!VALID_PAGE(root_hpa))
868867
return;
869-
}
870868

871869
write_lock(&vcpu->kvm->mmu_lock);
872870
for_each_shadow_entry_using_root(vcpu, root_hpa, addr, iterator) {

0 commit comments

Comments
 (0)