mce.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * mce.c - x86 Machine Check Exception Reporting
  3. * (c) 2002 Alan Cox <alan@redhat.com>, Dave Jones <davej@codemonkey.org.uk>
  4. */
  5. #include <linux/init.h>
  6. #include <linux/types.h>
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/smp.h>
  10. #include <linux/thread_info.h>
  11. #include <asm/processor.h>
  12. #include <asm/system.h>
  13. #include <asm/mce.h>
  14. #include "mce.h"
  15. int mce_disabled = 0;
  16. int nr_mce_banks;
  17. EXPORT_SYMBOL_GPL(nr_mce_banks); /* non-fatal.o */
  18. /* Handle unconfigured int18 (should never happen) */
  19. static fastcall void unexpected_machine_check(struct pt_regs * regs, long error_code)
  20. {
  21. printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", smp_processor_id());
  22. }
  23. /* Call the installed machine check handler for this CPU setup. */
  24. void fastcall (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
  25. /* This has to be run for each processor */
  26. void mcheck_init(struct cpuinfo_x86 *c)
  27. {
  28. if (mce_disabled==1)
  29. return;
  30. switch (c->x86_vendor) {
  31. case X86_VENDOR_AMD:
  32. amd_mcheck_init(c);
  33. break;
  34. case X86_VENDOR_INTEL:
  35. if (c->x86==5)
  36. intel_p5_mcheck_init(c);
  37. if (c->x86==6)
  38. intel_p6_mcheck_init(c);
  39. if (c->x86==15)
  40. intel_p4_mcheck_init(c);
  41. break;
  42. case X86_VENDOR_CENTAUR:
  43. if (c->x86==5)
  44. winchip_mcheck_init(c);
  45. break;
  46. default:
  47. break;
  48. }
  49. }
  50. static unsigned long old_cr4 __initdata;
  51. void __init stop_mce(void)
  52. {
  53. old_cr4 = read_cr4();
  54. clear_in_cr4(X86_CR4_MCE);
  55. }
  56. void __init restart_mce(void)
  57. {
  58. if (old_cr4 & X86_CR4_MCE)
  59. set_in_cr4(X86_CR4_MCE);
  60. }
  61. static int __init mcheck_disable(char *str)
  62. {
  63. mce_disabled = 1;
  64. return 1;
  65. }
  66. static int __init mcheck_enable(char *str)
  67. {
  68. mce_disabled = -1;
  69. return 1;
  70. }
  71. __setup("nomce", mcheck_disable);
  72. __setup("mce", mcheck_enable);