k7.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Athlon/Hammer specific Machine Check Exception Reporting
  3. * (C) Copyright 2002 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/config.h>
  9. #include <linux/irq.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/smp.h>
  12. #include <asm/processor.h>
  13. #include <asm/system.h>
  14. #include <asm/msr.h>
  15. #include "mce.h"
  16. /* Machine Check Handler For AMD Athlon/Duron */
  17. static fastcall void k7_machine_check(struct pt_regs * regs, long error_code)
  18. {
  19. int recover=1;
  20. u32 alow, ahigh, high, low;
  21. u32 mcgstl, mcgsth;
  22. int i;
  23. rdmsr (MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
  24. if (mcgstl & (1<<0)) /* Recoverable ? */
  25. recover=0;
  26. printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
  27. smp_processor_id(), mcgsth, mcgstl);
  28. for (i=1; i<nr_mce_banks; i++) {
  29. rdmsr (MSR_IA32_MC0_STATUS+i*4,low, high);
  30. if (high&(1<<31)) {
  31. if (high & (1<<29))
  32. recover |= 1;
  33. if (high & (1<<25))
  34. recover |= 2;
  35. printk (KERN_EMERG "Bank %d: %08x%08x", i, high, low);
  36. high &= ~(1<<31);
  37. if (high & (1<<27)) {
  38. rdmsr (MSR_IA32_MC0_MISC+i*4, alow, ahigh);
  39. printk ("[%08x%08x]", ahigh, alow);
  40. }
  41. if (high & (1<<26)) {
  42. rdmsr (MSR_IA32_MC0_ADDR+i*4, alow, ahigh);
  43. printk (" at %08x%08x", ahigh, alow);
  44. }
  45. printk ("\n");
  46. /* Clear it */
  47. wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
  48. /* Serialize */
  49. wmb();
  50. add_taint(TAINT_MACHINE_CHECK);
  51. }
  52. }
  53. if (recover&2)
  54. panic ("CPU context corrupt");
  55. if (recover&1)
  56. panic ("Unable to continue");
  57. printk (KERN_EMERG "Attempting to continue.\n");
  58. mcgstl &= ~(1<<2);
  59. wrmsr (MSR_IA32_MCG_STATUS,mcgstl, mcgsth);
  60. }
  61. /* AMD K7 machine check is Intel like */
  62. void __devinit amd_mcheck_init(struct cpuinfo_x86 *c)
  63. {
  64. u32 l, h;
  65. int i;
  66. machine_check_vector = k7_machine_check;
  67. wmb();
  68. printk (KERN_INFO "Intel machine check architecture supported.\n");
  69. rdmsr (MSR_IA32_MCG_CAP, l, h);
  70. if (l & (1<<8)) /* Control register present ? */
  71. wrmsr (MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
  72. nr_mce_banks = l & 0xff;
  73. /* Clear status for MC index 0 separately, we don't touch CTL,
  74. * as some Athlons cause spurious MCEs when its enabled. */
  75. wrmsr (MSR_IA32_MC0_STATUS, 0x0, 0x0);
  76. for (i=1; i<nr_mce_banks; i++) {
  77. wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
  78. wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
  79. }
  80. set_in_cr4 (X86_CR4_MCE);
  81. printk (KERN_INFO "Intel machine check reporting enabled on CPU#%d.\n",
  82. smp_processor_id());
  83. }