summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorYu Zhang2017-08-24 14:27:53 +0200
committerPaolo Bonzini2017-08-24 18:09:16 +0200
commitd1cd3ce9004412949163bfaa062a4df98fe75a98 (patch)
tree2e1f466ee6a60218518586f64058f23a0b3fb68f /arch/x86/kvm/x86.c
parentKVM: x86: Add return value to kvm_cpuid(). (diff)
downloadkernel-qcow2-linux-d1cd3ce9004412949163bfaa062a4df98fe75a98.tar.gz
kernel-qcow2-linux-d1cd3ce9004412949163bfaa062a4df98fe75a98.tar.xz
kernel-qcow2-linux-d1cd3ce9004412949163bfaa062a4df98fe75a98.zip
KVM: MMU: check guest CR3 reserved bits based on its physical address width.
Currently, KVM uses CR3_L_MODE_RESERVED_BITS to check the reserved bits in CR3. Yet the length of reserved bits in guest CR3 should be based on the physical address width exposed to the VM. This patch changes CR3 check logic to calculate the reserved bits at runtime. Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cc2c7e413e9c..79f5889f8c12 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -813,10 +813,10 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
return 0;
}
- if (is_long_mode(vcpu)) {
- if (cr3 & CR3_L_MODE_RESERVED_BITS)
- return 1;
- } else if (is_pae(vcpu) && is_paging(vcpu) &&
+ if (is_long_mode(vcpu) &&
+ (cr3 & rsvd_bits(cpuid_maxphyaddr(vcpu), 62)))
+ return 1;
+ else if (is_pae(vcpu) && is_paging(vcpu) &&
!load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3))
return 1;