]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: MMU: record maximum physical address width in kvm_mmu_extended_role
authorYu Zhang <yu.c.zhang@linux.intel.com>
Thu, 31 Jan 2019 16:09:23 +0000 (00:09 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 22 Feb 2019 18:25:10 +0000 (19:25 +0100)
Previously, commit 7dcd57552008 ("x86/kvm/mmu: check if tdp/shadow
MMU reconfiguration is needed") offered some optimization to avoid
the unnecessary reconfiguration. Yet one scenario is broken - when
cpuid changes VM's maximum physical address width, reconfiguration
is needed to reset the reserved bits.  Also, the TDP may need to
reset its shadow_root_level when this value is changed.

To fix this, a new field, maxphyaddr, is introduced in the extended
role structure to keep track of the configured guest physical address
width.

Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c

index 593e17b7797e2e81502d3890dd6c486b71a2a460..180373360e34256ef3a3bba30ada81f7df9d27ed 100644 (file)
@@ -299,6 +299,7 @@ union kvm_mmu_extended_role {
                unsigned int cr4_smap:1;
                unsigned int cr4_smep:1;
                unsigned int cr4_la57:1;
+               unsigned int maxphyaddr:6;
        };
 };
 
index 6e62ed3852ac3f6b70a3a7d381471c82ce286214..f2d1d230d5b8421827aa447984fb271360bfec00 100644 (file)
@@ -4777,6 +4777,7 @@ static union kvm_mmu_extended_role kvm_calc_mmu_role_ext(struct kvm_vcpu *vcpu)
        ext.cr4_pse = !!is_pse(vcpu);
        ext.cr4_pke = !!kvm_read_cr4_bits(vcpu, X86_CR4_PKE);
        ext.cr4_la57 = !!kvm_read_cr4_bits(vcpu, X86_CR4_LA57);
+       ext.maxphyaddr = cpuid_maxphyaddr(vcpu);
 
        ext.valid = 1;