From: Hans Rosenfeld <hans.rosenfeld@amd.com>
To: <linux-kernel@vger.kernel.org>
Cc: Hans Rosenfeld <hans.rosenfeld@amd.com>
Subject: [RFC 2/3] Allow saving of individual states in fpu_xsave().
Date: Tue, 5 Oct 2010 20:30:28 +0200 [thread overview]
Message-ID: <1286303429-415145-3-git-send-email-hans.rosenfeld@amd.com> (raw)
In-Reply-To: <20101005182739.GE173@escobedo.osrc.amd.com>
Add a feature mask argument to fpu_xsave(). Introduce XCNTXT_DEFAULT
to specify which feature states are to be saved/restored by default at
context switches. Rename XCNTXT_MASK to XCNTXT_SUPPORTED to make clear
what it really is.
Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com>
---
arch/x86/include/asm/i387.h | 4 ++--
arch/x86/include/asm/xsave.h | 14 +++++++++++---
arch/x86/kernel/xsave.c | 2 +-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
index de8593b..33600d3 100644
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -201,7 +201,7 @@ static inline void fpu_save_init(struct fpu *fpu)
if (use_xsave()) {
struct xsave_struct *xstate = &fpu->state->xsave;
- fpu_xsave(xstate);
+ fpu_xsave(xstate, XCNTXT_DEFAULT);
/*
* xsave header may indicate the init state of the FP.
@@ -239,7 +239,7 @@ static inline void __save_init_fpu(struct task_struct *tsk)
static inline int fpu_restore_checking(struct fpu *fpu)
{
if (use_xsave())
- return xrstor_checking(&fpu->state->xsave, -1);
+ return xrstor_checking(&fpu->state->xsave, XCNTXT_DEFAULT);
else
return fxrstor_checking(&fpu->state->fxsave);
}
diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
index 8bcbbce..8820b57 100644
--- a/arch/x86/include/asm/xsave.h
+++ b/arch/x86/include/asm/xsave.h
@@ -23,7 +23,12 @@
/*
* These are the features that the OS can handle currently.
*/
-#define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
+#define XCNTXT_SUPPORTED (XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
+
+/*
+ * These are the features that the OS saves/restores by default.
+ */
+#define XCNTXT_DEFAULT (-1)
#ifdef CONFIG_X86_64
#define REX_PREFIX "0x48, "
@@ -113,15 +118,18 @@ static inline void xsave_state(struct xsave_struct *fx, u64 mask)
: "memory");
}
-static inline void fpu_xsave(struct xsave_struct *fx)
+static inline void fpu_xsave(struct xsave_struct *fx, u64 mask)
{
+ u32 lmask = mask;
+ u32 hmask = mask >> 32;
+
/* This, however, we can work around by forcing the compiler to select
an addressing mode that doesn't require extended registers. */
alternative_input(
".byte " REX_PREFIX "0x0f,0xae,0x27",
".byte " REX_PREFIX "0x0f,0xae,0x37",
X86_FEATURE_XSAVEOPT,
- [fx] "D" (fx), "a" (-1), "d" (-1) :
+ [fx] "D" (fx), "a" (lmask), "d" (hmask) :
"memory");
}
#endif
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 5eb15d4..11c3445 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -434,7 +434,7 @@ static void __init xstate_enable_boot_cpu(void)
/*
* Support only the state known to OS.
*/
- pcntxt_mask = pcntxt_mask & XCNTXT_MASK;
+ pcntxt_mask = pcntxt_mask & XCNTXT_SUPPORTED;
xstate_enable();
--
1.5.6.5
next prev parent reply other threads:[~2010-10-05 18:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1286212172-654419-1-git-send-email-hans.rosenfeld@amd.com>
2010-10-04 22:13 ` [RFC 0/3] Basic support for LWP Thomas Gleixner
2010-10-05 14:51 ` Hans Rosenfeld
2010-10-05 15:34 ` Thomas Gleixner
2010-10-05 18:27 ` Hans Rosenfeld
2010-10-05 18:30 ` Hans Rosenfeld
2010-10-05 18:30 ` [RFC 1/3] Cleanup xsave/xrstor support Hans Rosenfeld
2010-10-05 18:30 ` Hans Rosenfeld [this message]
2010-10-05 18:30 ` [RFC 3/3] Save/restore LWP state in context switches Hans Rosenfeld
2010-10-06 11:12 ` Brian Gerst
2010-10-07 14:58 ` Hans Rosenfeld
2010-11-23 20:41 ` [RFC 0/2] FPU/xsave rework in preparation for LWP Hans Rosenfeld
2010-11-23 20:41 ` [RFC 1/2] x86, xsave: cleanup xsave/xrstor support Hans Rosenfeld
2010-11-23 20:41 ` [RFC 2/2] x86, xsave: rework xsave support Hans Rosenfeld
2010-11-25 0:36 ` Brian Gerst
2010-10-05 19:05 ` [RFC 0/3] Basic support for LWP Ingo Molnar
2010-10-06 7:35 ` Robert Richter
[not found] ` <AANLkTi=T0QmcKeZcgcR+GKk-9OwQUB_x8XdHiNuU7tE_@mail.gmail.com>
2010-10-07 10:46 ` Stephane Eranian
2010-10-07 13:59 ` H. Peter Anvin
2010-10-07 14:11 ` Stephane Eranian
2010-10-07 14:20 ` Hans Rosenfeld
2010-10-07 14:20 ` H. Peter Anvin
2010-10-07 14:25 ` Stephane Eranian
2010-10-07 14:47 ` H. Peter Anvin
2010-10-07 15:12 ` Stephane Eranian
2010-10-05 18:43 ` Davidlohr Bueso
2010-10-06 10:26 ` Andi Kleen
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=1286303429-415145-3-git-send-email-hans.rosenfeld@amd.com \
--to=hans.rosenfeld@amd.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®