aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorWanpeng Li <wanpeng.li@linux.intel.com>2014-08-20 03:31:53 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-08-20 04:13:40 -0400
commita32e84594ddf018cc618a8781298804c3e6131ce (patch)
tree4b5acc7131c98e21e312386830f7c824cf94ff6e /arch/x86/kvm/vmx.c
parent1e1b6c26443547b05925ae4a4494884c92eb7d95 (diff)
KVM: vmx: fix ept reserved bits for 1-GByte page
EPT misconfig handler in kvm will check which reason lead to EPT misconfiguration after vmexit. One of the reasons is that an EPT paging-structure entry is configured with settings reserved for future functionality. However, the handler can't identify if paging-structure entry of reserved bits for 1-GByte page are configured, since PDPTE which point to 1-GByte page will reserve bits 29:12 instead of bits 7:3 which are reserved for PDPTE that references an EPT Page Directory. This patch fix it by reserve bits 29:12 for 1-GByte page. Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index cad37d57cc47..286c2835e25c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5521,17 +5521,18 @@ static u64 ept_rsvd_mask(u64 spte, int level)
5521 for (i = 51; i > boot_cpu_data.x86_phys_bits; i--) 5521 for (i = 51; i > boot_cpu_data.x86_phys_bits; i--)
5522 mask |= (1ULL << i); 5522 mask |= (1ULL << i);
5523 5523
5524 if (level > 2) 5524 if (level == 4)
5525 /* bits 7:3 reserved */ 5525 /* bits 7:3 reserved */
5526 mask |= 0xf8; 5526 mask |= 0xf8;
5527 else if (level == 2) { 5527 else if (spte & (1ULL << 7))
5528 if (spte & (1ULL << 7)) 5528 /*
5529 /* 2MB ref, bits 20:12 reserved */ 5529 * 1GB/2MB page, bits 29:12 or 20:12 reserved respectively,
5530 mask |= 0x1ff000; 5530 * level == 1 if the hypervisor is using the ignored bit 7.
5531 else 5531 */
5532 /* bits 6:3 reserved */ 5532 mask |= (PAGE_SIZE << ((level - 1) * 9)) - PAGE_SIZE;
5533 mask |= 0x78; 5533 else if (level > 1)
5534 } 5534 /* bits 6:3 reserved */
5535 mask |= 0x78;
5535 5536
5536 return mask; 5537 return mask;
5537} 5538}
@@ -5561,7 +5562,8 @@ static void ept_misconfig_inspect_spte(struct kvm_vcpu *vcpu, u64 spte,
5561 WARN_ON(1); 5562 WARN_ON(1);
5562 } 5563 }
5563 5564
5564 if (level == 1 || (level == 2 && (spte & (1ULL << 7)))) { 5565 /* bits 5:3 are _not_ reserved for large page or leaf page */
5566 if ((rsvd_bits & 0x38) == 0) {
5565 u64 ept_mem_type = (spte & 0x38) >> 3; 5567 u64 ept_mem_type = (spte & 0x38) >> 3;
5566 5568
5567 if (ept_mem_type == 2 || ept_mem_type == 3 || 5569 if (ept_mem_type == 2 || ept_mem_type == 3 ||