From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86/xsave: also save/restore XCR0 across suspend (ACPI S3) Date: Mon, 21 Oct 2013 10:30:03 +0100 Message-ID: <5264F41B.9000304@citrix.com> References: <5264FDDC02000078000FC4BD@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1793157485438771912==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VYBoO-0000CW-Uu for xen-devel@lists.xenproject.org; Mon, 21 Oct 2013 09:30:09 +0000 In-Reply-To: <5264FDDC02000078000FC4BD@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============1793157485438771912== Content-Type: multipart/alternative; boundary="------------070609070300080607070302" --------------070609070300080607070302 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On 21/10/13 09:11, Jan Beulich wrote: > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > > --- a/xen/arch/x86/acpi/suspend.c > +++ b/xen/arch/x86/acpi/suspend.c > @@ -13,12 +13,14 @@ > #include > #include > #include > +#include > #include > > static unsigned long saved_lstar, saved_cstar; > static unsigned long saved_sysenter_esp, saved_sysenter_eip; > static unsigned long saved_fs_base, saved_gs_base, saved_kernel_gs_base; > static uint16_t saved_segs[4]; > +static uint64_t saved_xcr0; > > void save_rest_processor_state(void) > { > @@ -38,6 +40,8 @@ void save_rest_processor_state(void) > rdmsrl(MSR_IA32_SYSENTER_ESP, saved_sysenter_esp); > rdmsrl(MSR_IA32_SYSENTER_EIP, saved_sysenter_eip); > } > + if ( cpu_has_xsave ) > + saved_xcr0 = get_xcr0(); > } > > > @@ -77,6 +81,9 @@ void restore_rest_processor_state(void) > do_set_segment_base(SEGBASE_GS_USER_SEL, saved_segs[3]); > } > > + if ( cpu_has_xsave && !set_xcr0(saved_xcr0) ) > + BUG(); > + > /* Maybe load the debug registers. */ > BUG_ON(is_hvm_vcpu(curr)); > if ( !is_idle_vcpu(curr) && curr->arch.debugreg[7] ) > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------070609070300080607070302 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
On 21/10/13 09:11, Jan Beulich wrote:
Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/xen/arch/x86/acpi/suspend.c
+++ b/xen/arch/x86/acpi/suspend.c
@@ -13,12 +13,14 @@
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/support.h>
 #include <asm/i387.h>
+#include <asm/xstate.h>
 #include <xen/hypercall.h>
 
 static unsigned long saved_lstar, saved_cstar;
 static unsigned long saved_sysenter_esp, saved_sysenter_eip;
 static unsigned long saved_fs_base, saved_gs_base, saved_kernel_gs_base;
 static uint16_t saved_segs[4];
+static uint64_t saved_xcr0;
 
 void save_rest_processor_state(void)
 {
@@ -38,6 +40,8 @@ void save_rest_processor_state(void)
         rdmsrl(MSR_IA32_SYSENTER_ESP, saved_sysenter_esp);
         rdmsrl(MSR_IA32_SYSENTER_EIP, saved_sysenter_eip);
     }
+    if ( cpu_has_xsave )
+        saved_xcr0 = get_xcr0();
 }
 
 
@@ -77,6 +81,9 @@ void restore_rest_processor_state(void)
         do_set_segment_base(SEGBASE_GS_USER_SEL, saved_segs[3]);
     }
 
+    if ( cpu_has_xsave && !set_xcr0(saved_xcr0) )
+        BUG();
+
     /* Maybe load the debug registers. */
     BUG_ON(is_hvm_vcpu(curr));
     if ( !is_idle_vcpu(curr) && curr->arch.debugreg[7] )





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

--------------070609070300080607070302-- --===============1793157485438771912== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============1793157485438771912==--