ia64/xen-unstable

changeset 2047:4ab908608402

bitkeeper revision 1.1108.33.42 (410f6f3aRsLN-XTc0i2kCrGt2plvhw)

More NMI-handling cleanups. Users now have an option of what to do
with an error NMI by specifying 'nmi=xxx' on Xen's cmdline.
'nmi=dom0' -> Tell DOM0 about it (DOM0 currently ignores it).
'nmi=ignore' -> ignore it
'nmi=fatal' -> print a diagnostic and then hang.
author kaf24@scramble.cl.cam.ac.uk
date Tue Aug 03 10:55:54 2004 +0000 (2004-08-03)
parents 37da92a66bd8
children ebaca727e2a7 7831e606f604 3c9be01ca154
files README.CD docs/HOWTOs/Xen-HOWTO docs/user.tex xen/arch/x86/traps.c xen/arch/x86/x86_32/entry.S xen/common/kernel.c xen/include/hypervisor-ifs/hypervisor-if.h xen/include/xen/softirq.h
line diff
     1.1 --- a/README.CD	Tue Aug 03 09:36:46 2004 +0000
     1.2 +++ b/README.CD	Tue Aug 03 10:55:54 2004 +0000
     1.3 @@ -277,10 +277,6 @@ that may be able to help diagnose proble
     1.4  
     1.5   noht		  Disable Hyperthreading.
     1.6  
     1.7 - ifname=ethXX	  Select which Ethernet interface to use.
     1.8 -
     1.9 - ifname=dummy	  Don't use any network interface.
    1.10 -
    1.11   com1=<baud>,DPS[,<io_base>,<irq>]
    1.12   com2=<baud>,DPS[,<io_base>,<irq>]
    1.13                    Xen supports up to two 16550-compatible serial ports.
    1.14 @@ -317,6 +313,13 @@ that may be able to help diagnose proble
    1.15                    omitting the character, enables auto-switching.
    1.16   [NB. Default for this option is 'a']
    1.17  
    1.18 + nmi=<nmi-error-behaviour>
    1.19 +                  Specify what to do with an NMI parity or I/O error.
    1.20 +                  'nmi=fatal':  Xen prints a diagnostic and then hangs.
    1.21 +                  'nmi=dom0':   Inform DOM0 of the NMI.
    1.22 +                  'nmi=ignore': Ignore the NMI.
    1.23 + [NB. Default is 'dom0' ('fatal' for debug builds).]
    1.24 +
    1.25   dom0_mem=xxx 	  Set the initial amount of memory for domain0.
    1.26  
    1.27   pdb=xxx          Enable the pervasive debugger.  See docs/pdb.txt
     2.1 --- a/docs/HOWTOs/Xen-HOWTO	Tue Aug 03 09:36:46 2004 +0000
     2.2 +++ b/docs/HOWTOs/Xen-HOWTO	Tue Aug 03 10:55:54 2004 +0000
     2.3 @@ -223,10 +223,6 @@ The following is a list of command line 
     2.4  
     2.5   noht             Disable Hyperthreading.
     2.6  
     2.7 - ifname=ethXX     Select which Ethernet interface to use.
     2.8 -
     2.9 - ifname=dummy     Don't use any network interface.
    2.10 -
    2.11   com1=<baud>,DPS[,<io_base>,<irq>]
    2.12   com2=<baud>,DPS[,<io_base>,<irq>]
    2.13                    Xen supports up to two 16550-compatible serial ports.
    2.14 @@ -263,6 +259,13 @@ The following is a list of command line 
    2.15                    omitting the character, enables auto-switching.
    2.16   [NB. Default for this option is 'a']
    2.17  
    2.18 + nmi=<nmi-error-behaviour>
    2.19 +                  Specify what to do with an NMI parity or I/O error.
    2.20 +                  'nmi=fatal':  Xen prints a diagnostic and then hangs.
    2.21 +                  'nmi=dom0':   Inform DOM0 of the NMI.
    2.22 +                  'nmi=ignore': Ignore the NMI.
    2.23 + [NB. Default is 'dom0' ('fatal' for debug builds).]
    2.24 +
    2.25   dom0_mem=xxx     Set the maximum amount of memory for domain0.
    2.26  
    2.27   tbuf_size=xxx    Set the size of the per-cpu trace buffers, in pages
     3.1 --- a/docs/user.tex	Tue Aug 03 09:36:46 2004 +0000
     3.2 +++ b/docs/user.tex	Tue Aug 03 10:55:54 2004 +0000
     3.3 @@ -777,43 +777,43 @@ The available commands are as follows:
     3.4  \begin{description}
     3.5  \item[Atropos]             One of the CPU schedulers provided by Xen.
     3.6                             Atropos provides domains with absolute shares
     3.7 -			   of the CPU, with timeliness guarantees and a
     3.8 -			   mechanism for sharing out ``slack time''.
     3.9 +                           of the CPU, with timeliness guarantees and a
    3.10 +                           mechanism for sharing out ``slack time''.
    3.11  
    3.12  \item[BVT]                 The BVT scheduler is used to give propotional
    3.13                             fair shares of the CPU to domains.
    3.14  
    3.15  \item[Exokernel]           A minimal piece of privileged code, similar to
    3.16                             a {\bf microkernel} but providing a more
    3.17 -			   `hardware-like' interface to the tasks it
    3.18 -			   manages.  This is similar to a paravirtualising
    3.19 -			   VMM like {\bf Xen} but was designed as a new
    3.20 -			   operating system structure, rather than
    3.21 -			   specifically to run multiple conventional OSs.
    3.22 +                           `hardware-like' interface to the tasks it
    3.23 +                           manages.  This is similar to a paravirtualising
    3.24 +                           VMM like {\bf Xen} but was designed as a new
    3.25 +                           operating system structure, rather than
    3.26 +                           specifically to run multiple conventional OSs.
    3.27  
    3.28  \item[FBVT]                A derivative of the { \bf BVT } scheduler that
    3.29                             aims to give better fairness performance to IO
    3.30 -			   intensive domains in competition with CPU
    3.31 -			   intensive domains.
    3.32 +                           intensive domains in competition with CPU
    3.33 +                           intensive domains.
    3.34  
    3.35  \item[Domain]              A domain is the execution context that
    3.36                             contains a running { \bf virtual machine }.
    3.37 -			   The relationship between virtual machines
    3.38 -			   and domains on Xen is similar to that between
    3.39 -			   programs and processes in an operating
    3.40 -			   system: a virtual machine is a persistent
    3.41 -			   entity that resides on disk (somewhat like
    3.42 -			   a program).  When it is loaded for execution,
    3.43 -			   it runs in a domain.  Each domain has a
    3.44 -			   { \bf domain ID }.
    3.45 +                           The relationship between virtual machines
    3.46 +                           and domains on Xen is similar to that between
    3.47 +                           programs and processes in an operating
    3.48 +                           system: a virtual machine is a persistent
    3.49 +                           entity that resides on disk (somewhat like
    3.50 +                           a program).  When it is loaded for execution,
    3.51 +                           it runs in a domain.  Each domain has a
    3.52 +                           { \bf domain ID }.
    3.53  
    3.54  \item[Domain 0]            The first domain to be started on a Xen
    3.55                             machine.  Domain 0 is responsible for managing
    3.56 -			   the system.
    3.57 +                           the system.
    3.58  
    3.59  \item[Domain ID]           A unique identifier for a { \bf domain },
    3.60                             analagous to a process ID in an operating
    3.61 -			   system.  Apart from domain
    3.62 +                           system.  Apart from domain
    3.63  
    3.64  \item[Full virtualisation] An approach to virtualisation which
    3.65                             requires no modifications to the hosted
    3.66 @@ -822,18 +822,18 @@ The available commands are as follows:
    3.67  
    3.68  \item[Hypervisor]          An alternative term for { \bf VMM }, used
    3.69                             because it means ``beyond supervisor'',
    3.70 -			   since it is responsible for managing multiple
    3.71 -			   ``supervisor'' kernels.
    3.72 +                           since it is responsible for managing multiple
    3.73 +                           ``supervisor'' kernels.
    3.74  
    3.75  \item[Microkernel]         A small base of code running at the highest
    3.76                             hardware privilege level.  A microkernel is
    3.77 -			   responsible for sharing CPU and memory (and
    3.78 -			   sometimes other devices) between less
    3.79 -			   privileged tasks running on the system.
    3.80 -			   This is similar to a VMM, particularly a
    3.81 -			   {\bf paravirtualising} VMM but typically
    3.82 -			   addressing a different problem space and
    3.83 -			   providing different kind of interface.
    3.84 +                           responsible for sharing CPU and memory (and
    3.85 +                           sometimes other devices) between less
    3.86 +                           privileged tasks running on the system.
    3.87 +                           This is similar to a VMM, particularly a
    3.88 +                           {\bf paravirtualising} VMM but typically
    3.89 +                           addressing a different problem space and
    3.90 +                           providing different kind of interface.
    3.91  
    3.92  \item[NetBSD/Xen]          A port of NetBSD to the Xen architecture.
    3.93  
    3.94 @@ -853,12 +853,12 @@ The available commands are as follows:
    3.95  
    3.96  \item[VMM]                 Virtual Machine Monitor - the software that
    3.97                             allows multiple virtual machines to be
    3.98 -			   multiplexed on a single physical machine.
    3.99 +                           multiplexed on a single physical machine.
   3.100  
   3.101  \item[Xen]                 Xen is a paravirtualising virtual machine
   3.102                             monitor, developed primarily by the
   3.103 -			   Systems Research Group at the University
   3.104 -			   of Cambridge Computer Laboratory.
   3.105 +                           Systems Research Group at the University
   3.106 +                           of Cambridge Computer Laboratory.
   3.107  
   3.108  \item[XenLinux]            Official name for the port of the Linux kernel
   3.109                             that runs on Xen.
   3.110 @@ -1140,12 +1140,6 @@ editting \path{grub.conf}.
   3.111  {\bf noht } \\
   3.112   Disable Hyperthreading. \\
   3.113  
   3.114 -{\bf ifname=ethXX }\\ 
   3.115 - Select which Ethernet interface to use. \\
   3.116 -
   3.117 -{\bf ifname=dummy } \\
   3.118 - Don't use any network interface. \\
   3.119 -
   3.120  {\bf com1=$<$baud$>$,DPS[,$<$io\_base$>$,$<$irq$>$] \\
   3.121   com2=$<$baud$>$,DPS[,$<$io\_base$>$,$<$irq$>$] } \\
   3.122   Xen supports up to two 16550-compatible serial ports.
   3.123 @@ -1184,6 +1178,13 @@ editting \path{grub.conf}.
   3.124   omitting the character, enables auto-switching.
   3.125   [NB. Default for this option is 'a'] \\
   3.126  
   3.127 +{\bf nmi=xxx } \\
   3.128 + Specify what to do with an NMI parity or I/O error. \\
   3.129 + 'nmi=fatal':  Xen prints a diagnostic and then hangs. \\
   3.130 + 'nmi=dom0':   Inform DOM0 of the NMI. \\
   3.131 + 'nmi=ignore': Ignore the NMI. \\
   3.132 + [NB. Default is 'dom0' ('fatal' for debug builds).] \\
   3.133 +
   3.134  {\bf dom0\_mem=xxx } \\
   3.135   Set the maximum amount of memory for domain0. \\
   3.136  
     4.1 --- a/xen/arch/x86/traps.c	Tue Aug 03 09:36:46 2004 +0000
     4.2 +++ b/xen/arch/x86/traps.c	Tue Aug 03 10:55:54 2004 +0000
     4.3 @@ -36,9 +36,11 @@
     4.4  #include <xen/console.h>
     4.5  #include <asm/ptrace.h>
     4.6  #include <xen/delay.h>
     4.7 +#include <xen/event.h>
     4.8  #include <xen/spinlock.h>
     4.9  #include <xen/irq.h>
    4.10  #include <xen/perfc.h>
    4.11 +#include <xen/softirq.h>
    4.12  #include <asm/shadow.h>
    4.13  #include <asm/domain_page.h>
    4.14  #include <asm/system.h>
    4.15 @@ -52,6 +54,8 @@
    4.16  #include <asm/i387.h>
    4.17  #include <asm/pdb.h>
    4.18  
    4.19 +extern char opt_nmi[];
    4.20 +
    4.21  struct guest_trap_bounce guest_trap_bounce[NR_CPUS] = { { 0 } };
    4.22  
    4.23  #if defined(__i386__)
    4.24 @@ -472,16 +476,11 @@ asmlinkage void do_general_protection(st
    4.25      die("general protection fault", regs, error_code);
    4.26  }
    4.27  
    4.28 -asmlinkage void mem_parity_error(unsigned char reason, struct pt_regs *regs)
    4.29 +asmlinkage void mem_parity_error(struct pt_regs *regs)
    4.30  {
    4.31      console_force_unlock();
    4.32  
    4.33 -    printk("\n\nNMI received. Dazed and confused, but trying to continue\n");
    4.34 -    printk("You probably have a hardware problem with your RAM chips\n");
    4.35 -
    4.36 -    /* Clear and disable the memory parity error line. */
    4.37 -    reason = (reason & 0xf) | 4;
    4.38 -    outb(reason, 0x61);
    4.39 +    printk("\n\n");
    4.40  
    4.41      show_registers(regs);
    4.42  
    4.43 @@ -497,14 +496,11 @@ asmlinkage void mem_parity_error(unsigne
    4.44      for ( ; ; ) ;
    4.45  }
    4.46  
    4.47 -asmlinkage void io_check_error(unsigned char reason, struct pt_regs *regs)
    4.48 +asmlinkage void io_check_error(struct pt_regs *regs)
    4.49  {
    4.50      console_force_unlock();
    4.51  
    4.52 -    printk("\n\nNMI: IOCK error (debug interrupt?)\n");
    4.53 -
    4.54 -    reason = (reason & 0xf) | 8;
    4.55 -    outb(reason, 0x61);
    4.56 +    printk("\n\n");
    4.57  
    4.58      show_registers(regs);
    4.59  
    4.60 @@ -539,6 +535,23 @@ asmlinkage void do_nmi(struct pt_regs * 
    4.61          unknown_nmi_error((unsigned char)(reason&0xff), regs);
    4.62  }
    4.63  
    4.64 +unsigned long nmi_softirq_reason;
    4.65 +static void nmi_softirq(void)
    4.66 +{
    4.67 +    struct domain *d = find_domain_by_id(0);
    4.68 +
    4.69 +    if ( d == NULL )
    4.70 +        return;
    4.71 +
    4.72 +    if ( test_and_clear_bit(0, &nmi_softirq_reason) )
    4.73 +        send_guest_virq(d, VIRQ_PARITY_ERR);
    4.74 +
    4.75 +    if ( test_and_clear_bit(1, &nmi_softirq_reason) )
    4.76 +        send_guest_virq(d, VIRQ_IO_ERR);
    4.77 +
    4.78 +    put_domain(d);
    4.79 +}
    4.80 +
    4.81  asmlinkage void math_state_restore(struct pt_regs *regs, long error_code)
    4.82  {
    4.83      /* Prevent recursion. */
    4.84 @@ -751,6 +764,8 @@ void __init trap_init(void)
    4.85          extern void cpu_init(void);
    4.86          cpu_init();
    4.87      }
    4.88 +
    4.89 +    open_softirq(NMI_SOFTIRQ, nmi_softirq);
    4.90  }
    4.91  
    4.92  
     5.1 --- a/xen/arch/x86/x86_32/entry.S	Tue Aug 03 09:36:46 2004 +0000
     5.2 +++ b/xen/arch/x86/x86_32/entry.S	Tue Aug 03 10:55:54 2004 +0000
     5.3 @@ -58,6 +58,7 @@
     5.4  
     5.5  #include <xen/config.h>
     5.6  #include <xen/errno.h>
     5.7 +#include <xen/softirq.h>
     5.8  #include <hypervisor-ifs/hypervisor-if.h>
     5.9  
    5.10  EBX		= 0x00
    5.11 @@ -598,8 +599,7 @@ ENTRY(nmi)
    5.12  	pushl %eax
    5.13  	SAVE_ALL_NOSEGREGS
    5.14  
    5.15 -        # Check for hardware problems. These are always fatal so we can
    5.16 -        # reload DS and ES when handling them.
    5.17 +        # Check for hardware problems.
    5.18          inb   $0x61,%al
    5.19          testb $0x80,%al
    5.20          jne   nmi_parity_err
    5.21 @@ -656,25 +656,45 @@ nmi_badseg:
    5.22          addl $20,%esp
    5.23          iret
    5.24  
    5.25 -nmi_parity_err: 
    5.26 -        movl $(__HYPERVISOR_DS),%edx
    5.27 +nmi_parity_err:
    5.28 +        # Clear and disable the parity-error line
    5.29 +        andb $0xf,%al
    5.30 +        orb  $0x4,%al
    5.31 +        outb %al,$0x61
    5.32 +        cmpb $'i',%ss:SYMBOL_NAME(opt_nmi) # nmi=ignore
    5.33 +        je   nmi_badseg
    5.34 +        bts  $0,%ss:SYMBOL_NAME(nmi_softirq_reason)
    5.35 +        bts  $NMI_SOFTIRQ,%ss:SYMBOL_NAME(irq_stat)
    5.36 +        cmpb $'d',%ss:SYMBOL_NAME(opt_nmi) # nmi=dom0
    5.37 +        je   nmi_badseg
    5.38 +        movl $(__HYPERVISOR_DS),%edx       # nmi=fatal
    5.39          movl %edx,%ds
    5.40          movl %edx,%es
    5.41          movl %esp,%edx
    5.42          push %edx
    5.43 -        push %eax
    5.44          call SYMBOL_NAME(mem_parity_error)
    5.45 -        ud2
    5.46 -        
    5.47 +        addl $4,%esp
    5.48 +        jmp  ret_from_intr
    5.49 +                
    5.50  nmi_io_err: 
    5.51 -        movl $(__HYPERVISOR_DS),%edx
    5.52 +        # Clear and disable the I/O-error line
    5.53 +        andb $0xf,%al
    5.54 +        orb  $0x8,%al
    5.55 +        outb %al,$0x61
    5.56 +        cmpb $'i',%ss:SYMBOL_NAME(opt_nmi) # nmi=ignore
    5.57 +        je   nmi_badseg
    5.58 +        bts  $1,%ss:SYMBOL_NAME(nmi_softirq_reason)
    5.59 +        bts  $NMI_SOFTIRQ,%ss:SYMBOL_NAME(irq_stat)
    5.60 +        cmpb $'d',%ss:SYMBOL_NAME(opt_nmi) # nmi=dom0
    5.61 +        je   nmi_badseg
    5.62 +        movl $(__HYPERVISOR_DS),%edx       # nmi=fatal
    5.63          movl %edx,%ds
    5.64          movl %edx,%es
    5.65          movl %esp,%edx
    5.66          push %edx
    5.67 -        push %eax
    5.68          call SYMBOL_NAME(io_check_error)                        
    5.69 -        ud2   
    5.70 +        addl $4,%esp
    5.71 +        jmp  ret_from_intr
    5.72               
    5.73  .data
    5.74  ENTRY(hypercall_table)
     6.1 --- a/xen/common/kernel.c	Tue Aug 03 09:36:46 2004 +0000
     6.2 +++ b/xen/common/kernel.c	Tue Aug 03 10:55:54 2004 +0000
     6.3 @@ -80,6 +80,17 @@ char opt_leveltrigger[30] = "", opt_edge
     6.4   * pfn_info table and allocation bitmap.
     6.5   */
     6.6  unsigned int opt_xenheap_megabytes = XENHEAP_DEFAULT_MB;
     6.7 +/*
     6.8 + * opt_nmi: one of 'ignore', 'dom0', or 'fatal'.
     6.9 + *  fatal:  Xen prints diagnostic message and then hangs.
    6.10 + *  dom0:   The NMI is virtualised to DOM0.
    6.11 + *  ignore: The NMI error is cleared and ignored.
    6.12 + */
    6.13 +#ifdef NDEBUG
    6.14 +char opt_nmi[10] = "dom0";
    6.15 +#else
    6.16 +char opt_nmi[10] = "fatal";
    6.17 +#endif
    6.18  
    6.19  static struct {
    6.20      unsigned char *name;
    6.21 @@ -104,6 +115,7 @@ static struct {
    6.22      { "leveltrigger",      OPT_STR,  &opt_leveltrigger },
    6.23      { "edgetrigger",       OPT_STR,  &opt_edgetrigger },
    6.24      { "xenheap_megabytes", OPT_UINT, &opt_xenheap_megabytes },
    6.25 +    { "nmi",               OPT_STR,  &opt_nmi },
    6.26      { NULL,               0,        NULL     }
    6.27  };
    6.28  
     7.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h	Tue Aug 03 09:36:46 2004 +0000
     7.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h	Tue Aug 03 10:55:54 2004 +0000
     7.3 @@ -65,7 +65,9 @@
     7.4  #define VIRQ_DEBUG      2  /* Request guest to dump debug info.           */
     7.5  #define VIRQ_CONSOLE    3  /* (DOM0) bytes received on emergency console. */
     7.6  #define VIRQ_DOM_EXC    4  /* (DOM0) Exceptional event for some domain.   */
     7.7 -#define NR_VIRQS        5
     7.8 +#define VIRQ_PARITY_ERR 5  /* (DOM0) NMI parity error.                    */
     7.9 +#define VIRQ_IO_ERR     6  /* (DOM0) NMI I/O error.                       */
    7.10 +#define NR_VIRQS        7
    7.11  
    7.12  /*
    7.13   * MMU-UPDATE REQUESTS
     8.1 --- a/xen/include/xen/softirq.h	Tue Aug 03 09:36:46 2004 +0000
     8.2 +++ b/xen/include/xen/softirq.h	Tue Aug 03 10:55:54 2004 +0000
     8.3 @@ -1,23 +1,21 @@
     8.4  #ifndef __XEN_SOFTIRQ_H__
     8.5  #define __XEN_SOFTIRQ_H__
     8.6  
     8.7 +#define AC_TIMER_SOFTIRQ                  0
     8.8 +#define NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ 1
     8.9 +#define DEBUGGER_SOFTIRQ                  2
    8.10 +#define NMI_SOFTIRQ                       3
    8.11 +#define SCHEDULE_SOFTIRQ                  4
    8.12 +#define NR_SOFTIRQS                       5
    8.13 +
    8.14 +#ifndef __ASSEMBLY__
    8.15 +
    8.16  #include <xen/config.h>
    8.17  #include <xen/lib.h>
    8.18  #include <xen/smp.h>
    8.19  #include <asm/bitops.h>
    8.20  #include <asm/hardirq.h>
    8.21  
    8.22 -enum
    8.23 -{
    8.24 -    AC_TIMER_SOFTIRQ=0,
    8.25 -    NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ,
    8.26 -#ifdef XEN_DEBUGGER
    8.27 -    DEBUGGER_SOFTIRQ,
    8.28 -#endif
    8.29 -    SCHEDULE_SOFTIRQ, /* NB. This must come last or do_softirq() will break! */
    8.30 -    NR_SOFTIRQS
    8.31 -};
    8.32 -
    8.33  typedef void (*softirq_handler)(void);
    8.34  
    8.35  asmlinkage void do_softirq(void);
    8.36 @@ -34,4 +32,6 @@ static inline void raise_softirq(unsigne
    8.37      set_bit(nr, &softirq_pending(smp_processor_id()));
    8.38  }
    8.39  
    8.40 +#endif /* __ASSEMBLY__ */
    8.41 +
    8.42  #endif /* __XEN_SOFTIRQ_H__ */