bugs.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 1994 Linus Torvalds
  3. *
  4. * Cyrix stuff, June 1998 by:
  5. * - Rafael R. Reilova (moved everything from head.S),
  6. * <rreilova@ececs.uc.edu>
  7. * - Channing Corn (tests & fixes),
  8. * - Andrew D. Balsa (code cleanup).
  9. */
  10. #include <linux/init.h>
  11. #include <linux/utsname.h>
  12. #include <asm/bugs.h>
  13. #include <asm/processor.h>
  14. #include <asm/processor-flags.h>
  15. #include <asm/i387.h>
  16. #include <asm/msr.h>
  17. #include <asm/paravirt.h>
  18. #include <asm/alternative.h>
  19. static double __initdata x = 4195835.0;
  20. static double __initdata y = 3145727.0;
  21. /*
  22. * This used to check for exceptions..
  23. * However, it turns out that to support that,
  24. * the XMM trap handlers basically had to
  25. * be buggy. So let's have a correct XMM trap
  26. * handler, and forget about printing out
  27. * some status at boot.
  28. *
  29. * We should really only care about bugs here
  30. * anyway. Not features.
  31. */
  32. static void __init check_fpu(void)
  33. {
  34. s32 fdiv_bug;
  35. kernel_fpu_begin();
  36. /*
  37. * trap_init() enabled FXSR and company _before_ testing for FP
  38. * problems here.
  39. *
  40. * Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug
  41. */
  42. __asm__("fninit\n\t"
  43. "fldl %1\n\t"
  44. "fdivl %2\n\t"
  45. "fmull %2\n\t"
  46. "fldl %1\n\t"
  47. "fsubp %%st,%%st(1)\n\t"
  48. "fistpl %0\n\t"
  49. "fwait\n\t"
  50. "fninit"
  51. : "=m" (*&fdiv_bug)
  52. : "m" (*&x), "m" (*&y));
  53. kernel_fpu_end();
  54. if (fdiv_bug) {
  55. set_cpu_bug(&boot_cpu_data, X86_BUG_FDIV);
  56. pr_warn("Hmm, FPU with FDIV bug\n");
  57. }
  58. }
  59. void __init check_bugs(void)
  60. {
  61. identify_boot_cpu();
  62. #ifndef CONFIG_SMP
  63. pr_info("CPU: ");
  64. print_cpu_info(&boot_cpu_data);
  65. #endif
  66. /*
  67. * Check whether we are able to run this kernel safely on SMP.
  68. *
  69. * - i386 is no longer supported.
  70. * - In order to run on anything without a TSC, we need to be
  71. * compiled for a i486.
  72. */
  73. if (boot_cpu_data.x86 < 4)
  74. panic("Kernel requires i486+ for 'invlpg' and other features");
  75. init_utsname()->machine[1] =
  76. '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
  77. alternative_instructions();
  78. /*
  79. * kernel_fpu_begin/end() in check_fpu() relies on the patched
  80. * alternative instructions.
  81. */
  82. if (cpu_has_fpu)
  83. check_fpu();
  84. }