ia64/xen-unstable

changeset 18965:d0751463539a

x86, mce: Fix x86_mcinfo_getptr is called when no error found

The machine_check_poll() is called with mi which is set by
x86_mcinfo_getptr() everytime. But, I think it should not be called
when there is no error, because error_idx and fetch_idx cannot work
together.

Signed-off-by: Kazuhiro Suzuki <kaz@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Dec 29 14:03:26 2008 +0000 (2008-12-29)
parents 14a2c24eb94e
children e0301796fce8
files xen/arch/x86/cpu/mcheck/mce_intel.c
line diff
     1.1 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c	Mon Dec 29 14:00:45 2008 +0000
     1.2 +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c	Mon Dec 29 14:03:26 2008 +0000
     1.3 @@ -158,8 +158,9 @@ static inline void intel_get_extended_ms
     1.4   * It will generate a new mc_info item if found CE/UC errors. DOM0 is the 
     1.5   * consumer.
     1.6  */
     1.7 -static int machine_check_poll(struct mc_info *mi, int calltype)
     1.8 +static struct mc_info *machine_check_poll(int calltype)
     1.9  {
    1.10 +    struct mc_info *mi = NULL;
    1.11      int exceptions = (read_cr4() & X86_CR4_MCE);
    1.12      int i, nr_unit = 0, uc = 0, pcc = 0;
    1.13      uint64_t status, addr;
    1.14 @@ -170,12 +171,6 @@ static int machine_check_poll(struct mc_
    1.15  
    1.16      cpu = smp_processor_id();
    1.17  
    1.18 -    if (!mi) {
    1.19 -        printk(KERN_ERR "mcheck_poll: Failed to get mc_info entry\n");
    1.20 -        return 0;
    1.21 -    }
    1.22 -    x86_mcinfo_clear(mi);
    1.23 -
    1.24      memset(&mcg, 0, sizeof(mcg));
    1.25      mcg.common.type = MC_TYPE_GLOBAL;
    1.26      mcg.common.size = sizeof(mcg);
    1.27 @@ -217,6 +212,14 @@ static int machine_check_poll(struct mc_
    1.28          if (status & MCi_STATUS_PCC)
    1.29              pcc = 1;
    1.30  
    1.31 +        if (!mi) {
    1.32 +            mi = x86_mcinfo_getptr();
    1.33 +            if (!mi) {
    1.34 +                printk(KERN_ERR "mcheck_poll: Failed to get mc_info entry\n");
    1.35 +                return NULL;
    1.36 +            }
    1.37 +            x86_mcinfo_clear(mi);
    1.38 +        }
    1.39          memset(&mcb, 0, sizeof(mcb));
    1.40          mcb.common.type = MC_TYPE_BANK;
    1.41          mcb.common.size = sizeof(mcb);
    1.42 @@ -262,7 +265,7 @@ static int machine_check_poll(struct mc_
    1.43      if (nr_unit) 
    1.44          x86_mcinfo_add(mi, &mcg);
    1.45      /*Clear global state*/
    1.46 -    return nr_unit;
    1.47 +    return mi;
    1.48  }
    1.49  
    1.50  static fastcall void intel_machine_check(struct cpu_user_regs * regs, long error_code)
    1.51 @@ -478,15 +481,14 @@ static void intel_init_cmci(struct cpuin
    1.52  
    1.53  fastcall void smp_cmci_interrupt(struct cpu_user_regs *regs)
    1.54  {
    1.55 -    int nr_unit;
    1.56 -    struct mc_info *mi =  x86_mcinfo_getptr();
    1.57 +    struct mc_info *mi = NULL;
    1.58      int cpu = smp_processor_id();
    1.59  
    1.60      ack_APIC_irq();
    1.61      irq_enter();
    1.62      printk(KERN_DEBUG "CMCI: cmci_intr happen on CPU%d\n", cpu);
    1.63 -    nr_unit = machine_check_poll(mi, MC_FLAG_CMCI);
    1.64 -    if (nr_unit) {
    1.65 +    mi = machine_check_poll(MC_FLAG_CMCI);
    1.66 +    if (mi) {
    1.67          x86_mcinfo_dump(mi);
    1.68          if (dom0 && guest_enabled_event(dom0->vcpu[0], VIRQ_MCA))
    1.69              send_guest_global_virq(dom0, VIRQ_MCA);
    1.70 @@ -532,16 +534,16 @@ static void mce_cap_init(struct cpuinfo_
    1.71  static void mce_init(void)
    1.72  {
    1.73      u32 l, h;
    1.74 -    int i, nr_unit;
    1.75 -    struct mc_info *mi =  x86_mcinfo_getptr();
    1.76 +    int i;
    1.77 +    struct mc_info *mi;
    1.78      clear_in_cr4(X86_CR4_MCE);
    1.79      /* log the machine checks left over from the previous reset.
    1.80       * This also clears all registers*/
    1.81  
    1.82 -    nr_unit = machine_check_poll(mi, MC_FLAG_RESET);
    1.83 +    mi = machine_check_poll(MC_FLAG_RESET);
    1.84      /*in the boot up stage, not expect inject to DOM0, but go print out
    1.85      */
    1.86 -    if (nr_unit > 0)
    1.87 +    if (mi)
    1.88          x86_mcinfo_dump(mi);
    1.89  
    1.90      set_in_cr4(X86_CR4_MCE);
    1.91 @@ -595,13 +597,12 @@ static int adjust = 0;
    1.92  
    1.93  static void mce_intel_checkregs(void *info)
    1.94  {
    1.95 -    int nr_unit;
    1.96 -    struct mc_info *mi =  x86_mcinfo_getptr();
    1.97 +    struct mc_info *mi;
    1.98  
    1.99      if( !mce_available(&current_cpu_data))
   1.100          return;
   1.101 -    nr_unit = machine_check_poll(mi, MC_FLAG_POLLED);
   1.102 -    if (nr_unit)
   1.103 +    mi = machine_check_poll(MC_FLAG_POLLED);
   1.104 +    if (mi)
   1.105      {
   1.106          x86_mcinfo_dump(mi);
   1.107          adjust++;