ia64/xen-unstable

changeset 3927:55293083a741

bitkeeper revision 1.1236.3.2 (421f3a985MlpKQbJ61Hi9J-7qp0NCg)

Make show_registers() aware of vmx guest contexts.

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author maf46@burn.cl.cam.ac.uk
date Fri Feb 25 14:47:52 2005 +0000 (2005-02-25)
parents 256ed63cbd2c
children e8255a227e2c
files xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_32/traps.c
line diff
     1.1 --- a/xen/arch/x86/x86_32/entry.S	Fri Feb 25 13:37:57 2005 +0000
     1.2 +++ b/xen/arch/x86/x86_32/entry.S	Fri Feb 25 14:47:52 2005 +0000
     1.3 @@ -99,6 +99,7 @@
     1.4          pushl $VMX_MONITOR_EFLAGS; \
     1.5          popf; \
     1.6          subl $(NR_SKIPPED_REGS*4), %esp; \
     1.7 +        movl $0, 0xc(%esp); /* eflags==0 identifies xen_regs as VMX guest */ \
     1.8          pushl %eax; \
     1.9          pushl %ebp; \
    1.10          pushl %edi; \
     2.1 --- a/xen/arch/x86/x86_32/traps.c	Fri Feb 25 13:37:57 2005 +0000
     2.2 +++ b/xen/arch/x86/x86_32/traps.c	Fri Feb 25 14:47:52 2005 +0000
     2.3 @@ -9,6 +9,10 @@
     2.4  #include <xen/irq.h>
     2.5  #include <asm/flushtlb.h>
     2.6  
     2.7 +#ifdef CONFIG_VMX
     2.8 +#include <asm/vmx.h>
     2.9 +#endif
    2.10 +
    2.11  /* All CPUs have their own IDT to allow set_fast_trap(). */
    2.12  idt_entry_t *idt_tables[NR_CPUS] = { 0 };
    2.13  
    2.14 @@ -88,37 +92,63 @@ void show_stack(unsigned long *esp)
    2.15  
    2.16  void show_registers(struct xen_regs *regs)
    2.17  {
    2.18 -    unsigned long esp;
    2.19 -    unsigned short ss, ds, es, fs, gs;
    2.20 +    unsigned long ss, ds, es, fs, gs, cs;
    2.21 +    unsigned long eip, esp, eflags;
    2.22 +    const char *context;
    2.23  
    2.24 -    if ( GUEST_MODE(regs) )
    2.25 +#ifdef CONFIG_VMX
    2.26 +    if ( current->arch.arch_vmx.flags && (regs->eflags == 0) )
    2.27      {
    2.28 -        esp = regs->esp;
    2.29 -        ss  = regs->ss & 0xffff;
    2.30 -        ds  = regs->ds & 0xffff;
    2.31 -        es  = regs->es & 0xffff;
    2.32 -        fs  = regs->fs & 0xffff;
    2.33 -        gs  = regs->gs & 0xffff;
    2.34 +        __vmread(GUEST_EIP, &eip);
    2.35 +        __vmread(GUEST_ESP, &esp);
    2.36 +        __vmread(GUEST_EFLAGS, &eflags);
    2.37 +        __vmread(GUEST_SS_SELECTOR, &ss);
    2.38 +        __vmread(GUEST_DS_SELECTOR, &ds);
    2.39 +        __vmread(GUEST_ES_SELECTOR, &es);
    2.40 +        __vmread(GUEST_FS_SELECTOR, &fs);
    2.41 +        __vmread(GUEST_GS_SELECTOR, &gs);
    2.42 +        __vmread(GUEST_CS_SELECTOR, &cs);
    2.43 +        context = "vmx guest";
    2.44      }
    2.45      else
    2.46 +#endif
    2.47      {
    2.48 -        esp = (unsigned long)(&regs->esp);
    2.49 -        ss  = __HYPERVISOR_DS;
    2.50 -        ds  = __HYPERVISOR_DS;
    2.51 -        es  = __HYPERVISOR_DS;
    2.52 -        fs  = __HYPERVISOR_DS;
    2.53 -        gs  = __HYPERVISOR_DS;
    2.54 +        eip = regs->eip;
    2.55 +        eflags = regs->eflags;
    2.56 +
    2.57 +        if ( GUEST_MODE(regs) )
    2.58 +        {
    2.59 +            esp = regs->esp;
    2.60 +            ss  = regs->ss & 0xffff;
    2.61 +            ds  = regs->ds & 0xffff;
    2.62 +            es  = regs->es & 0xffff;
    2.63 +            fs  = regs->fs & 0xffff;
    2.64 +            gs  = regs->gs & 0xffff;
    2.65 +            cs  = regs->cs & 0xffff;
    2.66 +            context = "guest";
    2.67 +        }
    2.68 +        else
    2.69 +        {
    2.70 +            esp = (unsigned long)(&regs->esp);
    2.71 +            ss  = __HYPERVISOR_DS;
    2.72 +            ds  = __HYPERVISOR_DS;
    2.73 +            es  = __HYPERVISOR_DS;
    2.74 +            fs  = __HYPERVISOR_DS;
    2.75 +            gs  = __HYPERVISOR_DS;
    2.76 +            cs  = __HYPERVISOR_CS;
    2.77 +            
    2.78 +            context = "hypervisor";
    2.79 +        }
    2.80      }
    2.81  
    2.82 -    printk("CPU:    %d\nEIP:    %04lx:[<%p>]      \nEFLAGS: %p\n",
    2.83 -           smp_processor_id(), 0xffff & regs->cs, regs->eip, regs->eflags);
    2.84 +    printk("CPU:    %d\nEIP:    %04lx:[<%p>]      \nEFLAGS: %p   CONTEXT: %s\n",
    2.85 +           smp_processor_id(), 0xffff & regs->cs, eip, eflags, context);
    2.86      printk("eax: %p   ebx: %p   ecx: %p   edx: %p\n",
    2.87             regs->eax, regs->ebx, regs->ecx, regs->edx);
    2.88      printk("esi: %p   edi: %p   ebp: %p   esp: %p\n",
    2.89             regs->esi, regs->edi, regs->ebp, esp);
    2.90 -    printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   ss: %04x\n",
    2.91 -           ds, es, fs, gs, ss);
    2.92 -    printk("cr3: %08lx\n", read_cr3());
    2.93 +    printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   ss: %04x   cs: %04x\n",
    2.94 +           ds, es, fs, gs, ss, cs);
    2.95  
    2.96      show_stack((unsigned long *)&regs->esp);
    2.97  }