[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Nested VMX: Allow to set CR4.OSXSAVE if guest has xsave feature



From: Yang Zhang <yang.z.zhang@xxxxxxxxx>

We exposed the xsave feature to guest, but we didn't allow guest
to set CR4.OSXSAVE when guest running in nested mode. This will
cause win 7 guest fail to use XP mode. In this patch, we allow guest
to set CR4.OSXSAVE in nested mode when it has the xsave feature.

Signed-off-by: Yang Zhang <yang.z.zhang@xxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vvmx.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index cecc72f..879af58 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -1815,6 +1815,7 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 
*msr_content)
 {
     struct vcpu *v = current;
     u64 data = 0, host_data = 0;
+    unsigned int eax, ebx, ecx, edx;
     int r = 1;
 
     if ( !nestedhvm_enabled(v->domain) )
@@ -1925,8 +1926,13 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 
*msr_content)
         data = X86_CR4_VMXE;
         break;
     case MSR_IA32_VMX_CR4_FIXED1:
+        data = 0x267ff;
+        /* Allow to set OSXSAVE if guest has xsave feature. */
+        hvm_cpuid(0x1, &eax, &ebx, &ecx, &edx);
+        if ( ecx & cpufeat_mask(X86_FEATURE_XSAVE) )
+            data |= X86_CR4_OSXSAVE;
         /* allow 0-settings except SMXE */
-        data = 0x267ff & ~X86_CR4_SMXE;
+        data &= ~X86_CR4_SMXE;
         break;
     case MSR_IA32_VMX_MISC:
         /* Do not support CR3-target feature now */
-- 
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.