p6.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * P6 specific Machine Check Exception Reporting
  3. * (C) Copyright 2002 Alan Cox <alan@redhat.com>
  4. */
  5. #include <linux/init.h>
  6. #include <linux/types.h>
  7. #include <linux/kernel.h>
  8. #include <linux/irq.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/smp.h>
  11. #include <asm/processor.h>
  12. #include <asm/system.h>
  13. #include <asm/msr.h>
  14. #include "mce.h"
  15. /* Machine Check Handler For PII/PIII */
  16. static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
  17. {
  18. int recover=1;
  19. u32 alow, ahigh, high, low;
  20. u32 mcgstl, mcgsth;
  21. int i;
  22. rdmsr (MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
  23. if (mcgstl & (1<<0)) /* Recoverable ? */
  24. recover=0;
  25. printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
  26. smp_processor_id(), mcgsth, mcgstl);
  27. for (i=0; i<nr_mce_banks; i++) {
  28. rdmsr (MSR_IA32_MC0_STATUS+i*4,low, high);
  29. if (high & (1<<31)) {
  30. if (high & (1<<29))
  31. recover |= 1;
  32. if (high & (1<<25))
  33. recover |= 2;
  34. printk (KERN_EMERG "Bank %d: %08x%08x", i, high, low);
  35. high &= ~(1<<31);
  36. if (high & (1<<27)) {
  37. rdmsr (MSR_IA32_MC0_MISC+i*4, alow, ahigh);
  38. printk ("[%08x%08x]", ahigh, alow);
  39. }
  40. if (high & (1<<26)) {
  41. rdmsr (MSR_IA32_MC0_ADDR+i*4, alow, ahigh);
  42. printk (" at %08x%08x", ahigh, alow);
  43. }
  44. printk ("\n");
  45. }
  46. }
  47. if (recover & 2)
  48. panic ("CPU context corrupt");
  49. if (recover & 1)
  50. panic ("Unable to continue");
  51. printk (KERN_EMERG "Attempting to continue.\n");
  52. /*
  53. * Do not clear the MSR_IA32_MCi_STATUS if the error is not
  54. * recoverable/continuable.This will allow BIOS to look at the MSRs
  55. * for errors if the OS could not log the error.
  56. */
  57. for (i=0; i<nr_mce_banks; i++) {
  58. unsigned int msr;
  59. msr = MSR_IA32_MC0_STATUS+i*4;
  60. rdmsr (msr,low, high);
  61. if (high & (1<<31)) {
  62. /* Clear it */
  63. wrmsr (msr, 0UL, 0UL);
  64. /* Serialize */
  65. wmb();
  66. add_taint(TAINT_MACHINE_CHECK);
  67. }
  68. }
  69. mcgstl &= ~(1<<2);
  70. wrmsr (MSR_IA32_MCG_STATUS,mcgstl, mcgsth);
  71. }
  72. /* Set up machine check reporting for processors with Intel style MCE */
  73. void __devinit intel_p6_mcheck_init(struct cpuinfo_x86 *c)
  74. {
  75. u32 l, h;
  76. int i;
  77. /* Check for MCE support */
  78. if (!cpu_has(c, X86_FEATURE_MCE))
  79. return;
  80. /* Check for PPro style MCA */
  81. if (!cpu_has(c, X86_FEATURE_MCA))
  82. return;
  83. /* Ok machine check is available */
  84. machine_check_vector = intel_machine_check;
  85. wmb();
  86. printk (KERN_INFO "Intel machine check architecture supported.\n");
  87. rdmsr (MSR_IA32_MCG_CAP, l, h);
  88. if (l & (1<<8)) /* Control register present ? */
  89. wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
  90. nr_mce_banks = l & 0xff;
  91. /* Don't enable bank 0 on intel P6 cores, it goes bang quickly. */
  92. for (i=1; i<nr_mce_banks; i++) {
  93. wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
  94. wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
  95. }
  96. set_in_cr4 (X86_CR4_MCE);
  97. printk (KERN_INFO "Intel machine check reporting enabled on CPU#%d.\n",
  98. smp_processor_id());
  99. }