p5.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * P5 specific Machine Check Exception Reporting
  4. * (C) Copyright 2002 Alan Cox <[email protected]>
  5. */
  6. #include <linux/interrupt.h>
  7. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/smp.h>
  10. #include <linux/hardirq.h>
  11. #include <asm/processor.h>
  12. #include <asm/traps.h>
  13. #include <asm/tlbflush.h>
  14. #include <asm/mce.h>
  15. #include <asm/msr.h>
  16. #include "internal.h"
  17. /* By default disabled */
  18. int mce_p5_enabled __read_mostly;
  19. /* Machine check handler for Pentium class Intel CPUs: */
  20. noinstr void pentium_machine_check(struct pt_regs *regs)
  21. {
  22. u32 loaddr, hi, lotype;
  23. instrumentation_begin();
  24. rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi);
  25. rdmsr(MSR_IA32_P5_MC_TYPE, lotype, hi);
  26. pr_emerg("CPU#%d: Machine Check Exception: 0x%8X (type 0x%8X).\n",
  27. smp_processor_id(), loaddr, lotype);
  28. if (lotype & (1<<5)) {
  29. pr_emerg("CPU#%d: Possible thermal failure (CPU on fire ?).\n",
  30. smp_processor_id());
  31. }
  32. add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
  33. instrumentation_end();
  34. }
  35. /* Set up machine check reporting for processors with Intel style MCE: */
  36. void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
  37. {
  38. u32 l, h;
  39. /* Default P5 to off as its often misconnected: */
  40. if (!mce_p5_enabled)
  41. return;
  42. /* Check for MCE support: */
  43. if (!cpu_has(c, X86_FEATURE_MCE))
  44. return;
  45. /* Read registers before enabling: */
  46. rdmsr(MSR_IA32_P5_MC_ADDR, l, h);
  47. rdmsr(MSR_IA32_P5_MC_TYPE, l, h);
  48. pr_info("Intel old style machine check architecture supported.\n");
  49. /* Enable MCE: */
  50. cr4_set_bits(X86_CR4_MCE);
  51. pr_info("Intel old style machine check reporting enabled on CPU#%d.\n",
  52. smp_processor_id());
  53. }