diff options
Diffstat (limited to 'arch/x86/kernel/cpu/bugs.c')
| -rw-r--r-- | arch/x86/kernel/cpu/bugs.c | 125 | 
1 files changed, 25 insertions, 100 deletions
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index c39576cb301..03445346ee0 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -17,23 +17,6 @@  #include <asm/paravirt.h>  #include <asm/alternative.h> -static int __init no_halt(char *s) -{ -	boot_cpu_data.hlt_works_ok = 0; -	return 1; -} - -__setup("no-hlt", no_halt); - -static int __init no_387(char *s) -{ -	boot_cpu_data.hard_math = 0; -	write_cr0(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP | read_cr0()); -	return 1; -} - -__setup("no387", no_387); -  static double __initdata x = 4195835.0;  static double __initdata y = 3145727.0; @@ -52,20 +35,13 @@ static void __init check_fpu(void)  {  	s32 fdiv_bug; -	if (!boot_cpu_data.hard_math) { -#ifndef CONFIG_MATH_EMULATION -		printk(KERN_EMERG "No coprocessor found and no math emulation present.\n"); -		printk(KERN_EMERG "Giving up.\n"); -		for (;;) ; -#endif -		return; -	} +	kernel_fpu_begin();  	/*  	 * trap_init() enabled FXSR and company _before_ testing for FP  	 * problems here.  	 * -	 * Test for the divl bug.. +	 * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug  	 */  	__asm__("fninit\n\t"  		"fldl %1\n\t" @@ -79,91 +55,40 @@ static void __init check_fpu(void)  		: "=m" (*&fdiv_bug)  		: "m" (*&x), "m" (*&y)); -	boot_cpu_data.fdiv_bug = fdiv_bug; -	if (boot_cpu_data.fdiv_bug) -		printk(KERN_WARNING "Hmm, FPU with FDIV bug.\n"); -} - -static void __init check_hlt(void) -{ -	if (boot_cpu_data.x86 >= 5 || paravirt_enabled()) -		return; +	kernel_fpu_end(); -	printk(KERN_INFO "Checking 'hlt' instruction... "); -	if (!boot_cpu_data.hlt_works_ok) { -		printk("disabled\n"); -		return; +	if (fdiv_bug) { +		set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV); +		pr_warn("Hmm, FPU with FDIV bug\n");  	} -	halt(); -	halt(); -	halt(); -	halt(); -	printk(KERN_CONT "OK.\n"); -} - -/* - *	Most 386 processors have a bug where a POPAD can lock the - *	machine even from user space. - */ - -static void __init check_popad(void) -{ -#ifndef CONFIG_X86_POPAD_OK -	int res, inp = (int) &res; - -	printk(KERN_INFO "Checking for popad bug... "); -	__asm__ __volatile__( -	  "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx " -	  : "=&a" (res) -	  : "d" (inp) -	  : "ecx", "edi"); -	/* -	 * If this fails, it means that any user program may lock the -	 * CPU hard. Too bad. -	 */ -	if (res != 12345678) -		printk(KERN_CONT "Buggy.\n"); -	else -		printk(KERN_CONT "OK.\n"); -#endif -} - -/* - * Check whether we are able to run this kernel safely on SMP. - * - * - In order to run on a i386, we need to be compiled for i386 - *   (for due to lack of "invlpg" and working WP on a i386) - * - In order to run on anything without a TSC, we need to be - *   compiled for a i486. - */ - -static void __init check_config(void) -{ -/* - * We'd better not be a i386 if we're configured to use some - * i486+ only features! (WP works in supervisor mode and the - * new "invlpg" and "bswap" instructions) - */ -#if defined(CONFIG_X86_WP_WORKS_OK) || defined(CONFIG_X86_INVLPG) || \ -	defined(CONFIG_X86_BSWAP) -	if (boot_cpu_data.x86 == 3) -		panic("Kernel requires i486+ for 'invlpg' and other features"); -#endif  } -  void __init check_bugs(void)  {  	identify_boot_cpu();  #ifndef CONFIG_SMP -	printk(KERN_INFO "CPU: "); +	pr_info("CPU: ");  	print_cpu_info(&boot_cpu_data);  #endif -	check_config(); -	check_fpu(); -	check_hlt(); -	check_popad(); + +	/* +	 * 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();  }  | 
