ia64/xen-unstable

changeset 8848:39b392a22002

Fix segment-register dumping in show_registers().

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 14 19:43:45 2006 +0100 (2006-02-14)
parents 07a892f12609
children 70024ebbdf55
files xen/arch/x86/domain.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/include/asm-x86/system.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Tue Feb 14 18:25:10 2006 +0100
     1.2 +++ b/xen/arch/x86/domain.c	Tue Feb 14 19:43:45 2006 +0100
     1.3 @@ -615,10 +615,10 @@ static void save_segments(struct vcpu *v
     1.4      if ( HVM_DOMAIN(v) )
     1.5          hvm_save_segments(v);
     1.6  
     1.7 -    __asm__ __volatile__ ( "mov %%ds,%0" : "=m" (regs->ds) );
     1.8 -    __asm__ __volatile__ ( "mov %%es,%0" : "=m" (regs->es) );
     1.9 -    __asm__ __volatile__ ( "mov %%fs,%0" : "=m" (regs->fs) );
    1.10 -    __asm__ __volatile__ ( "mov %%gs,%0" : "=m" (regs->gs) );
    1.11 +    regs->ds = read_segment_register(ds);
    1.12 +    regs->es = read_segment_register(es);
    1.13 +    regs->fs = read_segment_register(fs);
    1.14 +    regs->gs = read_segment_register(gs);
    1.15  
    1.16      if ( regs->ds )
    1.17          dirty_segment_mask |= DIRTY_DS;
     2.1 --- a/xen/arch/x86/x86_32/traps.c	Tue Feb 14 18:25:10 2006 +0100
     2.2 +++ b/xen/arch/x86/x86_32/traps.c	Tue Feb 14 19:43:45 2006 +0100
     2.3 @@ -37,16 +37,13 @@ void show_registers(struct cpu_user_regs
     2.4          if ( !GUEST_MODE(regs) )
     2.5          {
     2.6              fault_regs.esp = (unsigned long)&regs->esp;
     2.7 -            fault_regs.ss = __HYPERVISOR_DS;
     2.8 -            fault_regs.ds = __HYPERVISOR_DS;
     2.9 -            fault_regs.es = __HYPERVISOR_DS;
    2.10 -            fault_regs.cs = __HYPERVISOR_CS;
    2.11 +            fault_regs.ss = read_segment_register(ss);
    2.12 +            fault_regs.ds = read_segment_register(ds);
    2.13 +            fault_regs.es = read_segment_register(es);
    2.14 +            fault_regs.fs = read_segment_register(fs);
    2.15 +            fault_regs.gs = read_segment_register(gs);
    2.16          }
    2.17  
    2.18 -        __asm__ (
    2.19 -            "movw %%fs,%0 ; movw %%gs,%1"
    2.20 -            : "=r" (fault_regs.fs), "=r" (fault_regs.gs) );
    2.21 -        
    2.22          fault_crs[0] = read_cr0();
    2.23          fault_crs[3] = read_cr3();
    2.24      }
     3.1 --- a/xen/arch/x86/x86_64/traps.c	Tue Feb 14 18:25:10 2006 +0100
     3.2 +++ b/xen/arch/x86/x86_64/traps.c	Tue Feb 14 19:43:45 2006 +0100
     3.3 @@ -35,6 +35,10 @@ void show_registers(struct cpu_user_regs
     3.4          context = GUEST_MODE(regs) ? "guest" : "hypervisor";
     3.5          fault_crs[0] = read_cr0();
     3.6          fault_crs[3] = read_cr3();
     3.7 +        fault_regs.ds = read_segment_register(ds);
     3.8 +        fault_regs.es = read_segment_register(es);
     3.9 +        fault_regs.fs = read_segment_register(fs);
    3.10 +        fault_regs.gs = read_segment_register(gs);
    3.11      }
    3.12  
    3.13      printk("----[ Xen-%d.%d%s    %s ]----\n",
    3.14 @@ -57,6 +61,10 @@ void show_registers(struct cpu_user_regs
    3.15             fault_regs.r12, fault_regs.r13, fault_regs.r14);
    3.16      printk("r15: %016lx   cr0: %016lx   cr3: %016lx\n",
    3.17             fault_regs.r15, fault_crs[0], fault_crs[3]);
    3.18 +    printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   "
    3.19 +           "ss: %04x   cs: %04x\n",
    3.20 +           fault_regs.ds, fault_regs.es, fault_regs.fs,
    3.21 +           fault_regs.gs, fault_regs.ss, fault_regs.cs);
    3.22  
    3.23      show_stack(regs);
    3.24  }
     4.1 --- a/xen/include/asm-x86/system.h	Tue Feb 14 18:25:10 2006 +0100
     4.2 +++ b/xen/include/asm-x86/system.h	Tue Feb 14 19:43:45 2006 +0100
     4.3 @@ -5,6 +5,12 @@
     4.4  #include <xen/types.h>
     4.5  #include <asm/bitops.h>
     4.6  
     4.7 +#define read_segment_register(name)                                     \
     4.8 +({  u16 __sel;                                                          \
     4.9 +    __asm__ __volatile__ ( "movw %%" STR(name) ",%0" : "=r" (__sel) );  \
    4.10 +    __sel;                                                              \
    4.11 +})
    4.12 +
    4.13  /* Clear and set 'TS' bit respectively */
    4.14  #define clts() __asm__ __volatile__ ("clts")
    4.15  #define stts() write_cr0(X86_CR0_TS|read_cr0())