Skip to contentSkip to conversation

nested vmx: Intercept guest rdmsr for MSR_IA32_VMX_VMFUNC

PATCH In review Euan Harris 5 participants 6 messages Jun 7, 2016 – Jun 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nested vmx: Intercept guest rdmsr for MSR_IA32_VMX_VMFUNC

Guest reads of MSR_IA32_VMX_VMFUNC should be handled by
the logic in vmx_msr_read_intercept(). Otherwise a guest
can read the raw host value of this MSR, even if nested vmx is disabled.

---
 xen/arch/x86/hvm/vmx/vmx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index 743b5a1..6c0721f 100644
@@ -2624,7 +2624,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
         __vmread(GUEST_IA32_DEBUGCTL, msr_content);
         break;
     case IA32_FEATURE_CONTROL_MSR:
-    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_VMFUNC:
         if ( !nvmx_msr_read_intercept(msr, msr_content) )
             goto gp_fault;
         break;
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 07.06.16 at 12:18, <[email protected]> wrote:

Guest reads of MSR_IA32_VMX_VMFUNC should be handled by
the logic in vmx_msr_read_intercept(). Otherwise a guest
can read the raw host value of this MSR, even if nested vmx is disabled.

Albeit ...

xen/arch/x86/hvm/vmx/vmx.c static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) · line 2630

Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2624,7 +2624,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
         __vmread(GUEST_IA32_DEBUGCTL, msr_content);
         break;
     case IA32_FEATURE_CONTROL_MSR:
-    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_VMFUNC:
         if ( !nvmx_msr_read_intercept(msr, msr_content) )
             goto gp_fault;
         break;

... retaining this code structure makes it likely that some future addition will lead to the same problem again. I think there should be something like MSR_IA32_VMX_LAST added to msr-index.h, and get used here instead. Suitably placed it would make pretty obvious to someone adding a new MSR there that this value also needs updating.

Or alternatively: Is there an architectural upper bound to the VMX MSR range? If so, we could widen the set to the full range in one go.

VMX maintainers - I'd appreciate if you could take care of this in one way or another.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 4 lines · Jan Beulich
Quoted 4 lines
xen/arch/x86/hvm/vmx/vmx.c +0 -0
@@ -2624,7 +2624,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
         __vmread(GUEST_IA32_DEBUGCTL, msr_content);
         break;
     case IA32_FEATURE_CONTROL_MSR:
Quoted 8 lines

xen/arch/x86/hvm/vmx/vmx.c static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) · line 2630

Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -1
-    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_VMFUNC:
         if ( !nvmx_msr_read_intercept(msr, msr_content) )
             goto gp_fault;
         break;

... retaining this code structure makes it likely that some future addition will lead to the same problem again.

The safest solution would be to whitelist the MSRs which Xen handles and which the guest should be allowed to see, rather than blacklisting which
is essentially what is happening now. That would involve a substantial
change in the code, but aside from that is there any fundamental reason why it would be a bad idea?

Thanks,
Euan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 12 lines · Euan Harris
Quoted 11 lines · Jan Beulich

xen/arch/x86/hvm/vmx/vmx.c static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) · line 2630

Quoted 9 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2624,7 +2624,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
         __vmread(GUEST_IA32_DEBUGCTL, msr_content);
         break;
     case IA32_FEATURE_CONTROL_MSR:
-    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_VMFUNC:
         if ( !nvmx_msr_read_intercept(msr, msr_content) )
             goto gp_fault;
         break;

... retaining this code structure makes it likely that some future addition will lead to the same problem again.

Quoted 5 lines

The safest solution would be to whitelist the MSRs which Xen handles and which the guest should be allowed to see, rather than blacklisting which
is essentially what is happening now. That would involve a substantial
change in the code, but aside from that is there any fundamental reason why it would be a bad idea?

I do have plans which will eventually turn all cpuid information and msrs visible to guests into a whitelist rather than a blacklist, but there is indeed a lot of infrastructure work required to make this happen.

It is certainly the longterm plan.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#4 lore raw
In reply to Euan Harris
Quoted 9 lines

From: Euan Harris [mailto:[email protected]]
Sent: Tuesday, June 07, 2016 6:19 PM

Guest reads of MSR_IA32_VMX_VMFUNC should be handled by
the logic in vmx_msr_read_intercept(). Otherwise a guest
can read the raw host value of this MSR, even if nested vmx is disabled.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
In reply to Euan Harris
Quoted 6 lines · Euan Harris

Guest reads of MSR_IA32_VMX_VMFUNC should be handled by
the logic in vmx_msr_read_intercept(). Otherwise a guest
can read the raw host value of this MSR, even if nested vmx is disabled.

For 4.7:

Quoted 25 lines
---
 xen/arch/x86/hvm/vmx/vmx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index 743b5a1..6c0721f 100644
@@ -2624,7 +2624,7 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
         __vmread(GUEST_IA32_DEBUGCTL, msr_content);
         break;
     case IA32_FEATURE_CONTROL_MSR:
-    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_TRUE_ENTRY_CTLS:
+    case MSR_IA32_VMX_BASIC...MSR_IA32_VMX_VMFUNC:
         if ( !nvmx_msr_read_intercept(msr, msr_content) )
             goto gp_fault;
         break;
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel