Skip to content

Commit c887c9b

Browse files
committed
kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use
In some cases where shadow paging is in use, the root page will be either mmu->pae_root or vcpu->arch.mmu->lm_root. Then it will not have an associated struct kvm_mmu_page, because it is allocated with alloc_page instead of kvm_mmu_alloc_page. Just return false quickly from is_tdp_mmu_root if the TDP MMU is not in use, which also includes the case where shadow paging is enabled. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 96308b0 commit c887c9b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ bool is_tdp_mmu_root(struct kvm *kvm, hpa_t hpa)
4949
{
5050
struct kvm_mmu_page *sp;
5151

52+
if (!kvm->arch.tdp_mmu_enabled)
53+
return false;
54+
if (WARN_ON(!VALID_PAGE(hpa)))
55+
return false;
56+
5257
sp = to_shadow_page(hpa);
58+
if (WARN_ON(!sp))
59+
return false;
5360

5461
return sp->tdp_mmu_page && sp->root_count;
5562
}

0 commit comments

Comments
 (0)