Skip to content

Commit 339f5a7

Browse files
rpedgecobonzini
authored andcommitted
kvm: x86/mmu: Use cpuid to determine max gfn
In the TDP MMU, use shadow_phys_bits to dermine the maximum possible GFN mapped in the guest for zapping operations. boot_cpu_data.x86_phys_bits may be reduced in the case of HW features that steal HPA bits for other purposes. However, this doesn't necessarily reduce GPA space that can be accessed via TDP. So zap based on a maximum gfn calculated with MAXPHYADDR retrieved from CPUID. This is already stored in shadow_phys_bits, so use it instead of x86_phys_bits. Fixes: faaf05b ("kvm: x86/mmu: Support zapping SPTEs in the TDP MMU") Signed-off-by: Rick Edgecombe <[email protected]> Message-Id: <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent a2b2d4b commit 339f5a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static bool zap_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
6666

6767
void kvm_tdp_mmu_free_root(struct kvm *kvm, struct kvm_mmu_page *root)
6868
{
69-
gfn_t max_gfn = 1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT);
69+
gfn_t max_gfn = 1ULL << (shadow_phys_bits - PAGE_SHIFT);
7070

7171
lockdep_assert_held(&kvm->mmu_lock);
7272

@@ -456,7 +456,7 @@ bool kvm_tdp_mmu_zap_gfn_range(struct kvm *kvm, gfn_t start, gfn_t end)
456456

457457
void kvm_tdp_mmu_zap_all(struct kvm *kvm)
458458
{
459-
gfn_t max_gfn = 1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT);
459+
gfn_t max_gfn = 1ULL << (shadow_phys_bits - PAGE_SHIFT);
460460
bool flush;
461461

462462
flush = kvm_tdp_mmu_zap_gfn_range(kvm, 0, max_gfn);

0 commit comments

Comments
 (0)