Skip to content

Commit

Permalink
x86, fpu: Merge fpu_init()
Browse files Browse the repository at this point in the history
Make fpu_init() handle 32-bit setup.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <1283563039-3466-3-git-send-email-brgerst@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Brian Gerst authored and H. Peter Anvin committed Sep 9, 2010
1 parent 2df7a6e commit 6ac8bac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 35 deletions.
7 changes: 0 additions & 7 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
30 changes: 14 additions & 16 deletions arch/x86/kernel/i387.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,28 @@ 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.
*/

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();
Expand All @@ -109,16 +117,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
Expand Down
12 changes: 0 additions & 12 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6ac8bac

Please sign in to comment.