diff options
author | Brian Gerst <brgerst@gmail.com> | 2010-09-03 21:17:09 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-09-09 17:16:20 -0400 |
commit | 6ac8bac2684235f4caf22a410549c582aa7327d6 (patch) | |
tree | d376c2c06ffa1461219f5370497d220cd4afefb0 | |
parent | 2df7a6e9e8e67c19e5fe2eac3f2d2223b7bb4a7b (diff) |
x86, fpu: Merge fpu_init()
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>
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 7 | ||||
-rw-r--r-- | arch/x86/kernel/i387.c | 30 | ||||
-rw-r--r-- | 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 490dac63c2d2..f9e23e8639eb 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1264,13 +1264,6 @@ void __cpuinit cpu_init(void) | |||
1264 | clear_all_debug_regs(); | 1264 | clear_all_debug_regs(); |
1265 | dbg_restore_debug_regs(); | 1265 | dbg_restore_debug_regs(); |
1266 | 1266 | ||
1267 | /* | ||
1268 | * Force FPU initialization: | ||
1269 | */ | ||
1270 | current_thread_info()->status = 0; | ||
1271 | clear_used_math(); | ||
1272 | mxcsr_feature_mask_init(); | ||
1273 | |||
1274 | fpu_init(); | 1267 | fpu_init(); |
1275 | xsave_init(); | 1268 | xsave_init(); |
1276 | } | 1269 | } |
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c index 2605c50b11d3..82166519497a 100644 --- a/arch/x86/kernel/i387.c +++ b/arch/x86/kernel/i387.c | |||
@@ -85,7 +85,6 @@ static void __cpuinit init_thread_xstate(void) | |||
85 | #endif | 85 | #endif |
86 | } | 86 | } |
87 | 87 | ||
88 | #ifdef CONFIG_X86_64 | ||
89 | /* | 88 | /* |
90 | * Called at bootup to set up the initial FPU state that is later cloned | 89 | * Called at bootup to set up the initial FPU state that is later cloned |
91 | * into all processes. | 90 | * into all processes. |
@@ -93,12 +92,21 @@ static void __cpuinit init_thread_xstate(void) | |||
93 | 92 | ||
94 | void __cpuinit fpu_init(void) | 93 | void __cpuinit fpu_init(void) |
95 | { | 94 | { |
96 | unsigned long oldcr0 = read_cr0(); | 95 | unsigned long cr0; |
97 | 96 | unsigned long cr4_mask = 0; | |
98 | set_in_cr4(X86_CR4_OSFXSR); | ||
99 | set_in_cr4(X86_CR4_OSXMMEXCPT); | ||
100 | 97 | ||
101 | write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */ | 98 | if (cpu_has_fxsr) |
99 | cr4_mask |= X86_CR4_OSFXSR; | ||
100 | if (cpu_has_xmm) | ||
101 | cr4_mask |= X86_CR4_OSXMMEXCPT; | ||
102 | if (cr4_mask) | ||
103 | set_in_cr4(cr4_mask); | ||
104 | |||
105 | cr0 = read_cr0(); | ||
106 | cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */ | ||
107 | if (!HAVE_HWFP) | ||
108 | cr0 |= X86_CR0_EM; | ||
109 | write_cr0(cr0); | ||
102 | 110 | ||
103 | if (!smp_processor_id()) | 111 | if (!smp_processor_id()) |
104 | init_thread_xstate(); | 112 | init_thread_xstate(); |
@@ -109,16 +117,6 @@ void __cpuinit fpu_init(void) | |||
109 | clear_used_math(); | 117 | clear_used_math(); |
110 | } | 118 | } |
111 | 119 | ||
112 | #else /* CONFIG_X86_64 */ | ||
113 | |||
114 | void __cpuinit fpu_init(void) | ||
115 | { | ||
116 | if (!smp_processor_id()) | ||
117 | init_thread_xstate(); | ||
118 | } | ||
119 | |||
120 | #endif /* CONFIG_X86_32 */ | ||
121 | |||
122 | void fpu_finit(struct fpu *fpu) | 120 | void fpu_finit(struct fpu *fpu) |
123 | { | 121 | { |
124 | #ifdef CONFIG_X86_32 | 122 | #ifdef CONFIG_X86_32 |
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 60788dee0f8a..d0029eb58589 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -881,18 +881,6 @@ void __init trap_init(void) | |||
881 | #endif | 881 | #endif |
882 | 882 | ||
883 | #ifdef CONFIG_X86_32 | 883 | #ifdef CONFIG_X86_32 |
884 | if (cpu_has_fxsr) { | ||
885 | printk(KERN_INFO "Enabling fast FPU save and restore... "); | ||
886 | set_in_cr4(X86_CR4_OSFXSR); | ||
887 | printk("done.\n"); | ||
888 | } | ||
889 | if (cpu_has_xmm) { | ||
890 | printk(KERN_INFO | ||
891 | "Enabling unmasked SIMD FPU exception support... "); | ||
892 | set_in_cr4(X86_CR4_OSXMMEXCPT); | ||
893 | printk("done.\n"); | ||
894 | } | ||
895 | |||
896 | set_system_trap_gate(SYSCALL_VECTOR, &system_call); | 884 | set_system_trap_gate(SYSCALL_VECTOR, &system_call); |
897 | set_bit(SYSCALL_VECTOR, used_vectors); | 885 | set_bit(SYSCALL_VECTOR, used_vectors); |
898 | #endif | 886 | #endif |