p5.c 1.7 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0
L
Linus Torvalds 已提交
2 3
/*
 * P5 specific Machine Check Exception Reporting
4
 * (C) Copyright 2002 Alan Cox <alan@lxorguk.ukuu.org.uk>
L
Linus Torvalds 已提交
5 6
 */
#include <linux/interrupt.h>
I
Ingo Molnar 已提交
7 8
#include <linux/kernel.h>
#include <linux/types.h>
L
Linus Torvalds 已提交
9 10
#include <linux/smp.h>

11
#include <asm/processor.h>
12
#include <asm/traps.h>
A
Andy Lutomirski 已提交
13
#include <asm/tlbflush.h>
H
Hidetoshi Seto 已提交
14
#include <asm/mce.h>
L
Linus Torvalds 已提交
15 16
#include <asm/msr.h>

17
/* By default disabled */
18
int mce_p5_enabled __read_mostly;
19

I
Ingo Molnar 已提交
20
/* Machine check handler for Pentium class Intel CPUs: */
21
static void pentium_machine_check(struct pt_regs *regs, long error_code)
L
Linus Torvalds 已提交
22 23
{
	u32 loaddr, hi, lotype;
I
Ingo Molnar 已提交
24

25
	ist_enter(regs);
26

L
Linus Torvalds 已提交
27 28
	rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi);
	rdmsr(MSR_IA32_P5_MC_TYPE, lotype, hi);
I
Ingo Molnar 已提交
29

30 31
	pr_emerg("CPU#%d: Machine Check Exception:  0x%8X (type 0x%8X).\n",
		 smp_processor_id(), loaddr, lotype);
I
Ingo Molnar 已提交
32 33

	if (lotype & (1<<5)) {
34 35
		pr_emerg("CPU#%d: Possible thermal failure (CPU on fire ?).\n",
			 smp_processor_id());
I
Ingo Molnar 已提交
36 37
	}

38
	add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
39

40
	ist_exit(regs);
L
Linus Torvalds 已提交
41 42
}

I
Ingo Molnar 已提交
43
/* Set up machine check reporting for processors with Intel style MCE: */
S
Shaohua Li 已提交
44
void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
L
Linus Torvalds 已提交
45 46
{
	u32 l, h;
47

48 49
	/* Default P5 to off as its often misconnected: */
	if (!mce_p5_enabled)
50
		return;
L
Linus Torvalds 已提交
51

52 53
	/* Check for MCE support: */
	if (!cpu_has(c, X86_FEATURE_MCE))
L
Linus Torvalds 已提交
54
		return;
I
Ingo Molnar 已提交
55

L
Linus Torvalds 已提交
56
	machine_check_vector = pentium_machine_check;
I
Ingo Molnar 已提交
57
	/* Make sure the vector pointer is visible before we enable MCEs: */
L
Linus Torvalds 已提交
58 59
	wmb();

I
Ingo Molnar 已提交
60
	/* Read registers before enabling: */
L
Linus Torvalds 已提交
61 62
	rdmsr(MSR_IA32_P5_MC_ADDR, l, h);
	rdmsr(MSR_IA32_P5_MC_TYPE, l, h);
63
	pr_info("Intel old style machine check architecture supported.\n");
L
Linus Torvalds 已提交
64

I
Ingo Molnar 已提交
65
	/* Enable MCE: */
A
Andy Lutomirski 已提交
66
	cr4_set_bits(X86_CR4_MCE);
67 68
	pr_info("Intel old style machine check reporting enabled on CPU#%d.\n",
		smp_processor_id());
L
Linus Torvalds 已提交
69
}