All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Huang <wei.huang2@amd.com>
To: "'xen-devel@lists.xensource.com'" <xen-devel@lists.xensource.com>
Subject: [PATCH][RFC] FPU LWP 2/5: add mask option to xsave/xrstor
Date: Thu, 14 Apr 2011 15:38:21 -0500	[thread overview]
Message-ID: <4DA75B3D.2040101@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

This patch adds a mask option to xsave/xrstor. This mask is used by 
xsave and xrstor instructions to selectively save/restore memory area.

Signed-off-by: Wei Huang <wei.huang2@amd.com>


[-- Attachment #2: lwp2.txt --]
[-- Type: text/plain, Size: 3649 bytes --]

# HG changeset patch
# User Wei Huang <wei.huang2@amd.com>
# Date 1302811998 18000
# Branch lwp3
# Node ID f5c4d99cde695bd0342a96d3ea6d5b34bd6047af
# Parent  4ed4e3d9106e691dddf3bbf54afd935ef0a9000f
FPU: Add mask option to xsave/xrstor

This patch adds a mask option to xsave/xrstor. This mask is used by xsave and xrstor instructions to selectively save/restore memory area.

Signed-off-by: Wei Huang <wei.huang2@amd.com>

diff -r 4ed4e3d9106e -r f5c4d99cde69 xen/arch/x86/i387.c
--- a/xen/arch/x86/i387.c	Thu Apr 14 15:12:07 2011 -0500
+++ b/xen/arch/x86/i387.c	Thu Apr 14 15:13:18 2011 -0500
@@ -127,36 +127,42 @@
     return cpu_has_xsave;	
 }
 
-static void xsave(struct vcpu *v)
+static void xsave(struct vcpu *v, uint64_t mask)
 {
     struct xsave_struct *ptr = v->arch.xsave_area;
+    uint32_t hmask = mask >> 32;
+    uint32_t lmask = mask;
 
     asm volatile (
         ".byte " REX_PREFIX "0x0f,0xae,0x27"
         :
-        : "a" (-1), "d" (-1), "D"(ptr)
+        : "a" (lmask), "d" (hmask), "D"(ptr)
         : "memory" );
 }
 
-static void xsaveopt(struct vcpu *v)
+static void xsaveopt(struct vcpu *v, uint64_t mask)
 {
     struct xsave_struct *ptr = v->arch.xsave_area;
+    uint32_t hmask = mask >> 32;
+    uint32_t lmask = mask;
 
     asm volatile (
         ".byte " REX_PREFIX "0x0f,0xae,0x37"
         :
-        : "a" (-1), "d" (-1), "D"(ptr)
+        : "a" (lmask), "d" (hmask), "D"(ptr)
         : "memory" );
 }
 
-static void xrstor(struct vcpu *v)
+static void xrstor(struct vcpu *v, uint64_t mask)
 {
     struct xsave_struct *ptr = v->arch.xsave_area;
+    uint32_t hmask = mask >> 32;
+    uint32_t lmask = mask;
 
     asm volatile (
         ".byte " REX_PREFIX "0x0f,0xae,0x2f"
         :
-        : "m" (*ptr), "a" (-1), "d" (-1), "D"(ptr) );
+        : "m" (*ptr), "a" (lmask), "d" (hmask), "D"(ptr) );
 }
 
 /******************************/
@@ -185,7 +191,7 @@
      * we set all supported feature mask before doing save/restore.
      */
     set_xcr0(v->arch.xcr0_accum);
-    xrstor(v);
+    xrstor(v, XCNTXT_MASK);
     set_xcr0(v->arch.xcr0);
 }
 
@@ -270,10 +276,10 @@
      */
     set_xcr0(v->arch.xcr0_accum);
     if ( cpu_has_xsaveopt )
-        xsaveopt(v);
+        xsaveopt(v, XCNTXT_MASK);
     else
-        xsave(v);
-    set_xcr0(v->arch.xcr0);    
+        xsave(v, XCNTXT_MASK);
+    set_xcr0(v->arch.xcr0);
 }
 
 /* Save x87 FPU, MMX, SSE and SSE2 state */
diff -r 4ed4e3d9106e -r f5c4d99cde69 xen/include/asm-x86/i387.h
--- a/xen/include/asm-x86/i387.h	Thu Apr 14 15:12:07 2011 -0500
+++ b/xen/include/asm-x86/i387.h	Thu Apr 14 15:13:18 2011 -0500
@@ -23,15 +23,17 @@
 extern u64 xfeature_mask;
 
 #define XSAVE_AREA_MIN_SIZE (512 + 64) /* FP/SSE + XSAVE.HEADER */
-#define XSTATE_FP       (1ULL << 0)
-#define XSTATE_SSE      (1ULL << 1)
-#define XSTATE_YMM      (1ULL << 2)
-#define XSTATE_LWP      (1ULL << 62) /* AMD lightweight profiling */
-#define XSTATE_FP_SSE   (XSTATE_FP | XSTATE_SSE)
-#define XCNTXT_MASK     (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_LWP)
-#define XSTATE_YMM_OFFSET  XSAVE_AREA_MIN_SIZE
-#define XSTATE_YMM_SIZE    256
-#define XSAVEOPT        (1 << 0)
+#define XSTATE_YMM_OFFSET   XSAVE_AREA_MIN_SIZE
+#define XSTATE_YMM_SIZE     256
+
+#define XSTATE_FP           (1ULL << 0)
+#define XSTATE_SSE          (1ULL << 1)
+#define XSTATE_YMM          (1ULL << 2)
+#define XSTATE_LWP          (1ULL << 62) /* AMD lightweight profiling */
+#define XSTATE_FP_SSE       (XSTATE_FP | XSTATE_SSE)
+#define XCNTXT_MASK         (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_LWP)
+
+#define XSAVEOPT            (1 << 0)
 
 #define XCR_XFEATURE_ENABLED_MASK   0
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2011-04-14 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14 20:38 Wei Huang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-15  9:11 [PATCH][RFC] FPU LWP 2/5: add mask option to xsave/xrstor Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DA75B3D.2040101@amd.com \
    --to=wei.huang2@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.