mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
60e019eb37
Reimplement FPU detection code in C and drop old, not-so-recommended detection method in asm. Move all the relevant stuff into i387.c where it conceptually belongs. Finally drop cpuinfo_x86.hard_math. [ hpa: huge thanks to Borislav for taking my original concept patch and productizing it ] [ Boris, note to self: do not use static_cpu_has before alternatives! ] Signed-off-by: H. Peter Anvin <hpa@zytor.com> Link: http://lkml.kernel.org/r/1367244262-29511-2-git-send-email-bp@alien8.de Link: http://lkml.kernel.org/r/1365436666-9837-2-git-send-email-bp@alien8.de Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
94 lines
2.1 KiB
C
94 lines
2.1 KiB
C
/*
|
|
* Copyright (C) 1994 Linus Torvalds
|
|
*
|
|
* Cyrix stuff, June 1998 by:
|
|
* - Rafael R. Reilova (moved everything from head.S),
|
|
* <rreilova@ececs.uc.edu>
|
|
* - Channing Corn (tests & fixes),
|
|
* - Andrew D. Balsa (code cleanup).
|
|
*/
|
|
#include <linux/init.h>
|
|
#include <linux/utsname.h>
|
|
#include <asm/bugs.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/processor-flags.h>
|
|
#include <asm/i387.h>
|
|
#include <asm/msr.h>
|
|
#include <asm/paravirt.h>
|
|
#include <asm/alternative.h>
|
|
|
|
static double __initdata x = 4195835.0;
|
|
static double __initdata y = 3145727.0;
|
|
|
|
/*
|
|
* This used to check for exceptions..
|
|
* However, it turns out that to support that,
|
|
* the XMM trap handlers basically had to
|
|
* be buggy. So let's have a correct XMM trap
|
|
* handler, and forget about printing out
|
|
* some status at boot.
|
|
*
|
|
* We should really only care about bugs here
|
|
* anyway. Not features.
|
|
*/
|
|
static void __init check_fpu(void)
|
|
{
|
|
s32 fdiv_bug;
|
|
|
|
kernel_fpu_begin();
|
|
|
|
/*
|
|
* trap_init() enabled FXSR and company _before_ testing for FP
|
|
* problems here.
|
|
*
|
|
* Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug
|
|
*/
|
|
__asm__("fninit\n\t"
|
|
"fldl %1\n\t"
|
|
"fdivl %2\n\t"
|
|
"fmull %2\n\t"
|
|
"fldl %1\n\t"
|
|
"fsubp %%st,%%st(1)\n\t"
|
|
"fistpl %0\n\t"
|
|
"fwait\n\t"
|
|
"fninit"
|
|
: "=m" (*&fdiv_bug)
|
|
: "m" (*&x), "m" (*&y));
|
|
|
|
kernel_fpu_end();
|
|
|
|
if (fdiv_bug) {
|
|
set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
|
|
pr_warn("Hmm, FPU with FDIV bug\n");
|
|
}
|
|
}
|
|
|
|
void __init check_bugs(void)
|
|
{
|
|
identify_boot_cpu();
|
|
#ifndef CONFIG_SMP
|
|
pr_info("CPU: ");
|
|
print_cpu_info(&boot_cpu_data);
|
|
#endif
|
|
|
|
/*
|
|
* Check whether we are able to run this kernel safely on SMP.
|
|
*
|
|
* - i386 is no longer supported.
|
|
* - In order to run on anything without a TSC, we need to be
|
|
* compiled for a i486.
|
|
*/
|
|
if (boot_cpu_data.x86 < 4)
|
|
panic("Kernel requires i486+ for 'invlpg' and other features");
|
|
|
|
init_utsname()->machine[1] =
|
|
'0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
|
|
alternative_instructions();
|
|
|
|
/*
|
|
* kernel_fpu_begin/end() in check_fpu() relies on the patched
|
|
* alternative instructions.
|
|
*/
|
|
if (cpu_has_fpu)
|
|
check_fpu();
|
|
}
|