ia64/xen-unstable

changeset 17884:b55f6d42668d

x86: Must use a softirq to defer dom0 NMI
notification. tasklet_schedule() contains a spinlock and is unsafe in
NMI context.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 18 14:17:10 2008 +0100 (2008-06-18)
parents 52592af0204a
children 0034766b45c2 3da148fb7d9b
files xen/arch/x86/traps.c xen/include/asm-x86/softirq.h
line diff
     1.1 --- a/xen/arch/x86/traps.c	Wed Jun 18 11:55:34 2008 +0100
     1.2 +++ b/xen/arch/x86/traps.c	Wed Jun 18 14:17:10 2008 +0100
     1.3 @@ -2678,14 +2678,12 @@ asmlinkage void do_general_protection(st
     1.4      panic("GENERAL PROTECTION FAULT\n[error_code=%04x]\n", regs->error_code);
     1.5  }
     1.6  
     1.7 -static void nmi_action(unsigned long unused)
     1.8 +static void nmi_mce_softirq(void)
     1.9  {
    1.10      /* Only used to defer wakeup of dom0,vcpu0 to a safe (non-NMI) context. */
    1.11      vcpu_kick(dom0->vcpu[0]);
    1.12  }
    1.13  
    1.14 -static DECLARE_TASKLET(nmi_tasklet, nmi_action, 0);
    1.15 -
    1.16  static void nmi_dom0_report(unsigned int reason_idx)
    1.17  {
    1.18      struct domain *d;
    1.19 @@ -2696,8 +2694,9 @@ static void nmi_dom0_report(unsigned int
    1.20  
    1.21      set_bit(reason_idx, nmi_reason(d));
    1.22  
    1.23 +    /* Not safe to wake a vcpu here, or even to schedule a tasklet! */
    1.24      if ( !test_and_set_bool(v->nmi_pending) )
    1.25 -        tasklet_schedule(&nmi_tasklet); /* not safe to wake a vcpu here */
    1.26 +        raise_softirq(NMI_MCE_SOFTIRQ);
    1.27  }
    1.28  
    1.29  asmlinkage void mem_parity_error(struct cpu_user_regs *regs)
    1.30 @@ -2975,6 +2974,8 @@ void __init trap_init(void)
    1.31      percpu_traps_init();
    1.32  
    1.33      cpu_init();
    1.34 +
    1.35 +    open_softirq(NMI_MCE_SOFTIRQ, nmi_mce_softirq);
    1.36  }
    1.37  
    1.38  long register_guest_nmi_callback(unsigned long address)
     2.1 --- a/xen/include/asm-x86/softirq.h	Wed Jun 18 11:55:34 2008 +0100
     2.2 +++ b/xen/include/asm-x86/softirq.h	Wed Jun 18 14:17:10 2008 +0100
     2.3 @@ -1,6 +1,8 @@
     2.4  #ifndef __ASM_SOFTIRQ_H__
     2.5  #define __ASM_SOFTIRQ_H__
     2.6  
     2.7 -#define NR_ARCH_SOFTIRQS    0
     2.8 +#define NMI_MCE_SOFTIRQ     (NR_COMMON_SOFTIRQS + 0)
     2.9 +
    2.10 +#define NR_ARCH_SOFTIRQS    1
    2.11  
    2.12  #endif /* __ASM_SOFTIRQ_H__ */