forked from Minki/linux
fc560a80ba
fpu__init_check_bugs() runs long after the early FPU init, so CR0.TS will be clear by the time it runs. The save-and-restore dance would have been unnecessary anyway, though, as kernel_fpu_begin() would have been good enough. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com> Cc: Rik van Riel <riel@redhat.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: kvm list <kvm@vger.kernel.org> Link: http://lkml.kernel.org/r/76d1f1eacb5caead98197d1eb50ac6110ab20c6a.1477951965.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
/*
|
|
* x86 FPU bug checks:
|
|
*/
|
|
#include <asm/fpu/internal.h>
|
|
|
|
/*
|
|
* Boot time CPU/FPU FDIV bug detection code:
|
|
*/
|
|
|
|
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.
|
|
*/
|
|
void __init fpu__init_check_bugs(void)
|
|
{
|
|
s32 fdiv_bug;
|
|
|
|
/* kernel_fpu_begin/end() relies on patched alternative instructions. */
|
|
if (!boot_cpu_has(X86_FEATURE_FPU))
|
|
return;
|
|
|
|
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");
|
|
}
|
|
}
|