ia64/xen-unstable

changeset 3041:20087d779fb6

bitkeeper revision 1.1159.179.2 (419cbedfAFJPmYd4XKno5lrw9LXJ0A)

Auto-generate assembly struct offsets. Clean up Xen-death on
unhandleable traps/faults/NMIs/etc.
author kaf24@scramble.cl.cam.ac.uk
date Thu Nov 18 15:25:19 2004 +0000 (2004-11-18)
parents 576b4b91f80a
children 4644bea63898 ceacd1c23c6c
files .rootkeys BitKeeper/etc/ignore xen/Makefile xen/arch/x86/Makefile xen/arch/x86/nmi.c xen/arch/x86/traps.c xen/arch/x86/x86_32/asm-offsets.c xen/common/keyhandler.c xen/include/asm-x86/processor.h xen/include/asm-x86/shadow.h xen/include/asm-x86/x86_32/asm_defns.h
line diff
     1.1 --- a/.rootkeys	Thu Nov 18 15:13:33 2004 +0000
     1.2 +++ b/.rootkeys	Thu Nov 18 15:25:19 2004 +0000
     1.3 @@ -606,6 +606,7 @@ 3ddb79bcfUN3-UBCPzX26IU8bq-3aw xen/arch/
     1.4  3ddb79bc-Udq7ol-NX4q9XsYnN7A2Q xen/arch/x86/time.c
     1.5  3ddb79bccYVzXZJyVaxuv5T42Z1Fsw xen/arch/x86/trampoline.S
     1.6  3ddb79bcOftONV9h4QCxXOfiT0h91w xen/arch/x86/traps.c
     1.7 +419cbedeQDg8IrO3izo3o5rQNlo0kQ xen/arch/x86/x86_32/asm-offsets.c
     1.8  3e32af9aRnYGl4GMOaDKp7JdfhOGhg xen/arch/x86/x86_32/domain_page.c
     1.9  3ddb79bcecupHj56ZbTa3B0FxDowMg xen/arch/x86/x86_32/entry.S
    1.10  3ddb79bcHwuCQDjBICDTSis52hWguw xen/arch/x86/x86_32/mm.c
     2.1 --- a/BitKeeper/etc/ignore	Thu Nov 18 15:13:33 2004 +0000
     2.2 +++ b/BitKeeper/etc/ignore	Thu Nov 18 15:25:19 2004 +0000
     2.3 @@ -62,12 +62,14 @@ tools/misc/xen_cpuperf
     2.4  tools/web-shutdown.tap
     2.5  tools/xentrace/xentrace
     2.6  tools/xfrd/xfrd
     2.7 +xen/arch/x86/asm-offsets.s
     2.8  xen/arch/x86/boot/mkelf32
     2.9  xen/drivers/pci/classlist.h
    2.10  xen/drivers/pci/devlist.h
    2.11  xen/drivers/pci/gen-devlist
    2.12  xen/figlet/figlet
    2.13  xen/include/asm
    2.14 +xen/include/asm-*/asm-offsets.h
    2.15  xen/include/hypervisor-ifs/arch
    2.16  xen/include/xen/compile.h
    2.17  xen/tools/elf-reloc
     3.1 --- a/xen/Makefile	Thu Nov 18 15:13:33 2004 +0000
     3.2 +++ b/xen/Makefile	Thu Nov 18 15:25:19 2004 +0000
     3.3 @@ -34,10 +34,13 @@ clean:
     3.4  	$(MAKE) -C drivers clean
     3.5  	$(MAKE) -C arch/$(TARGET_ARCH) clean
     3.6  	rm -f include/asm *.o $(TARGET)* *~ core include/xen/compile.h
     3.7 +	rm -f include/asm-*/asm-offsets.h
     3.8  
     3.9  $(TARGET): delete-unfresh-files
    3.10  	[ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
    3.11  	$(MAKE) include/xen/compile.h
    3.12 +	$(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
    3.13 +	$(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
    3.14  	$(MAKE) -C common
    3.15  	$(MAKE) -C drivers
    3.16  	$(MAKE) -C arch/$(TARGET_ARCH)
    3.17 @@ -67,6 +70,22 @@ include/xen/compile.h:
    3.18  	cd ./figlet && make && ./figlet Xen $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION) 1>>../$@ && cd ..
    3.19  	@LANG=C echo >> $@
    3.20  
    3.21 +include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
    3.22 +	@(set -e; \
    3.23 +	  echo "/*"; \
    3.24 +	  echo " * DO NOT MODIFY."; \
    3.25 +	  echo " *"; \
    3.26 +	  echo " * This file was auto-generated from $<"; \
    3.27 +	  echo " *"; \
    3.28 +	  echo " */"; \
    3.29 +	  echo ""; \
    3.30 +	  echo "#ifndef __ASM_OFFSETS_H__"; \
    3.31 +	  echo "#define __ASM_OFFSETS_H__"; \
    3.32 +	  echo ""; \
    3.33 +	  sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
    3.34 +	  echo ""; \
    3.35 +	  echo "#endif") <$< >$@
    3.36 +
    3.37  .PHONY: default debug install dist clean delete-unfresh-files TAGS
    3.38  
    3.39  SUBDIRS = arch common drivers 
    3.40 @@ -77,4 +96,3 @@ TAGS:
    3.41  	  find $(SUBDIRS) -name '*.[ch]' ) | grep -v /SCCS/ | etags -
    3.42  MAP:
    3.43  	nm $(TARGET) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
    3.44 -
     4.1 --- a/xen/arch/x86/Makefile	Thu Nov 18 15:13:33 2004 +0000
     4.2 +++ b/xen/arch/x86/Makefile	Thu Nov 18 15:25:19 2004 +0000
     4.3 @@ -9,16 +9,23 @@ endif
     4.4  OBJS += $(patsubst %.S,%.o,$(wildcard $(TARGET_SUBARCH)/*.S))
     4.5  OBJS += $(patsubst %.c,%.o,$(wildcard $(TARGET_SUBARCH)/*.c))
     4.6  
     4.7 +OBJS := $(subst $(TARGET_SUBARCH)/asm-offsets.o,,$(OBJS))
     4.8 +
     4.9  default: boot/$(TARGET_SUBARCH).o $(OBJS) boot/mkelf32
    4.10  	$(LD) $(LDFLAGS) -r -o arch.o $(OBJS)
    4.11  	$(LD) $(LDFLAGS) -T $(TARGET_SUBARCH)/xen.lds -N \
    4.12  	    boot/$(TARGET_SUBARCH).o $(ALL_OBJS) -o $(TARGET)-syms
    4.13  	./boot/mkelf32 $(TARGET)-syms $(TARGET) 0x100000
    4.14  
    4.15 +asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c
    4.16 +	$(CC) $(CFLAGS) -S -o $@ $<
    4.17 +
    4.18  boot/mkelf32: boot/mkelf32.c
    4.19  	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
    4.20  
    4.21  clean:
    4.22 -	rm -f *.o *~ core boot/*.o boot/*~ boot/core boot/mkelf32
    4.23 +	rm -f *.o *.s *~ core boot/*.o boot/*~ boot/core boot/mkelf32
    4.24  	rm -f x86_32/*.o x86_32/*~ x86_32/core
    4.25  	rm -f x86_64/*.o x86_64/*~ x86_64/core
    4.26 +
    4.27 +.PHONY: default clean
     5.1 --- a/xen/arch/x86/nmi.c	Thu Nov 18 15:13:33 2004 +0000
     5.2 +++ b/xen/arch/x86/nmi.c	Thu Nov 18 15:25:19 2004 +0000
     5.3 @@ -25,12 +25,12 @@
     5.4  #include <asm/smp.h>
     5.5  #include <asm/msr.h>
     5.6  #include <asm/mpspec.h>
     5.7 +#include <asm/debugger.h>
     5.8  
     5.9  unsigned int nmi_watchdog = NMI_NONE;
    5.10  unsigned int watchdog_on = 0;
    5.11  static unsigned int nmi_hz = HZ;
    5.12  unsigned int nmi_perfctr_msr;	/* the MSR to reset in NMI handler */
    5.13 -extern void show_registers(struct xen_regs *regs);
    5.14  
    5.15  extern int logical_proc_id[];
    5.16  
    5.17 @@ -272,8 +272,6 @@ void touch_nmi_watchdog (void)
    5.18  
    5.19  void nmi_watchdog_tick (struct xen_regs * regs)
    5.20  {
    5.21 -    extern void die(const char * str, struct xen_regs * regs, long err);
    5.22 -
    5.23      int sum, cpu = smp_processor_id();
    5.24  
    5.25      sum = apic_timer_irqs[cpu];
    5.26 @@ -288,7 +286,7 @@ void nmi_watchdog_tick (struct xen_regs 
    5.27          if ( alert_counter[cpu] == 5*nmi_hz )
    5.28          {
    5.29              console_force_unlock();
    5.30 -            die("NMI Watchdog detected LOCKUP on CPU", regs, cpu);
    5.31 +            fatal_trap(TRAP_nmi, regs, 0);
    5.32          }
    5.33      } 
    5.34      else 
     6.1 --- a/xen/arch/x86/traps.c	Thu Nov 18 15:13:33 2004 +0000
     6.2 +++ b/xen/arch/x86/traps.c	Thu Nov 18 15:25:19 2004 +0000
     6.3 @@ -52,8 +52,6 @@
     6.4  #include <asm/i387.h>
     6.5  #include <asm/debugger.h>
     6.6  
     6.7 -extern char opt_nmi[];
     6.8 -
     6.9  struct guest_trap_bounce guest_trap_bounce[NR_CPUS] = { { 0 } };
    6.10  
    6.11  #if defined(__i386__)
    6.12 @@ -199,20 +197,39 @@ void show_registers(struct xen_regs *reg
    6.13      show_stack(&regs->esp);
    6.14  } 
    6.15  
    6.16 -
    6.17 -spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
    6.18 -
    6.19 -void die(const char *str, struct xen_regs * regs, long err)
    6.20 +/*
    6.21 + * This is called for faults at very unexpected times (e.g., when interrupts
    6.22 + * are disabled). In such situations we can't do much that is safe. We try to
    6.23 + * print out some tracing and then we just spin.
    6.24 + */
    6.25 +asmlinkage void fatal_trap(int trapnr, struct xen_regs *regs, long error_code)
    6.26  {
    6.27 -    unsigned long flags;
    6.28 -    spin_lock_irqsave(&die_lock, flags);
    6.29 -    printk("%s: %04lx,%04lx\n", str, err >> 16, err & 0xffff);
    6.30 +    int cpu = smp_processor_id();
    6.31 +    static char *trapstr[] = { 
    6.32 +        "divide error", "debug", "nmi", "bkpt", "overflow", "bounds", 
    6.33 +        "invalid operation", "device not available", "double fault", 
    6.34 +        "coprocessor segment", "invalid tss", "segment not found", 
    6.35 +        "stack error", "general protection fault", "page fault", 
    6.36 +        "spurious interrupt", "coprocessor error", "alignment check", 
    6.37 +        "machine check", "simd error"
    6.38 +    };
    6.39 +
    6.40      show_registers(regs);
    6.41 -    spin_unlock_irqrestore(&die_lock, flags);
    6.42 -    panic("Fatal crash within Xen.\n");
    6.43 +    printk("************************************\n");
    6.44 +    printk("CPU%d FATAL TRAP %d (%s), ERROR_CODE %lx%s.\n",
    6.45 +           cpu, trapnr, trapstr[trapnr], error_code,
    6.46 +           (regs->eflags & X86_EFLAGS_IF) ? "" : ", IN INTERRUPT CONTEXT");
    6.47 +    printk("System shutting down -- need manual reset.\n");
    6.48 +    printk("************************************\n");
    6.49 +
    6.50 +    /* Lock up the console to prevent spurious output from other CPUs. */
    6.51 +    console_force_lock();
    6.52 +
    6.53 +    /* Wait for manual reset. */
    6.54 +    for ( ; ; )
    6.55 +        __asm__ __volatile__ ( "hlt" );
    6.56  }
    6.57  
    6.58 -
    6.59  static inline void do_trap(int trapnr, char *str,
    6.60                             struct xen_regs *regs, 
    6.61                             long error_code, int use_error_code)
    6.62 @@ -275,7 +292,6 @@ DO_ERROR(11, "segment not present", segm
    6.63  DO_ERROR(12, "stack segment", stack_segment)
    6.64  DO_ERROR_NOCODE(16, "fpu error", coprocessor_error)
    6.65  DO_ERROR(17, "alignment check", alignment_check)
    6.66 -DO_ERROR_NOCODE(18, "machine check", machine_check)
    6.67  DO_ERROR_NOCODE(19, "simd error", simd_coprocessor_error)
    6.68  
    6.69  asmlinkage void do_int3(struct xen_regs *regs, long error_code)
    6.70 @@ -328,13 +344,17 @@ asmlinkage void do_double_fault(void)
    6.71      printk("System needs manual reset.\n");
    6.72      printk("************************************\n");
    6.73  
    6.74 -    DEBUGGER_trap_fatal(TRAP_double_fault, NULL, 0);
    6.75 -
    6.76      /* Lock up the console to prevent spurious output from other CPUs. */
    6.77      console_force_lock();
    6.78  
    6.79      /* Wait for manual reset. */
    6.80 -    for ( ; ; ) ;
    6.81 +    for ( ; ; )
    6.82 +        __asm__ __volatile__ ( "hlt" );
    6.83 +}
    6.84 +
    6.85 +asmlinkage void do_machine_check(struct xen_regs *regs, long error_code)
    6.86 +{
    6.87 +    fatal_trap(TRAP_machine_check, regs, error_code);
    6.88  }
    6.89  
    6.90  asmlinkage void do_page_fault(struct xen_regs *regs, long error_code)
    6.91 @@ -509,47 +529,24 @@ asmlinkage void do_general_protection(st
    6.92  
    6.93      DEBUGGER_trap_fatal(TRAP_gp_fault, regs, error_code);
    6.94  
    6.95 -    die("general protection fault", regs, error_code);
    6.96 +    show_registers(regs);
    6.97 +    panic("CPU%d GENERAL PROTECTION FAULT\n"
    6.98 +          "[error_code=%08x]\n", smp_processor_id(), error_code);
    6.99  }
   6.100  
   6.101  asmlinkage void mem_parity_error(struct xen_regs *regs)
   6.102  {
   6.103      console_force_unlock();
   6.104 -
   6.105 -    printk("\n\n");
   6.106 -
   6.107 -    show_registers(regs);
   6.108 -
   6.109 -    printk("************************************\n");
   6.110 -    printk("CPU%d MEMORY ERROR -- system shutdown\n", smp_processor_id());
   6.111 -    printk("System needs manual reset.\n");
   6.112 -    printk("************************************\n");
   6.113 -
   6.114 -    /* Lock up the console to prevent spurious output from other CPUs. */
   6.115 -    console_force_lock();
   6.116 -
   6.117 -    /* Wait for manual reset. */
   6.118 -    for ( ; ; ) ;
   6.119 +    printk("\n\nNMI - MEMORY ERROR\n");
   6.120 +    fatal_trap(TRAP_nmi, regs, 0);
   6.121  }
   6.122  
   6.123  asmlinkage void io_check_error(struct xen_regs *regs)
   6.124  {
   6.125      console_force_unlock();
   6.126  
   6.127 -    printk("\n\n");
   6.128 -
   6.129 -    show_registers(regs);
   6.130 -
   6.131 -    printk("************************************\n");
   6.132 -    printk("CPU%d I/O ERROR -- system shutdown\n", smp_processor_id());
   6.133 -    printk("System needs manual reset.\n");
   6.134 -    printk("************************************\n");
   6.135 -
   6.136 -    /* Lock up the console to prevent spurious output from other CPUs. */
   6.137 -    console_force_lock();
   6.138 -
   6.139 -    /* Wait for manual reset. */
   6.140 -    for ( ; ; ) ;
   6.141 +    printk("\n\nNMI - I/O ERROR\n");
   6.142 +    fatal_trap(TRAP_nmi, regs, 0);
   6.143  }
   6.144  
   6.145  static void unknown_nmi_error(unsigned char reason, struct xen_regs * regs)
   6.146 @@ -738,26 +735,26 @@ void __init trap_init(void)
   6.147       * saved. The page-fault handler also needs interrupts disabled until %cr2 
   6.148       * has been read and saved on the stack.
   6.149       */
   6.150 -    set_intr_gate(0,&divide_error);
   6.151 -    set_intr_gate(1,&debug);
   6.152 -    set_intr_gate(2,&nmi);
   6.153 -    set_system_gate(3,&int3);     /* usable from all privilege levels */
   6.154 -    set_system_gate(4,&overflow); /* usable from all privilege levels */
   6.155 -    set_intr_gate(5,&bounds);
   6.156 -    set_intr_gate(6,&invalid_op);
   6.157 -    set_intr_gate(7,&device_not_available);
   6.158 -    set_task_gate(8,__DOUBLEFAULT_TSS_ENTRY<<3);
   6.159 -    set_intr_gate(9,&coprocessor_segment_overrun);
   6.160 -    set_intr_gate(10,&invalid_TSS);
   6.161 -    set_intr_gate(11,&segment_not_present);
   6.162 -    set_intr_gate(12,&stack_segment);
   6.163 -    set_intr_gate(13,&general_protection);
   6.164 -    set_intr_gate(14,&page_fault);
   6.165 -    set_intr_gate(15,&spurious_interrupt_bug);
   6.166 -    set_intr_gate(16,&coprocessor_error);
   6.167 -    set_intr_gate(17,&alignment_check);
   6.168 -    set_intr_gate(18,&machine_check);
   6.169 -    set_intr_gate(19,&simd_coprocessor_error);
   6.170 +    set_intr_gate(TRAP_divide_error,&divide_error);
   6.171 +    set_intr_gate(TRAP_debug,&debug);
   6.172 +    set_intr_gate(TRAP_nmi,&nmi);
   6.173 +    set_system_gate(TRAP_int3,&int3);         /* usable from all privileges */
   6.174 +    set_system_gate(TRAP_overflow,&overflow); /* usable from all privileges */
   6.175 +    set_intr_gate(TRAP_bounds,&bounds);
   6.176 +    set_intr_gate(TRAP_invalid_op,&invalid_op);
   6.177 +    set_intr_gate(TRAP_no_device,&device_not_available);
   6.178 +    set_task_gate(TRAP_double_fault,__DOUBLEFAULT_TSS_ENTRY<<3);
   6.179 +    set_intr_gate(TRAP_copro_seg,&coprocessor_segment_overrun);
   6.180 +    set_intr_gate(TRAP_invalid_tss,&invalid_TSS);
   6.181 +    set_intr_gate(TRAP_no_segment,&segment_not_present);
   6.182 +    set_intr_gate(TRAP_stack_error,&stack_segment);
   6.183 +    set_intr_gate(TRAP_gp_fault,&general_protection);
   6.184 +    set_intr_gate(TRAP_page_fault,&page_fault);
   6.185 +    set_intr_gate(TRAP_spurious_int,&spurious_interrupt_bug);
   6.186 +    set_intr_gate(TRAP_copro_error,&coprocessor_error);
   6.187 +    set_intr_gate(TRAP_alignment_check,&alignment_check);
   6.188 +    set_intr_gate(TRAP_machine_check,&machine_check);
   6.189 +    set_intr_gate(TRAP_simd_error,&simd_coprocessor_error);
   6.190  
   6.191      /* Only ring 1 can access Xen services. */
   6.192      _set_gate(idt_table+HYPERCALL_VECTOR,14,1,&hypercall);
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/xen/arch/x86/x86_32/asm-offsets.c	Thu Nov 18 15:25:19 2004 +0000
     7.3 @@ -0,0 +1,57 @@
     7.4 +/*
     7.5 + * Generate definitions needed by assembly language modules.
     7.6 + * This code generates raw asm output which is post-processed
     7.7 + * to extract and format the required data.
     7.8 + */
     7.9 +
    7.10 +#include <xen/sched.h>
    7.11 +
    7.12 +#define DEFINE(_sym, _val) \
    7.13 +    __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" _val )
    7.14 +#define BLANK() \
    7.15 +    __asm__ __volatile__ ( "\n->" : : )
    7.16 +#define OFFSET(_sym, _str, _mem) \
    7.17 +    DEFINE(_sym, offsetof(_str, _mem));
    7.18 +
    7.19 +void __dummy__(void)
    7.20 +{
    7.21 +    OFFSET(XREGS_eax, struct xen_regs, eax);
    7.22 +    OFFSET(XREGS_ebx, struct xen_regs, ebx);
    7.23 +    OFFSET(XREGS_ecx, struct xen_regs, ecx);
    7.24 +    OFFSET(XREGS_edx, struct xen_regs, edx);
    7.25 +    OFFSET(XREGS_esi, struct xen_regs, esi);
    7.26 +    OFFSET(XREGS_edi, struct xen_regs, edi);
    7.27 +    OFFSET(XREGS_esp, struct xen_regs, esp);
    7.28 +    OFFSET(XREGS_ebp, struct xen_regs, ebp);
    7.29 +    OFFSET(XREGS_eip, struct xen_regs, eip);
    7.30 +    OFFSET(XREGS_cs, struct xen_regs, cs);
    7.31 +    OFFSET(XREGS_ds, struct xen_regs, ds);
    7.32 +    OFFSET(XREGS_es, struct xen_regs, es);
    7.33 +    OFFSET(XREGS_fs, struct xen_regs, fs);
    7.34 +    OFFSET(XREGS_gs, struct xen_regs, gs);
    7.35 +    OFFSET(XREGS_ss, struct xen_regs, ss);
    7.36 +    OFFSET(XREGS_eflags, struct xen_regs, eflags);
    7.37 +    OFFSET(XREGS_orig_eax, struct xen_regs, orig_eax);
    7.38 +    BLANK();
    7.39 +
    7.40 +    OFFSET(DOMAIN_processor, struct domain, processor);
    7.41 +    OFFSET(DOMAIN_shared_info, struct domain, shared_info);
    7.42 +    OFFSET(DOMAIN_event_sel, struct domain, event_selector);
    7.43 +    OFFSET(DOMAIN_event_addr, struct domain, event_address);
    7.44 +    OFFSET(DOMAIN_failsafe_sel, struct domain, failsafe_selector);
    7.45 +    OFFSET(DOMAIN_failsafe_addr, struct domain, failsafe_address);
    7.46 +    BLANK();
    7.47 +
    7.48 +    OFFSET(SHINFO_upcall_pending, shared_info_t, 
    7.49 +           vcpu_data[0].evtchn_upcall_pending);
    7.50 +    OFFSET(SHINFO_upcall_mask, shared_info_t, 
    7.51 +           vcpu_data[0].evtchn_upcall_mask);
    7.52 +    BLANK();
    7.53 +
    7.54 +    OFFSET(GTB_error_code, struct guest_trap_bounce, error_code);
    7.55 +    OFFSET(GTB_cr2, struct guest_trap_bounce, cr2);
    7.56 +    OFFSET(GTB_flags, struct guest_trap_bounce, flags);
    7.57 +    OFFSET(GTB_cs, struct guest_trap_bounce, cs);
    7.58 +    OFFSET(GTB_eip, struct guest_trap_bounce, eip);
    7.59 +    BLANK();
    7.60 +}
     8.1 --- a/xen/common/keyhandler.c	Thu Nov 18 15:13:33 2004 +0000
     8.2 +++ b/xen/common/keyhandler.c	Thu Nov 18 15:25:19 2004 +0000
     8.3 @@ -81,10 +81,8 @@ static void show_handlers(unsigned char 
     8.4                     key_table[i].desc);
     8.5  }
     8.6  
     8.7 -
     8.8  static void dump_registers(unsigned char key, struct xen_regs *regs)
     8.9  {
    8.10 -    extern void show_registers(struct xen_regs *regs); 
    8.11      printk("'%c' pressed -> dumping registers\n", key); 
    8.12      show_registers(regs); 
    8.13  }
     9.1 --- a/xen/include/asm-x86/processor.h	Thu Nov 18 15:13:33 2004 +0000
     9.2 +++ b/xen/include/asm-x86/processor.h	Thu Nov 18 15:25:19 2004 +0000
     9.3 @@ -7,6 +7,7 @@
     9.4  #ifndef __ASM_X86_PROCESSOR_H
     9.5  #define __ASM_X86_PROCESSOR_H
     9.6  
     9.7 +#ifndef __ASSEMBLY__
     9.8  #include <asm/page.h>
     9.9  #include <asm/types.h>
    9.10  #include <asm/cpufeature.h>
    9.11 @@ -16,6 +17,81 @@
    9.12  #include <xen/config.h>
    9.13  #include <xen/spinlock.h>
    9.14  #include <public/xen.h>
    9.15 +#endif
    9.16 +
    9.17 +/*
    9.18 + * CPU vendor IDs
    9.19 + */
    9.20 +#define X86_VENDOR_INTEL 0
    9.21 +#define X86_VENDOR_CYRIX 1
    9.22 +#define X86_VENDOR_AMD 2
    9.23 +#define X86_VENDOR_UMC 3
    9.24 +#define X86_VENDOR_NEXGEN 4
    9.25 +#define X86_VENDOR_CENTAUR 5
    9.26 +#define X86_VENDOR_RISE 6
    9.27 +#define X86_VENDOR_TRANSMETA 7
    9.28 +#define X86_VENDOR_NSC 8
    9.29 +#define X86_VENDOR_SIS 9
    9.30 +#define X86_VENDOR_UNKNOWN 0xff
    9.31 +
    9.32 +/*
    9.33 + * EFLAGS bits
    9.34 + */
    9.35 +#define X86_EFLAGS_CF	0x00000001 /* Carry Flag */
    9.36 +#define X86_EFLAGS_PF	0x00000004 /* Parity Flag */
    9.37 +#define X86_EFLAGS_AF	0x00000010 /* Auxillary carry Flag */
    9.38 +#define X86_EFLAGS_ZF	0x00000040 /* Zero Flag */
    9.39 +#define X86_EFLAGS_SF	0x00000080 /* Sign Flag */
    9.40 +#define X86_EFLAGS_TF	0x00000100 /* Trap Flag */
    9.41 +#define X86_EFLAGS_IF	0x00000200 /* Interrupt Flag */
    9.42 +#define X86_EFLAGS_DF	0x00000400 /* Direction Flag */
    9.43 +#define X86_EFLAGS_OF	0x00000800 /* Overflow Flag */
    9.44 +#define X86_EFLAGS_IOPL	0x00003000 /* IOPL mask */
    9.45 +#define X86_EFLAGS_NT	0x00004000 /* Nested Task */
    9.46 +#define X86_EFLAGS_RF	0x00010000 /* Resume Flag */
    9.47 +#define X86_EFLAGS_VM	0x00020000 /* Virtual Mode */
    9.48 +#define X86_EFLAGS_AC	0x00040000 /* Alignment Check */
    9.49 +#define X86_EFLAGS_VIF	0x00080000 /* Virtual Interrupt Flag */
    9.50 +#define X86_EFLAGS_VIP	0x00100000 /* Virtual Interrupt Pending */
    9.51 +#define X86_EFLAGS_ID	0x00200000 /* CPUID detection flag */
    9.52 +
    9.53 +/*
    9.54 + * Intel CPU flags in CR0
    9.55 + */
    9.56 +#define X86_CR0_PE              0x00000001 /* Enable Protected Mode    (RW) */
    9.57 +#define X86_CR0_MP              0x00000002 /* Monitor Coprocessor      (RW) */
    9.58 +#define X86_CR0_EM              0x00000004 /* Require FPU Emulation    (RO) */
    9.59 +#define X86_CR0_TS              0x00000008 /* Task Switched            (RW) */
    9.60 +#define X86_CR0_NE              0x00000020 /* Numeric Error Reporting  (RW) */
    9.61 +#define X86_CR0_WP              0x00010000 /* Supervisor Write Protect (RW) */
    9.62 +#define X86_CR0_AM              0x00040000 /* Alignment Checking       (RW) */
    9.63 +#define X86_CR0_NW              0x20000000 /* Not Write-Through        (RW) */
    9.64 +#define X86_CR0_CD              0x40000000 /* Cache Disable            (RW) */
    9.65 +#define X86_CR0_PG              0x80000000 /* Paging                   (RW) */
    9.66 +
    9.67 +/*
    9.68 + * Intel CPU features in CR4
    9.69 + */
    9.70 +#define X86_CR4_VME		0x0001	/* enable vm86 extensions */
    9.71 +#define X86_CR4_PVI		0x0002	/* virtual interrupts flag enable */
    9.72 +#define X86_CR4_TSD		0x0004	/* disable time stamp at ipl 3 */
    9.73 +#define X86_CR4_DE		0x0008	/* enable debugging extensions */
    9.74 +#define X86_CR4_PSE		0x0010	/* enable page size extensions */
    9.75 +#define X86_CR4_PAE		0x0020	/* enable physical address extensions */
    9.76 +#define X86_CR4_MCE		0x0040	/* Machine check enable */
    9.77 +#define X86_CR4_PGE		0x0080	/* enable global pages */
    9.78 +#define X86_CR4_PCE		0x0100	/* enable performance counters at ipl 3 */
    9.79 +#define X86_CR4_OSFXSR		0x0200	/* enable fast FPU save and restore */
    9.80 +#define X86_CR4_OSXMMEXCPT	0x0400	/* enable unmasked SSE exceptions */
    9.81 +
    9.82 +/*
    9.83 + * 'guest_trap_bounce' flags values.
    9.84 + */
    9.85 +#define GTBF_TRAP        1
    9.86 +#define GTBF_TRAP_NOCODE 2
    9.87 +#define GTBF_TRAP_CR2    4
    9.88 +
    9.89 +#ifndef __ASSEMBLY__
    9.90  
    9.91  struct domain;
    9.92  
    9.93 @@ -49,18 +125,6 @@ struct cpuinfo_x86 {
    9.94      int	    x86_tlbsize;     /* number of 4K pages in DTLB/ITLB combined */
    9.95  } __attribute__((__aligned__(SMP_CACHE_BYTES)));
    9.96  
    9.97 -#define X86_VENDOR_INTEL 0
    9.98 -#define X86_VENDOR_CYRIX 1
    9.99 -#define X86_VENDOR_AMD 2
   9.100 -#define X86_VENDOR_UMC 3
   9.101 -#define X86_VENDOR_NEXGEN 4
   9.102 -#define X86_VENDOR_CENTAUR 5
   9.103 -#define X86_VENDOR_RISE 6
   9.104 -#define X86_VENDOR_TRANSMETA 7
   9.105 -#define X86_VENDOR_NSC 8
   9.106 -#define X86_VENDOR_SIS 9
   9.107 -#define X86_VENDOR_UNKNOWN 0xff
   9.108 -
   9.109  /*
   9.110   * capabilities of CPUs
   9.111   */
   9.112 @@ -83,27 +147,6 @@ extern void print_cpu_info(struct cpuinf
   9.113  extern void dodgy_tsc(void);
   9.114  
   9.115  /*
   9.116 - * EFLAGS bits
   9.117 - */
   9.118 -#define X86_EFLAGS_CF	0x00000001 /* Carry Flag */
   9.119 -#define X86_EFLAGS_PF	0x00000004 /* Parity Flag */
   9.120 -#define X86_EFLAGS_AF	0x00000010 /* Auxillary carry Flag */
   9.121 -#define X86_EFLAGS_ZF	0x00000040 /* Zero Flag */
   9.122 -#define X86_EFLAGS_SF	0x00000080 /* Sign Flag */
   9.123 -#define X86_EFLAGS_TF	0x00000100 /* Trap Flag */
   9.124 -#define X86_EFLAGS_IF	0x00000200 /* Interrupt Flag */
   9.125 -#define X86_EFLAGS_DF	0x00000400 /* Direction Flag */
   9.126 -#define X86_EFLAGS_OF	0x00000800 /* Overflow Flag */
   9.127 -#define X86_EFLAGS_IOPL	0x00003000 /* IOPL mask */
   9.128 -#define X86_EFLAGS_NT	0x00004000 /* Nested Task */
   9.129 -#define X86_EFLAGS_RF	0x00010000 /* Resume Flag */
   9.130 -#define X86_EFLAGS_VM	0x00020000 /* Virtual Mode */
   9.131 -#define X86_EFLAGS_AC	0x00040000 /* Alignment Check */
   9.132 -#define X86_EFLAGS_VIF	0x00080000 /* Virtual Interrupt Flag */
   9.133 -#define X86_EFLAGS_VIP	0x00100000 /* Virtual Interrupt Pending */
   9.134 -#define X86_EFLAGS_ID	0x00200000 /* CPUID detection flag */
   9.135 -
   9.136 -/*
   9.137   * Generic CPUID function
   9.138   */
   9.139  static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx)
   9.140 @@ -161,20 +204,6 @@ static inline unsigned int cpuid_edx(uns
   9.141  }
   9.142  
   9.143  
   9.144 -/*
   9.145 - * Intel CPU flags in CR0
   9.146 - */
   9.147 -#define X86_CR0_PE              0x00000001 /* Enable Protected Mode    (RW) */
   9.148 -#define X86_CR0_MP              0x00000002 /* Monitor Coprocessor      (RW) */
   9.149 -#define X86_CR0_EM              0x00000004 /* Require FPU Emulation    (RO) */
   9.150 -#define X86_CR0_TS              0x00000008 /* Task Switched            (RW) */
   9.151 -#define X86_CR0_NE              0x00000020 /* Numeric Error Reporting  (RW) */
   9.152 -#define X86_CR0_WP              0x00010000 /* Supervisor Write Protect (RW) */
   9.153 -#define X86_CR0_AM              0x00040000 /* Alignment Checking       (RW) */
   9.154 -#define X86_CR0_NW              0x20000000 /* Not Write-Through        (RW) */
   9.155 -#define X86_CR0_CD              0x40000000 /* Cache Disable            (RW) */
   9.156 -#define X86_CR0_PG              0x80000000 /* Paging                   (RW) */
   9.157 -
   9.158  #define read_cr0() ({ \
   9.159  	unsigned long __dummy; \
   9.160  	__asm__( \
   9.161 @@ -188,21 +217,6 @@ static inline unsigned int cpuid_edx(uns
   9.162  
   9.163  
   9.164  /*
   9.165 - * Intel CPU features in CR4
   9.166 - */
   9.167 -#define X86_CR4_VME		0x0001	/* enable vm86 extensions */
   9.168 -#define X86_CR4_PVI		0x0002	/* virtual interrupts flag enable */
   9.169 -#define X86_CR4_TSD		0x0004	/* disable time stamp at ipl 3 */
   9.170 -#define X86_CR4_DE		0x0008	/* enable debugging extensions */
   9.171 -#define X86_CR4_PSE		0x0010	/* enable page size extensions */
   9.172 -#define X86_CR4_PAE		0x0020	/* enable physical address extensions */
   9.173 -#define X86_CR4_MCE		0x0040	/* Machine check enable */
   9.174 -#define X86_CR4_PGE		0x0080	/* enable global pages */
   9.175 -#define X86_CR4_PCE		0x0100	/* enable performance counters at ipl 3 */
   9.176 -#define X86_CR4_OSFXSR		0x0200	/* enable fast FPU save and restore */
   9.177 -#define X86_CR4_OSXMMEXCPT	0x0400	/* enable unmasked SSE exceptions */
   9.178 -
   9.179 -/*
   9.180   * Save the cr4 feature set we're using (ie
   9.181   * Pentium 4MB enable and PPro Global page
   9.182   * enable), so that any CPU's that boot up
   9.183 @@ -344,9 +358,6 @@ long set_fast_trap(struct domain *p, int
   9.184  
   9.185  #endif /* __x86_64__ */
   9.186  
   9.187 -#define GTBF_TRAP        1
   9.188 -#define GTBF_TRAP_NOCODE 2
   9.189 -#define GTBF_TRAP_CR2    4
   9.190  struct guest_trap_bounce {
   9.191      unsigned long  error_code;        /*   0 */
   9.192      unsigned long  cr2;               /*   4 */
   9.193 @@ -477,4 +488,12 @@ extern inline void prefetchw(const void 
   9.194  
   9.195  #endif
   9.196  
   9.197 +void show_guest_stack();
   9.198 +void show_trace(unsigned long *esp);
   9.199 +void show_stack(unsigned long *esp);
   9.200 +void show_registers(struct xen_regs *regs);
   9.201 +asmlinkage void fatal_trap(int trapnr, struct xen_regs *regs, long error_code);
   9.202 +
   9.203 +#endif /* !__ASSEMBLY__ */
   9.204 +
   9.205  #endif /* __ASM_X86_PROCESSOR_H */
    10.1 --- a/xen/include/asm-x86/shadow.h	Thu Nov 18 15:13:33 2004 +0000
    10.2 +++ b/xen/include/asm-x86/shadow.h	Thu Nov 18 15:25:19 2004 +0000
    10.3 @@ -116,18 +116,15 @@ static inline int __mark_dirty( struct m
    10.4  #ifndef NDEBUG
    10.5      else if ( mfn < max_page )
    10.6      {
    10.7 +        unsigned long *esp;
    10.8          SH_LOG("mark_dirty OOR! mfn=%x pfn=%lx max=%x (mm %p)",
    10.9                 mfn, pfn, m->shadow_dirty_bitmap_size, m );
   10.10          SH_LOG("dom=%p caf=%08x taf=%08x\n", 
   10.11                 frame_table[mfn].u.inuse.domain,
   10.12                 frame_table[mfn].count_info, 
   10.13                 frame_table[mfn].u.inuse.type_info );
   10.14 -        {
   10.15 -            extern void show_trace(unsigned long *esp);
   10.16 -            unsigned long *esp;
   10.17 -            __asm__ __volatile__ ("movl %%esp,%0" : "=r" (esp) : );
   10.18 -            show_trace(esp);
   10.19 -        }
   10.20 +        __asm__ __volatile__ ("movl %%esp,%0" : "=r" (esp) : );
   10.21 +        show_trace(esp);
   10.22      }
   10.23  #endif
   10.24  
    11.1 --- a/xen/include/asm-x86/x86_32/asm_defns.h	Thu Nov 18 15:13:33 2004 +0000
    11.2 +++ b/xen/include/asm-x86/x86_32/asm_defns.h	Thu Nov 18 15:25:19 2004 +0000
    11.3 @@ -1,56 +1,14 @@
    11.4  #ifndef __ASM_DEFNS_H__
    11.5  #define __ASM_DEFNS_H__
    11.6  
    11.7 -/* Offsets in 'struct xen_regs' --- AUTO-GENERATE ME! */
    11.8 -#define XREGS_ebx      0x00
    11.9 -#define XREGS_ecx      0x04
   11.10 -#define XREGS_edx      0x08
   11.11 -#define XREGS_esi      0x0C
   11.12 -#define XREGS_edi      0x10
   11.13 -#define XREGS_ebp      0x14
   11.14 -#define XREGS_eax      0x18
   11.15 -#define XREGS_orig_eax 0x1C
   11.16 -#define XREGS_eip      0x20
   11.17 -#define XREGS_cs       0x24
   11.18 -#define XREGS_eflags   0x28
   11.19 -#define XREGS_esp      0x2C
   11.20 -#define XREGS_ss       0x30
   11.21 -#define XREGS_es       0x34
   11.22 -#define XREGS_ds       0x38
   11.23 -#define XREGS_fs       0x3C
   11.24 -#define XREGS_gs       0x40
   11.25 -
   11.26 -/* Offsets in 'struct domain' --- AUTO-GENERATE ME! */
   11.27 -#define DOMAIN_processor       0
   11.28 -#define DOMAIN_shared_info     4
   11.29 -#define DOMAIN_event_sel       8
   11.30 -#define DOMAIN_event_addr     12
   11.31 -#define DOMAIN_failsafe_sel   16
   11.32 -#define DOMAIN_failsafe_addr  20
   11.33 -
   11.34 -/* Offsets in shared_info_t --- AUTO-GENERATE ME! */
   11.35 -#define SHINFO_upcall_pending /* 0 */
   11.36 -#define SHINFO_upcall_mask       1
   11.37 -
   11.38 -/* Offsets in 'struct guest_trap_bounce' --- AUTO-GENERATE ME! */
   11.39 -#define GTB_error_code    0
   11.40 -#define GTB_cr2           4
   11.41 -#define GTB_flags         8
   11.42 -#define GTB_cs           10
   11.43 -#define GTB_eip          12
   11.44 -#define GTBF_TRAP         1
   11.45 -#define GTBF_TRAP_NOCODE  2
   11.46 -#define GTBF_TRAP_CR2     4
   11.47 -
   11.48 -/* EFLAGS masks. */
   11.49 -#define CF_MASK 0x00000001
   11.50 -#define IF_MASK 0x00000200
   11.51 -#define NT_MASK 0x00004000
   11.52 +/* NB. Auto-generated from arch/.../asm-offsets.c */
   11.53 +#include <asm/asm-offsets.h>
   11.54 +#include <asm/processor.h>
   11.55  
   11.56  #define __STR(x) #x
   11.57  #define STR(x) __STR(x)
   11.58  
   11.59 -/* AUTO-GENERATE the following two cases (quoted vs. unquoted). */
   11.60 +/* Maybe auto-generate the following two cases (quoted vs. unquoted). */
   11.61  #ifndef __ASSEMBLY__
   11.62  
   11.63  #define __SAVE_ALL_PRE(_reg) \