~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/arch/x86/cpu/mcheck/k7.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Athlon/Hammer specific Machine Check Exception Reporting
 
3
 * (C) Copyright 2002 Dave Jones <davej@codemonkey.org.uk>
 
4
 */
 
5
 
 
6
#include <xen/init.h>
 
7
#include <xen/types.h>
 
8
#include <xen/kernel.h>
 
9
#include <xen/config.h>
 
10
#include <xen/smp.h>
 
11
 
 
12
#include <asm/processor.h> 
 
13
#include <asm/system.h>
 
14
#include <asm/msr.h>
 
15
 
 
16
#include "mce.h"
 
17
#include "x86_mca.h"
 
18
 
 
19
/* Machine Check Handler For AMD Athlon/Duron */
 
20
static fastcall void k7_machine_check(struct cpu_user_regs * regs, long error_code)
 
21
{
 
22
        int recover=1;
 
23
        u32 alow, ahigh, high, low;
 
24
        u32 mcgstl, mcgsth;
 
25
        int i;
 
26
 
 
27
        rdmsr (MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
 
28
        if (mcgstl & (1<<0))    /* Recoverable ? */
 
29
                recover=0;
 
30
 
 
31
        printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
 
32
                smp_processor_id(), mcgsth, mcgstl);
 
33
 
 
34
        for (i=1; i<nr_mce_banks; i++) {
 
35
                rdmsr (MSR_IA32_MC0_STATUS+i*4,low, high);
 
36
                if (high&(1<<31)) {
 
37
                        if (high & (1<<29))
 
38
                                recover |= 1;
 
39
                        if (high & (1<<25))
 
40
                                recover |= 2;
 
41
                        printk (KERN_EMERG "Bank %d: %08x%08x", i, high, low);
 
42
                        high &= ~(1<<31);
 
43
                        if (high & (1<<27)) {
 
44
                                rdmsr (MSR_IA32_MC0_MISC+i*4, alow, ahigh);
 
45
                                printk ("[%08x%08x]", ahigh, alow);
 
46
                        }
 
47
                        if (high & (1<<26)) {
 
48
                                rdmsr (MSR_IA32_MC0_ADDR+i*4, alow, ahigh);
 
49
                                printk (" at %08x%08x", ahigh, alow);
 
50
                        }
 
51
                        printk ("\n");
 
52
                        /* Clear it */
 
53
                        wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
 
54
                        /* Serialize */
 
55
                        wmb();
 
56
                        add_taint(TAINT_MACHINE_CHECK);
 
57
                }
 
58
        }
 
59
 
 
60
        if (recover&2)
 
61
                mc_panic ("CPU context corrupt");
 
62
        if (recover&1)
 
63
                mc_panic ("Unable to continue");
 
64
        printk (KERN_EMERG "Attempting to continue.\n");
 
65
        mcgstl &= ~(1<<2);
 
66
        wrmsr (MSR_IA32_MCG_STATUS,mcgstl, mcgsth);
 
67
}
 
68
 
 
69
 
 
70
/* AMD K7 machine check */
 
71
enum mcheck_type amd_k7_mcheck_init(struct cpuinfo_x86 *c)
 
72
{
 
73
        u32 l, h;
 
74
        int i;
 
75
 
 
76
        /* Check for PPro style MCA; our caller has confirmed MCE support. */
 
77
        if (!cpu_has(c, X86_FEATURE_MCA))
 
78
                return mcheck_none;
 
79
 
 
80
        x86_mce_vector_register(k7_machine_check);
 
81
 
 
82
        rdmsr (MSR_IA32_MCG_CAP, l, h);
 
83
        if (l & (1<<8)) /* Control register present ? */
 
84
                wrmsr (MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
 
85
        nr_mce_banks = l & 0xff;
 
86
 
 
87
        /* Clear status for MC index 0 separately, we don't touch CTL,
 
88
         * as some Athlons cause spurious MCEs when its enabled. */
 
89
        wrmsr (MSR_IA32_MC0_STATUS, 0x0, 0x0);
 
90
        for (i=1; i<nr_mce_banks; i++) {
 
91
                wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
 
92
                wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
 
93
        }
 
94
 
 
95
        set_in_cr4 (X86_CR4_MCE);
 
96
 
 
97
        return mcheck_amd_k7;
 
98
}