Skip to contentSkip to conversation

kvm: nVMX: Enforce must-be-zero bits in the IA32_VMX_VMCS_ENUM MSR

PATCH In review Aaron Lewis 2 participants 4 messages May 31, 2019 – Jul 10, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kvm: nVMX: Enforce must-be-zero bits in the IA32_VMX_VMCS_ENUM MSR

According to the SDM, bit 0 and bits 63:10 of the IA32_VMX_VMCS_ENUM MSR are reserved and are read as 0.

---
 arch/x86/kvm/vmx/nested.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/nested.c +2 -0
index 6401eb7ef19c..3438279e76bb 100644
@@ -1219,6 +1219,8 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
 	case MSR_IA32_VMX_EPT_VPID_CAP:
 		return vmx_restore_vmx_ept_vpid_cap(vmx, data);
 	case MSR_IA32_VMX_VMCS_ENUM:
+		if (data & (GENMASK_ULL(63, 10) | BIT_ULL(0)))
+			return -EINVAL;
 		vmx->nested.msrs.vmcs_enum = data;
 		return 0;
 	default:
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
Reviewed-by on v1 1/2
#1 lore raw
Quoted 14 lines · Aaron Lewis

According to the SDM, bit 0 and bits 63:10 of the IA32_VMX_VMCS_ENUM MSR are reserved and are read as 0.

---
  arch/x86/kvm/vmx/nested.c | 2 ++
  1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/nested.c +0 -0
index 6401eb7ef19c..3438279e76bb 100644

arch/x86/kvm/vmx/nested.c int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) · line 1226

Quoted 8 lines
arch/x86/kvm/vmx/nested.c +2 -0
@@ -1219,6 +1219,8 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
  	case MSR_IA32_VMX_EPT_VPID_CAP:
  		return vmx_restore_vmx_ept_vpid_cap(vmx, data);
  	case MSR_IA32_VMX_VMCS_ENUM:
+		if (data & (GENMASK_ULL(63, 10) | BIT_ULL(0)))
+			return -EINVAL;
  		vmx->nested.msrs.vmcs_enum = data;
  		return 0;
  	default:
#2 lore raw
Quoted 13 lines · Krish Sadhukhan
Quoted 10 lines · Aaron Lewis

According to the SDM, bit 0 and bits 63:10 of the IA32_VMX_VMCS_ENUM MSR are reserved and are read as 0.

---
  arch/x86/kvm/vmx/nested.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 17 lines

arch/x86/kvm/vmx/nested.c int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) · line 1226

Quoted 13 lines
arch/x86/kvm/vmx/nested.c +2 -0
index 6401eb7ef19c..3438279e76bb 100644
@@ -1219,6 +1219,8 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
      case MSR_IA32_VMX_EPT_VPID_CAP:
              return vmx_restore_vmx_ept_vpid_cap(vmx, data);
      case MSR_IA32_VMX_VMCS_ENUM:
+             if (data & (GENMASK_ULL(63, 10) | BIT_ULL(0)))
+                     return -EINVAL;
              vmx->nested.msrs.vmcs_enum = data;
              return 0;
      default:

ping

#3 lore raw
Quoted 34 lines · Aaron Lewis
Quoted 13 lines · Krish Sadhukhan
Quoted 10 lines · Aaron Lewis

According to the SDM, bit 0 and bits 63:10 of the IA32_VMX_VMCS_ENUM MSR are reserved and are read as 0.

---
  arch/x86/kvm/vmx/nested.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 17 lines

arch/x86/kvm/vmx/nested.c int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) · line 1226

Quoted 13 lines
arch/x86/kvm/vmx/nested.c +2 -0
index 6401eb7ef19c..3438279e76bb 100644
@@ -1219,6 +1219,8 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
      case MSR_IA32_VMX_EPT_VPID_CAP:
              return vmx_restore_vmx_ept_vpid_cap(vmx, data);
      case MSR_IA32_VMX_VMCS_ENUM:
+             if (data & (GENMASK_ULL(63, 10) | BIT_ULL(0)))
+                     return -EINVAL;
              vmx->nested.msrs.vmcs_enum = data;
              return 0;
      default:
Quoted 1 line

ping

ping