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>,
	Keir Fraser <keir@xen.org>, "Wei, Gang" <gang.wei@intel.com>
Subject: [PATCH 2/5][RFC] lwp: adding support for AMD lightweight profiling
Date: Fri, 11 Feb 2011 10:28:43 -0600	[thread overview]
Message-ID: <4D5563BB.6020304@amd.com> (raw)

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

Add a new field for xsave/xrstor functions to specify the features.

Current implementation set EAX:EDX to all 1's. To be prepared for LWP, 
we add a parameter in xsave/xrstor functions to be set in EAX:EDX. Some 
of the idea was borrowed from Hans Rosenfeld's Linux kernel patch.

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


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

exporting patch:
# HG changeset patch
# User Wei Huang <wei.huang2@amd.com>
# Date 1297376221 21600
# Node ID 20d10f3a6d4c6b7357da0cf35a9fe28100cb582d
# Parent  b57ee5edd2924179b21fa19d35b0e2754c4caeff
Add a new field for xsave/xrstor functions to specify the features.

Current implementation set EAX:EDX to all 1's. To be prepared for LWP, we add a parameter in xsave/xrstor functions to be set in EAX:EDX.

diff -r b57ee5edd292 -r 20d10f3a6d4c xen/arch/x86/i387.c
--- a/xen/arch/x86/i387.c	Thu Feb 10 16:00:34 2011 -0600
+++ b/xen/arch/x86/i387.c	Thu Feb 10 16:17:01 2011 -0600
@@ -18,36 +18,42 @@
 
 static bool_t __read_mostly cpu_has_xsaveopt;
 
-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) );
 }
 
 static void load_mxcsr(unsigned long val)
@@ -76,7 +82,7 @@
          * we set all supported feature mask before doing save/restore.
          */
         set_xcr0(v->arch.xcr0_accum);
-        xrstor(v);
+        xrstor(v, XCNTXT_DEFAULT);
         set_xcr0(v->arch.xcr0);
     }
     else if ( v->fpu_initialised )
@@ -123,9 +129,9 @@
          */
         set_xcr0(v->arch.xcr0_accum);
         if ( cpu_has_xsaveopt )
-            xsaveopt(v);
+            xsaveopt(v, XCNTXT_DEFAULT);
         else
-            xsave(v);
+            xsave(v, XCNTXT_DEFAULT);
         set_xcr0(v->arch.xcr0);
     }
     else if ( cpu_has_fxsr )
diff -r b57ee5edd292 -r 20d10f3a6d4c xen/include/asm-x86/i387.h
--- a/xen/include/asm-x86/i387.h	Thu Feb 10 16:00:34 2011 -0600
+++ b/xen/include/asm-x86/i387.h	Thu Feb 10 16:17:01 2011 -0600
@@ -32,6 +32,9 @@
 #define XSTATE_YMM_SIZE    256
 #define XSAVEOPT        (1 << 0)
 
+/* The features that the OS saves/restores by default. */
+#define XCNTXT_DEFAULT     (-1)
+
 struct xsave_struct
 {
     struct { char x[512]; } fpu_sse;         /* FPU/MMX, SSE */

[-- 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-02-11 16:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4D5563BB.6020304@amd.com \
    --to=wei.huang2@amd.com \
    --cc=gang.wei@intel.com \
    --cc=keir@xen.org \
    --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.