public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Gerst <brgerst@gmail.com>
To: hpa@zytor.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org, penberg@kernel.org
Subject: [PATCH 02/12] x86: Merge fpu_init()
Date: Fri,  3 Sep 2010 21:17:09 -0400	[thread overview]
Message-ID: <1283563039-3466-3-git-send-email-brgerst@gmail.com> (raw)
In-Reply-To: <1283563039-3466-1-git-send-email-brgerst@gmail.com>

Make fpu_init() handle 32-bit setup.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 arch/x86/kernel/cpu/common.c |    7 -------
 arch/x86/kernel/i387.c       |   30 ++++++++++++++----------------
 arch/x86/kernel/traps.c      |   12 ------------
 3 files changed, 14 insertions(+), 35 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 490dac6..f9e23e8 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1264,13 +1264,6 @@ void __cpuinit cpu_init(void)
 	clear_all_debug_regs();
 	dbg_restore_debug_regs();
 
-	/*
-	 * Force FPU initialization:
-	 */
-	current_thread_info()->status = 0;
-	clear_used_math();
-	mxcsr_feature_mask_init();
-
 	fpu_init();
 	xsave_init();
 }
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index a46cb35..1f082f3 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -80,7 +80,6 @@ static void __cpuinit init_thread_xstate(void)
 #endif
 }
 
-#ifdef CONFIG_X86_64
 /*
  * Called at bootup to set up the initial FPU state that is later cloned
  * into all processes.
@@ -88,12 +87,21 @@ static void __cpuinit init_thread_xstate(void)
 
 void __cpuinit fpu_init(void)
 {
-	unsigned long oldcr0 = read_cr0();
-
-	set_in_cr4(X86_CR4_OSFXSR);
-	set_in_cr4(X86_CR4_OSXMMEXCPT);
+	unsigned long cr0;
+	unsigned long cr4_mask = 0;
 
-	write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */
+	if (cpu_has_fxsr)
+		cr4_mask |= X86_CR4_OSFXSR;
+	if (cpu_has_xmm)
+		cr4_mask |= X86_CR4_OSXMMEXCPT;
+	if (cr4_mask)
+		set_in_cr4(cr4_mask);
+
+	cr0 = read_cr0();
+	cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */
+	if (!HAVE_HWFP)
+		cr0 |= X86_CR0_EM;
+	write_cr0(cr0);
 
 	if (!smp_processor_id())
 		init_thread_xstate();
@@ -104,16 +112,6 @@ void __cpuinit fpu_init(void)
 	clear_used_math();
 }
 
-#else	/* CONFIG_X86_64 */
-
-void __cpuinit fpu_init(void)
-{
-	if (!smp_processor_id())
-		init_thread_xstate();
-}
-
-#endif	/* CONFIG_X86_32 */
-
 void fpu_finit(struct fpu *fpu)
 {
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 60788de..d0029eb 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -881,18 +881,6 @@ void __init trap_init(void)
 #endif
 
 #ifdef CONFIG_X86_32
-	if (cpu_has_fxsr) {
-		printk(KERN_INFO "Enabling fast FPU save and restore... ");
-		set_in_cr4(X86_CR4_OSFXSR);
-		printk("done.\n");
-	}
-	if (cpu_has_xmm) {
-		printk(KERN_INFO
-			"Enabling unmasked SIMD FPU exception support... ");
-		set_in_cr4(X86_CR4_OSXMMEXCPT);
-		printk("done.\n");
-	}
-
 	set_system_trap_gate(SYSCALL_VECTOR, &system_call);
 	set_bit(SYSCALL_VECTOR, used_vectors);
 #endif
-- 
1.7.2.2


  parent reply	other threads:[~2010-09-04  1:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-04  1:17 [PATCH 0/12] x86 FPU cleanups (v2) Brian Gerst
2010-09-04  1:17 ` [PATCH 01/12] x86: Use correct type for %cr4 Brian Gerst
2010-09-04  6:45   ` Pekka Enberg
2010-09-10  1:46   ` [tip:x86/fpu] " tip-bot for Brian Gerst
2010-09-04  1:17 ` Brian Gerst [this message]
2010-09-04  6:45   ` [PATCH 02/12] x86: Merge fpu_init() Pekka Enberg
2010-09-10  1:46   ` [tip:x86/fpu] x86, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 03/12] x86: Merge tolerant_fwait() Brian Gerst
2010-09-04  6:46   ` Pekka Enberg
2010-09-10  1:46   ` [tip:x86/fpu] x86, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 04/12] x86: Merge __save_init_fpu() Brian Gerst
2010-09-04  6:47   ` Pekka Enberg
2010-09-10  1:47   ` [tip:x86/fpu] x86, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 05/12] x86-64: Disable preemption when using TS_USEDFPU Brian Gerst
2010-09-04  6:47   ` Pekka Enberg
2010-09-10  1:47   ` [tip:x86/fpu] x86-64, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 06/12] x86-64: Fix %cs value in convert_from_fxsr() Brian Gerst
2010-09-04  6:51   ` Pekka Enberg
2010-09-10  1:47   ` [tip:x86/fpu] x86-64, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 07/12] x86-64: Simplify constraints for fxsave/fxtstor Brian Gerst
2010-09-04  6:48   ` Pekka Enberg
2010-09-09 21:22   ` H. Peter Anvin
2010-09-09 23:43     ` Brian Gerst
2010-09-10  1:48   ` [tip:x86/fpu] x86-64, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 08/12] x86-32: Remove math_emulate stub Brian Gerst
2010-09-04  6:48   ` Pekka Enberg
2010-09-10  1:48   ` [tip:x86/fpu] x86-32, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 09/12] x86: Remove unnecessary ifdefs from i387 code Brian Gerst
2010-09-04  6:49   ` Pekka Enberg
2010-09-10  1:48   ` [tip:x86/fpu] x86, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 10/12] x86: Remove PSHUFB_XMM5_* macros Brian Gerst
2010-09-04  6:49   ` Pekka Enberg
2010-09-10  1:49   ` [tip:x86/fpu] x86, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 11/12] x86-32: Rewrite fpu_save_init() Brian Gerst
2010-09-04  6:51   ` Pekka Enberg
2010-09-10  1:49   ` [tip:x86/fpu] x86-32, fpu: " tip-bot for Brian Gerst
2010-09-04  1:17 ` [PATCH 12/12] x86: Merge fpu_save_init() Brian Gerst
2010-09-04  6:51   ` Pekka Enberg
2010-09-10  1:50   ` [tip:x86/fpu] x86, fpu: " tip-bot for Brian Gerst
2010-09-04  6:45 ` [PATCH 0/12] x86 FPU cleanups (v2) Pekka Enberg

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=1283563039-3466-3-git-send-email-brgerst@gmail.com \
    --to=brgerst@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=x86@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