summaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2016-04-04 16:24:58 -0400
committerIngo Molnar <mingo@kernel.org>2016-04-13 05:37:40 -0400
commita402a8dffc9f838b413c5ee0317d2d3184968f5b (patch)
treee6e77be1294c7a073dfb7041d1da1ee38967d4bb /arch/x86/kernel
parentdda9edf7c1fdc0d7a7ed7f46299a26282190fb6d (diff)
x86/cpufeature: Replace cpu_has_fpu with boot_cpu_has() usage
Use static_cpu_has() in the timing-sensitive paths in fpstate_init() and fpu__copy(). While at it, simplify the use in init_cyrix() and get rid of the ternary operator. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1459801503-15600-6-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/cpu/cyrix.c2
-rw-r--r--arch/x86/kernel/fpu/bugs.c2
-rw-r--r--arch/x86/kernel/fpu/core.c4
-rw-r--r--arch/x86/kernel/fpu/init.c8
4 files changed, 8 insertions, 8 deletions
diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index 6adef9cac23e..bd9dcd6b712d 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -333,7 +333,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)
333 switch (dir0_lsn) { 333 switch (dir0_lsn) {
334 case 0xd: /* either a 486SLC or DLC w/o DEVID */ 334 case 0xd: /* either a 486SLC or DLC w/o DEVID */
335 dir0_msn = 0; 335 dir0_msn = 0;
336 p = Cx486_name[(cpu_has_fpu ? 1 : 0)]; 336 p = Cx486_name[!!boot_cpu_has(X86_FEATURE_FPU)];
337 break; 337 break;
338 338
339 case 0xe: /* a 486S A step */ 339 case 0xe: /* a 486S A step */
diff --git a/arch/x86/kernel/fpu/bugs.c b/arch/x86/kernel/fpu/bugs.c
index dd9ca9b60ff3..224b5ec52195 100644
--- a/arch/x86/kernel/fpu/bugs.c
+++ b/arch/x86/kernel/fpu/bugs.c
@@ -66,6 +66,6 @@ void __init fpu__init_check_bugs(void)
66 * kernel_fpu_begin/end() in check_fpu() relies on the patched 66 * kernel_fpu_begin/end() in check_fpu() relies on the patched
67 * alternative instructions. 67 * alternative instructions.
68 */ 68 */
69 if (cpu_has_fpu) 69 if (boot_cpu_has(X86_FEATURE_FPU))
70 check_fpu(); 70 check_fpu();
71} 71}
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index b05aa68f88c0..0e7859f9aedc 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -217,7 +217,7 @@ static inline void fpstate_init_fstate(struct fregs_state *fp)
217 217
218void fpstate_init(union fpregs_state *state) 218void fpstate_init(union fpregs_state *state)
219{ 219{
220 if (!cpu_has_fpu) { 220 if (!static_cpu_has(X86_FEATURE_FPU)) {
221 fpstate_init_soft(&state->soft); 221 fpstate_init_soft(&state->soft);
222 return; 222 return;
223 } 223 }
@@ -237,7 +237,7 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
237 dst_fpu->fpregs_active = 0; 237 dst_fpu->fpregs_active = 0;
238 dst_fpu->last_cpu = -1; 238 dst_fpu->last_cpu = -1;
239 239
240 if (!src_fpu->fpstate_active || !cpu_has_fpu) 240 if (!src_fpu->fpstate_active || !static_cpu_has(X86_FEATURE_FPU))
241 return 0; 241 return 0;
242 242
243 WARN_ON_FPU(src_fpu != &current->thread.fpu); 243 WARN_ON_FPU(src_fpu != &current->thread.fpu);
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 9bbb332a71ff..3a84275f012e 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -38,13 +38,13 @@ static void fpu__init_cpu_generic(void)
38 38
39 cr0 = read_cr0(); 39 cr0 = read_cr0();
40 cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */ 40 cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */
41 if (!cpu_has_fpu) 41 if (!boot_cpu_has(X86_FEATURE_FPU))
42 cr0 |= X86_CR0_EM; 42 cr0 |= X86_CR0_EM;
43 write_cr0(cr0); 43 write_cr0(cr0);
44 44
45 /* Flush out any pending x87 state: */ 45 /* Flush out any pending x87 state: */
46#ifdef CONFIG_MATH_EMULATION 46#ifdef CONFIG_MATH_EMULATION
47 if (!cpu_has_fpu) 47 if (!boot_cpu_has(X86_FEATURE_FPU))
48 fpstate_init_soft(&current->thread.fpu.state.soft); 48 fpstate_init_soft(&current->thread.fpu.state.soft);
49 else 49 else
50#endif 50#endif
@@ -89,7 +89,7 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
89 } 89 }
90 90
91#ifndef CONFIG_MATH_EMULATION 91#ifndef CONFIG_MATH_EMULATION
92 if (!cpu_has_fpu) { 92 if (!boot_cpu_has(X86_FEATURE_FPU)) {
93 pr_emerg("x86/fpu: Giving up, no FPU found and no math emulation present\n"); 93 pr_emerg("x86/fpu: Giving up, no FPU found and no math emulation present\n");
94 for (;;) 94 for (;;)
95 asm volatile("hlt"); 95 asm volatile("hlt");
@@ -212,7 +212,7 @@ static void __init fpu__init_system_xstate_size_legacy(void)
212 * fpu__init_system_xstate(). 212 * fpu__init_system_xstate().
213 */ 213 */
214 214
215 if (!cpu_has_fpu) { 215 if (!boot_cpu_has(X86_FEATURE_FPU)) {
216 /* 216 /*
217 * Disable xsave as we do not support it if i387 217 * Disable xsave as we do not support it if i387
218 * emulation is enabled. 218 * emulation is enabled.