Skip to content

Commit de3ccd2

Browse files
Yu Zhangbonzini
authored andcommitted
KVM: MMU: record maximum physical address width in kvm_mmu_extended_role
Previously, commit 7dcd575 ("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>
1 parent 511da98 commit de3ccd2

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ union kvm_mmu_extended_role {
299299
unsigned int cr4_smap:1;
300300
unsigned int cr4_smep:1;
301301
unsigned int cr4_la57:1;
302+
unsigned int maxphyaddr:6;
302303
};
303304
};
304305

arch/x86/kvm/mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4777,6 +4777,7 @@ static union kvm_mmu_extended_role kvm_calc_mmu_role_ext(struct kvm_vcpu *vcpu)
47774777
ext.cr4_pse = !!is_pse(vcpu);
47784778
ext.cr4_pke = !!kvm_read_cr4_bits(vcpu, X86_CR4_PKE);
47794779
ext.cr4_la57 = !!kvm_read_cr4_bits(vcpu, X86_CR4_LA57);
4780+
ext.maxphyaddr = cpuid_maxphyaddr(vcpu);
47804781

47814782
ext.valid = 1;
47824783

0 commit comments

Comments
 (0)