mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Robert Richter <robert.richter@amd.com>
Subject: [PATCH 1/7] x86, xsave: separate fpu and xsave initialization
Date: Wed, 21 Jul 2010 19:03:52 +0200	[thread overview]
Message-ID: <1279731838-1522-2-git-send-email-robert.richter@amd.com> (raw)
In-Reply-To: <1279731838-1522-1-git-send-email-robert.richter@amd.com>

As xsave also supports other than fpu features, it should be
initialized independently of the fpu. This patch moves this out of fpu
initialization.

There is also a lot of cross referencing between fpu and xsave
code. This patch reduces this by making xsave_cntxt_init() and
init_thread_xstate() static functions.

The patch moves the cpu_has_xsave check at the beginning of
xsave_init(). All other checks may removed then.

Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 arch/x86/include/asm/i387.h  |    1 -
 arch/x86/include/asm/xsave.h |    1 -
 arch/x86/kernel/cpu/common.c |    2 ++
 arch/x86/kernel/i387.c       |   27 +++++++++++++++++++--------
 arch/x86/kernel/xsave.c      |   10 +++++-----
 5 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
index 59bd93a..509ddab 100644
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -31,7 +31,6 @@ extern void mxcsr_feature_mask_init(void);
 extern int init_fpu(struct task_struct *child);
 extern asmlinkage void math_state_restore(void);
 extern void __math_state_restore(void);
-extern void init_thread_xstate(void);
 extern int dump_fpu(struct pt_regs *, struct user_i387_struct *);
 
 extern user_regset_active_fn fpregs_active, xfpregs_active;
diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
index 94d5f84..4d3b5d1 100644
--- a/arch/x86/include/asm/xsave.h
+++ b/arch/x86/include/asm/xsave.h
@@ -28,7 +28,6 @@ extern u64 pcntxt_mask;
 extern struct xsave_struct *init_xstate_buf;
 extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
 
-extern void xsave_cntxt_init(void);
 extern void xsave_init(void);
 extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
 extern int init_fpu(struct task_struct *child);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4056108..94c36c7 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1210,6 +1210,7 @@ void __cpuinit cpu_init(void)
 	dbg_restore_debug_regs();
 
 	fpu_init();
+	xsave_init();
 
 	raw_local_save_flags(kernel_eflags);
 
@@ -1270,6 +1271,7 @@ void __cpuinit cpu_init(void)
 	clear_used_math();
 	mxcsr_feature_mask_init();
 
+	fpu_init();
 	xsave_init();
 }
 #endif
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 2f32ef0..e73c54e 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -59,18 +59,18 @@ void __cpuinit mxcsr_feature_mask_init(void)
 	stts();
 }
 
-void __cpuinit init_thread_xstate(void)
+static void __cpuinit init_thread_xstate(void)
 {
+	/*
+	 * Note that xstate_size might be overwriten later during
+	 * xsave_init().
+	 */
+
 	if (!HAVE_HWFP) {
 		xstate_size = sizeof(struct i387_soft_struct);
 		return;
 	}
 
-	if (cpu_has_xsave) {
-		xsave_cntxt_init();
-		return;
-	}
-
 	if (cpu_has_fxsr)
 		xstate_size = sizeof(struct i387_fxsave_struct);
 #ifdef CONFIG_X86_32
@@ -84,6 +84,7 @@ void __cpuinit init_thread_xstate(void)
  * Called at bootup to set up the initial FPU state that is later cloned
  * into all processes.
  */
+
 void __cpuinit fpu_init(void)
 {
 	unsigned long oldcr0 = read_cr0();
@@ -93,14 +94,24 @@ void __cpuinit fpu_init(void)
 
 	write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */
 
-	xsave_init();
+	if (!smp_processor_id())
+		init_thread_xstate();
 
 	mxcsr_feature_mask_init();
 	/* clean state in init */
 	current_thread_info()->status = 0;
 	clear_used_math();
 }
-#endif	/* CONFIG_X86_64 */
+
+#else	/* CONFIG_X86_64 */
+
+void __cpuinit fpu_init(void)
+{
+	if (!smp_processor_id())
+		init_thread_xstate();
+}
+
+#endif	/* CONFIG_X86_32 */
 
 static void fpu_finit(struct fpu *fpu)
 {
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index ab9ad48..550bf45 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -362,9 +362,6 @@ unsigned int sig_xstate_size = sizeof(struct _fpstate);
  */
 static void __cpuinit __xsave_init(void)
 {
-	if (!cpu_has_xsave)
-		return;
-
 	set_in_cr4(X86_CR4_OSXSAVE);
 
 	/*
@@ -429,7 +426,7 @@ static void __init setup_xstate_init(void)
 /*
  * Enable and initialize the xsave feature.
  */
-void __ref xsave_cntxt_init(void)
+static void __cpuinit xsave_cntxt_init(void)
 {
 	unsigned int eax, ebx, ecx, edx;
 
@@ -466,10 +463,13 @@ void __ref xsave_cntxt_init(void)
 
 void __cpuinit xsave_init(void)
 {
+	if (!cpu_has_xsave)
+		return;
+
 	/*
 	 * Boot processor to setup the FP and extended state context info.
 	 */
 	if (!smp_processor_id())
-		init_thread_xstate();
+		xsave_cntxt_init();
 	__xsave_init();
 }
-- 
1.7.1.1



  reply	other threads:[~2010-07-21 17:22 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 17:03 [PATCH 0/7] x86, xsave: some code cleanups and reworks, -v2 Robert Richter
2010-07-21 17:03 ` Robert Richter [this message]
2010-07-21 22:36   ` [tip:x86/xsave] x86, xsave: Separate fpu and xsave initialization tip-bot for Robert Richter
2010-07-21 17:03 ` [PATCH 2/7] x86, xsave: introduce xstate enable functions Robert Richter
2010-07-21 21:10   ` H. Peter Anvin
2010-07-21 21:20     ` Suresh Siddha
2010-07-21 21:53       ` H. Peter Anvin
2010-07-21 22:32         ` Suresh Siddha
2010-07-22 12:15         ` Robert Richter
2010-07-22 12:23           ` H. Peter Anvin
2010-07-22 13:16             ` Robert Richter
2010-07-21 22:38     ` [tip:x86/xsave] x86, xsave: Make xstate_enable_boot_cpu() __init, protect on CPU 0 tip-bot for H. Peter Anvin
2010-07-21 22:37   ` [tip:x86/xsave] x86, xsave: Introduce xstate enable functions tip-bot for Robert Richter
2010-07-21 17:03 ` [PATCH 3/7] x86, xsave: check cpuid level for XSTATE_CPUID (0x0d) Robert Richter
2010-07-21 22:37   ` [tip:x86/xsave] x86, xsave: Check " tip-bot for Robert Richter
2010-07-21 17:03 ` [PATCH 4/7] x86, xsave: make init_xstate_buf static Robert Richter
2010-07-21 22:37   ` [tip:x86/xsave] x86, xsave: Make " tip-bot for Robert Richter
2010-07-21 17:03 ` [PATCH 5/7] x86, xsave: add __init attribute to setup_xstate_features() Robert Richter
2010-07-21 22:37   ` [tip:x86/xsave] x86, xsave: Add " tip-bot for Robert Richter
2010-07-21 17:03 ` [PATCH 6/7] x86, xsave: disable xsave in i387 emulation mode Robert Richter
2010-07-21 18:16   ` Suresh Siddha
2010-07-22 12:36     ` Robert Richter
2010-07-23 17:50       ` Suresh Siddha
2010-07-26 16:42         ` Robert Richter
2010-07-26 18:26       ` H. Peter Anvin
2010-07-27  8:53         ` Robert Richter
2010-08-12 22:06   ` [tip:x86/fpu] x86, xsave: Disable " tip-bot for Robert Richter
2010-07-21 17:03 ` [PATCH 7/7] x86: removing boot_cpu_id variable Robert Richter
2010-08-12 21:03   ` [tip:x86/cleanups] x86, cleanup: Remove obsolete " tip-bot for Robert Richter
2010-07-21 18:19 ` [PATCH 0/7] x86, xsave: some code cleanups and reworks, -v2 Suresh Siddha
2010-07-21 20:55 ` H. Peter Anvin
2010-07-21 21:07   ` H. Peter Anvin
2010-08-10 19:24 ` [osrc-patches] " Robert Richter

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=1279731838-1522-2-git-send-email-robert.richter@amd.com \
    --to=robert.richter@amd.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=suresh.b.siddha@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome