Skip to content

Commit

Permalink
kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bonzini committed Nov 15, 2020
1 parent 96308b0 commit c887c9b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arch/x86/kvm/mmu/tdp_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ bool is_tdp_mmu_root(struct kvm *kvm, hpa_t hpa)
{
struct kvm_mmu_page *sp;

if (!kvm->arch.tdp_mmu_enabled)
return false;
if (WARN_ON(!VALID_PAGE(hpa)))
return false;

sp = to_shadow_page(hpa);
if (WARN_ON(!sp))
return false;

return sp->tdp_mmu_page && sp->root_count;
}
Expand Down

0 comments on commit c887c9b

Please sign in to comment.