linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: VMX: Check the corresponding bits according to the intel sdm
@ 2021-03-23  2:37 lihaiwei.kernel
  2021-03-23  3:16 ` Jim Mattson
  2021-03-25 13:22 ` Haiwei Li
  0 siblings, 2 replies; 6+ messages in thread
From: lihaiwei.kernel @ 2021-03-23  2:37 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, Haiwei Li

From: Haiwei Li <lihaiwei@tencent.com>

According to IA-32 SDM Vol.3D "A.1 BASIC VMX INFORMATION", two inspections
are missing.
* Bit 31 is always 0. Earlier versions of this manual specified that the
VMCS revision identifier was a 32-bit field in bits 31:0 of this MSR. For
all processors produced prior to this change, bit 31 of this MSR was read
as 0.
* The values of bits 47:45 and bits 63:57 are reserved and are read as 0.

Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
---
 arch/x86/kvm/vmx/vmx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 32cf828..0d6d13c 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2577,6 +2577,20 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
 
 	rdmsr(MSR_IA32_VMX_BASIC, vmx_msr_low, vmx_msr_high);
 
+	/*
+	 * IA-32 SDM Vol 3D: Bit 31 is always 0.
+	 * For all earlier processors, bit 31 of this MSR was read as 0.
+	 */
+	if (vmx_msr_low & (1u<<31))
+		return -EIO;
+
+	/*
+	 * IA-32 SDM Vol 3D: bits 47:45 and bits 63:57 are reserved and are read
+	 * as 0.
+	 */
+	if (vmx_msr_high & 0xfe00e000)
+		return -EIO;
+
 	/* IA-32 SDM Vol 3B: VMCS size is never greater than 4kB. */
 	if ((vmx_msr_high & 0x1fff) > PAGE_SIZE)
 		return -EIO;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-26  0:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  2:37 [PATCH] KVM: VMX: Check the corresponding bits according to the intel sdm lihaiwei.kernel
2021-03-23  3:16 ` Jim Mattson
2021-03-23  4:42   ` Haiwei Li
2021-03-25 13:22 ` Haiwei Li
2021-03-25 15:49   ` Sean Christopherson
2021-03-26  0:39     ` Haiwei Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).