ia64/xen-unstable

changeset 3597:ed902e5c4b49

bitkeeper revision 1.1159.212.62 (41fff40aESe4aWS82z_rLHeonXpxuQ)

More x86/64 stuff.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Tue Feb 01 21:26:34 2005 +0000 (2005-02-01)
parents 578b6c14e635
children 11b95fad5f5d 9a9c5a491401
files .rootkeys xen/arch/x86/boot/x86_64.S xen/arch/x86/traps.c xen/arch/x86/vmx.c xen/arch/x86/x86_32/seg_fixup.c xen/arch/x86/x86_64/asm-offsets.c xen/include/asm-x86/desc.h xen/include/asm-x86/processor.h xen/include/asm-x86/regs.h xen/include/asm-x86/x86_32/regs.h xen/include/asm-x86/x86_64/desc.h xen/include/asm-x86/x86_64/regs.h
line diff
     1.1 --- a/.rootkeys	Tue Feb 01 09:24:57 2005 +0000
     1.2 +++ b/.rootkeys	Tue Feb 01 21:26:34 2005 +0000
     1.3 @@ -1042,7 +1042,6 @@ 3e7f358aG11EvMI9VJ4_9hD4LUO7rQ xen/inclu
     1.4  3ddb79c3M2n1ROZH6xk3HbyN4CPDqg xen/include/asm-x86/x86_32/uaccess.h
     1.5  41bf1717bML6GxpclTWJabiaO5W5vg xen/include/asm-x86/x86_64/asm_defns.h
     1.6  404f1b9ceJeGVaPNIENm2FkK0AgEOQ xen/include/asm-x86/x86_64/current.h
     1.7 -404f1b9fl6AQ_a-T1TDK3fuwTPXmHw xen/include/asm-x86/x86_64/desc.h
     1.8  41febc4b1aCGLsm0Y0b_82h7lFtrEA xen/include/asm-x86/x86_64/domain_page.h
     1.9  404f1badfXZJZ2sU8sh9PS2EZvd19Q xen/include/asm-x86/x86_64/ldt.h
    1.10  404f1bb86rAXB3aLS1vYdcqpJiEcyg xen/include/asm-x86/x86_64/regs.h
     2.1 --- a/xen/arch/x86/boot/x86_64.S	Tue Feb 01 09:24:57 2005 +0000
     2.2 +++ b/xen/arch/x86/boot/x86_64.S	Tue Feb 01 21:26:34 2005 +0000
     2.3 @@ -106,10 +106,6 @@ 1:      /* Now in compatibility mode. Lo
     2.4  
     2.5          /* Install relocated selectors (FS/GS unused). */
     2.6          lgdt    gdt_descr(%rip)
     2.7 -        mov     $(__HYPERVISOR_DS),%ecx
     2.8 -        mov     %ecx,%ds
     2.9 -        mov     %ecx,%es
    2.10 -        mov     %ecx,%ss
    2.11  
    2.12          /* Enable full CR4 features. */
    2.13          mov     mmu_cr4_features(%rip),%rcx
    2.14 @@ -164,9 +160,6 @@ int_msg:
    2.15          .asciz "Unknown interrupt\n"
    2.16  ignore_int:
    2.17          cld
    2.18 -        mov     $(__HYPERVISOR_DS),%eax
    2.19 -        mov     %eax,%ds
    2.20 -        mov     %eax,%es
    2.21          lea     int_msg(%rip),%rdi
    2.22          call    SYMBOL_NAME(printf)
    2.23  1:      jmp     1b
     3.1 --- a/xen/arch/x86/traps.c	Tue Feb 01 09:24:57 2005 +0000
     3.2 +++ b/xen/arch/x86/traps.c	Tue Feb 01 21:26:34 2005 +0000
     3.3 @@ -1,5 +1,5 @@
     3.4  /******************************************************************************
     3.5 - * arch/i386/traps.c
     3.6 + * arch/x86/traps.c
     3.7   * 
     3.8   * Modifications to Linux original are copyright (c) 2002-2004, K A Fraser
     3.9   * 
    3.10 @@ -66,8 +66,6 @@ char opt_nmi[10] = "fatal";
    3.11  #endif
    3.12  string_param("nmi", opt_nmi);
    3.13  
    3.14 -#if defined(__i386__)
    3.15 -
    3.16  #define GUEST_FAULT(_r) (likely(VM86_MODE(_r) || !RING_0(_r)))
    3.17  
    3.18  #define DOUBLEFAULT_STACK_SIZE 1024
    3.19 @@ -77,9 +75,9 @@ static unsigned char doublefault_stack[D
    3.20  asmlinkage int hypercall(void);
    3.21  
    3.22  /* Master table, and the one used by CPU0. */
    3.23 -struct desc_struct idt_table[256] = { {0, 0}, };
    3.24 +idt_entry_t idt_table[IDT_ENTRIES] = { {0, 0}, };
    3.25  /* All other CPUs have their own copy. */
    3.26 -struct desc_struct *idt_tables[NR_CPUS] = { 0 };
    3.27 +idt_entry_t *idt_tables[NR_CPUS] = { 0 };
    3.28  
    3.29  asmlinkage void divide_error(void);
    3.30  asmlinkage void debug(void);
    3.31 @@ -112,7 +110,7 @@ static inline int kernel_text_address(un
    3.32  
    3.33  }
    3.34  
    3.35 -void show_guest_stack()
    3.36 +void show_guest_stack(void)
    3.37  {
    3.38      int i;
    3.39      execution_context_t *ec = get_execution_context();
    3.40 @@ -199,11 +197,11 @@ void show_registers(struct xen_regs *reg
    3.41          gs  = __HYPERVISOR_DS;
    3.42      }
    3.43  
    3.44 -    printk("CPU:    %d\nEIP:    %04x:[<%08x>]      \nEFLAGS: %08x\n",
    3.45 +    printk("CPU:    %d\nEIP:    %04lx:[<%08lx>]      \nEFLAGS: %08lx\n",
    3.46             smp_processor_id(), 0xffff & regs->cs, regs->eip, regs->eflags);
    3.47 -    printk("eax: %08x   ebx: %08x   ecx: %08x   edx: %08x\n",
    3.48 +    printk("eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
    3.49             regs->eax, regs->ebx, regs->ecx, regs->edx);
    3.50 -    printk("esi: %08x   edi: %08x   ebp: %08x   esp: %08lx\n",
    3.51 +    printk("esi: %08lx   edi: %08lx   ebp: %08lx   esp: %08lx\n",
    3.52             regs->esi, regs->edi, regs->ebp, esp);
    3.53      printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   ss: %04x\n",
    3.54             ds, es, fs, gs, ss);
    3.55 @@ -283,7 +281,7 @@ static inline int do_trap(int trapnr, ch
    3.56  
    3.57      if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
    3.58      {
    3.59 -        DPRINTK("Trap %d: %08x -> %08lx\n", trapnr, regs->eip, fixup);
    3.60 +        DPRINTK("Trap %d: %08lx -> %08lx\n", trapnr, regs->eip, fixup);
    3.61          regs->eip = fixup;
    3.62          return 0;
    3.63      }
    3.64 @@ -472,7 +470,7 @@ asmlinkage int do_page_fault(struct xen_
    3.65      {
    3.66          perfc_incrc(copy_user_faults);
    3.67          if ( !ed->mm.shadow_mode )
    3.68 -            DPRINTK("Page fault: %08x -> %08lx\n", regs->eip, fixup);
    3.69 +            DPRINTK("Page fault: %08lx -> %08lx\n", regs->eip, fixup);
    3.70          regs->eip = fixup;
    3.71          return 0;
    3.72      }
    3.73 @@ -704,7 +702,7 @@ asmlinkage int do_general_protection(str
    3.74  
    3.75      if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
    3.76      {
    3.77 -        DPRINTK("GPF (%04x): %08x -> %08lx\n",
    3.78 +        DPRINTK("GPF (%04x): %08lx -> %08lx\n",
    3.79                  regs->error_code, regs->eip, fixup);
    3.80          regs->eip = fixup;
    3.81          return 0;
    3.82 @@ -1151,11 +1149,3 @@ unsigned long do_get_debugreg(int reg)
    3.83      if ( (reg < 0) || (reg > 7) ) return -EINVAL;
    3.84      return current->thread.debugreg[reg];
    3.85  }
    3.86 -
    3.87 -#else
    3.88 -
    3.89 -asmlinkage void fatal_trap(int trapnr, struct xen_regs *regs)
    3.90 -{
    3.91 -}
    3.92 -
    3.93 -#endif /* __i386__ */
     4.1 --- a/xen/arch/x86/vmx.c	Tue Feb 01 09:24:57 2005 +0000
     4.2 +++ b/xen/arch/x86/vmx.c	Tue Feb 01 21:26:34 2005 +0000
     4.3 @@ -166,7 +166,7 @@ static void vmx_do_general_protection_fa
     4.4              eip, error_code);
     4.5  
     4.6      VMX_DBG_LOG(DBG_LEVEL_1,
     4.7 -            "eax=%x, ebx=%x, ecx=%x, edx=%x, esi=%x, edi=%x\n",
     4.8 +            "eax=%lx, ebx=%lx, ecx=%lx, edx=%lx, esi=%lx, edi=%lx\n",
     4.9              regs->eax, regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
    4.10  
    4.11      /* Reflect it back into the guest */
    4.12 @@ -186,7 +186,10 @@ static void vmx_vmexit_do_cpuid(unsigned
    4.13      __vmread(GUEST_EIP, &eip);
    4.14  
    4.15      VMX_DBG_LOG(DBG_LEVEL_1, 
    4.16 -            "do_cpuid: (eax) %x, (ebx) %x, (ecx) %x, (edx) %x, (esi) %x, (edi) %x\n", regs->eax, regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
    4.17 +                "do_cpuid: (eax) %lx, (ebx) %lx, (ecx) %lx, (edx) %lx,"
    4.18 +                " (esi) %lx, (edi) %lx\n",
    4.19 +                regs->eax, regs->ebx, regs->ecx, regs->edx,
    4.20 +                regs->esi, regs->edi);
    4.21  
    4.22      cpuid(input, &eax, &ebx, &ecx, &edx);
    4.23  
    4.24 @@ -213,16 +216,16 @@ static void vmx_vmexit_do_cpuid(unsigned
    4.25  static void vmx_dr_access (unsigned long exit_qualification, struct xen_regs *regs)
    4.26  {
    4.27      unsigned int reg;
    4.28 -    u32 *reg_p = 0;
    4.29 +    unsigned long *reg_p = 0;
    4.30      struct exec_domain *ed = current;
    4.31 -    u32 eip;
    4.32 +    unsigned long eip;
    4.33  
    4.34      __vmread(GUEST_EIP, &eip);
    4.35  
    4.36      reg = exit_qualification & DEBUG_REG_ACCESS_NUM;
    4.37  
    4.38      VMX_DBG_LOG(DBG_LEVEL_1, 
    4.39 -                "vmx_dr_access : eip=%08x, reg=%d, exit_qualification = %lx\n",
    4.40 +                "vmx_dr_access : eip=%lx, reg=%d, exit_qualification = %lx\n",
    4.41                  eip, reg, exit_qualification);
    4.42  
    4.43      switch(exit_qualification & DEBUG_REG_ACCESS_REG) {
    4.44 @@ -629,13 +632,14 @@ static void vmx_cr_access (unsigned long
    4.45  
    4.46  static inline void vmx_do_msr_read(struct xen_regs *regs)
    4.47  {
    4.48 -    VMX_DBG_LOG(DBG_LEVEL_1, "vmx_do_msr_read: ecx=%x, eax=%x, edx=%x",
    4.49 +    VMX_DBG_LOG(DBG_LEVEL_1, "vmx_do_msr_read: ecx=%lx, eax=%lx, edx=%lx",
    4.50              regs->ecx, regs->eax, regs->edx);
    4.51  
    4.52      rdmsr(regs->ecx, regs->eax, regs->edx);
    4.53  
    4.54 -    VMX_DBG_LOG(DBG_LEVEL_1, "vmx_do_msr_read returns: ecx=%x, eax=%x, edx=%x",
    4.55 -            regs->ecx, regs->eax, regs->edx);
    4.56 +    VMX_DBG_LOG(DBG_LEVEL_1, "vmx_do_msr_read returns: "
    4.57 +                "ecx=%lx, eax=%lx, edx=%lx",
    4.58 +                regs->ecx, regs->eax, regs->edx);
    4.59  }
    4.60  
    4.61  /*
    4.62 @@ -792,7 +796,9 @@ asmlinkage void vmx_vmexit_handler(struc
    4.63              __vmread(EXIT_QUALIFICATION, &va);
    4.64              __vmread(VM_EXIT_INTR_ERROR_CODE, &error_code);
    4.65              VMX_DBG_LOG(DBG_LEVEL_VMMU, 
    4.66 -                    "eax=%x, ebx=%x, ecx=%x, edx=%x, esi=%x, edi=%x\n", regs.eax, regs.ebx, regs.ecx, regs.edx, regs.esi, regs.edi);
    4.67 +                    "eax=%lx, ebx=%lx, ecx=%lx, edx=%lx, esi=%lx, edi=%lx\n",
    4.68 +                        regs.eax, regs.ebx, regs.ecx, regs.edx, regs.esi,
    4.69 +                        regs.edi);
    4.70              d->thread.arch_vmx.vmx_platform.mpci.inst_decoder_regs = &regs;
    4.71  
    4.72              if (!(error = vmx_do_page_fault(va, error_code))) {
    4.73 @@ -907,7 +913,7 @@ asmlinkage void vmx_vmexit_handler(struc
    4.74          break;
    4.75      case EXIT_REASON_MSR_WRITE:
    4.76          __vmread(GUEST_EIP, &eip);
    4.77 -        VMX_DBG_LOG(DBG_LEVEL_1, "MSR_WRITE: eip=%08lx, eax=%08x, edx=%08x",
    4.78 +        VMX_DBG_LOG(DBG_LEVEL_1, "MSR_WRITE: eip=%08lx, eax=%08lx, edx=%08lx",
    4.79                  eip, regs.eax, regs.edx);
    4.80          /* just ignore this point */
    4.81          __get_instruction_length(inst_len);
     5.1 --- a/xen/arch/x86/x86_32/seg_fixup.c	Tue Feb 01 09:24:57 2005 +0000
     5.2 +++ b/xen/arch/x86/x86_32/seg_fixup.c	Tue Feb 01 21:26:34 2005 +0000
     5.3 @@ -292,7 +292,7 @@ int gpf_emulate_4gb(struct xen_regs *reg
     5.4      u32           disp32 = 0;
     5.5      u8            *eip;         /* ptr to instruction start */
     5.6      u8            *pb, b;       /* ptr into instr. / current instr. byte */
     5.7 -    unsigned int  *pseg = NULL; /* segment for memory operand (NULL=default) */
     5.8 +    unsigned long *pseg = NULL; /* segment for memory operand (NULL=default) */
     5.9  
    5.10      /* WARNING: We only work for ring-3 segments. */
    5.11      if ( unlikely(VM86_MODE(regs)) || unlikely(!RING_3(regs)) )
     6.1 --- a/xen/arch/x86/x86_64/asm-offsets.c	Tue Feb 01 09:24:57 2005 +0000
     6.2 +++ b/xen/arch/x86/x86_64/asm-offsets.c	Tue Feb 01 21:26:34 2005 +0000
     6.3 @@ -30,7 +30,8 @@ void __dummy__(void)
     6.4      OFFSET(XREGS_rdx, struct xen_regs, rdx);
     6.5      OFFSET(XREGS_rsi, struct xen_regs, rsi);
     6.6      OFFSET(XREGS_rdi, struct xen_regs, rdi);
     6.7 -    OFFSET(XREGS_orig_rax, struct xen_regs, orig_rax);
     6.8 +    OFFSET(XREGS_error_code, struct xen_regs, error_code);
     6.9 +    OFFSET(XREGS_entry_vector, struct xen_regs, entry_vector);
    6.10      OFFSET(XREGS_rip, struct xen_regs, rip);
    6.11      OFFSET(XREGS_cs, struct xen_regs, cs);
    6.12      OFFSET(XREGS_eflags, struct xen_regs, eflags);
     7.1 --- a/xen/include/asm-x86/desc.h	Tue Feb 01 09:24:57 2005 +0000
     7.2 +++ b/xen/include/asm-x86/desc.h	Tue Feb 01 21:26:34 2005 +0000
     7.3 @@ -40,15 +40,24 @@
     7.4  
     7.5  #ifndef __ASSEMBLY__
     7.6  struct desc_struct {
     7.7 -	unsigned long a,b;
     7.8 +    u32 a, b;
     7.9  };
    7.10  
    7.11 +#if defined(__x86_64__)
    7.12 +typedef struct {
    7.13 +    u64 a, b;
    7.14 +} idt_entry_t;
    7.15 +#elif defined(__i386__)
    7.16 +typedef struct desc_struct idt_entry_t;
    7.17 +#endif
    7.18 +
    7.19  extern struct desc_struct gdt_table[];
    7.20 -extern struct desc_struct *idt, *gdt;
    7.21 +extern struct desc_struct *gdt;
    7.22 +extern idt_entry_t        *idt;
    7.23  
    7.24  struct Xgt_desc_struct {
    7.25 -	unsigned short size;
    7.26 -	unsigned long address __attribute__((packed));
    7.27 +    unsigned short size;
    7.28 +    unsigned long address __attribute__((packed));
    7.29  };
    7.30  
    7.31  #define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
     8.1 --- a/xen/include/asm-x86/processor.h	Tue Feb 01 09:24:57 2005 +0000
     8.2 +++ b/xen/include/asm-x86/processor.h	Tue Feb 01 21:26:34 2005 +0000
     8.3 @@ -438,8 +438,8 @@ struct thread_struct {
     8.4  };
     8.5  
     8.6  #define IDT_ENTRIES 256
     8.7 -extern struct desc_struct idt_table[];
     8.8 -extern struct desc_struct *idt_tables[];
     8.9 +extern idt_entry_t idt_table[];
    8.10 +extern idt_entry_t *idt_tables[];
    8.11  
    8.12  #if defined(__i386__)
    8.13  
     9.1 --- a/xen/include/asm-x86/regs.h	Tue Feb 01 09:24:57 2005 +0000
     9.2 +++ b/xen/include/asm-x86/regs.h	Tue Feb 01 21:26:34 2005 +0000
     9.3 @@ -1,6 +1,34 @@
     9.4 +
     9.5 +#ifndef __X86_REGS_H__
     9.6 +#define __X86_REGS_H__
     9.7  
     9.8  #ifdef __x86_64__
     9.9  #include <asm/x86_64/regs.h>
    9.10  #else
    9.11  #include <asm/x86_32/regs.h>
    9.12  #endif
    9.13 +
    9.14 +enum EFLAGS {
    9.15 +    EF_CF   = 0x00000001,
    9.16 +    EF_PF   = 0x00000004,
    9.17 +    EF_AF   = 0x00000010,
    9.18 +    EF_ZF   = 0x00000040,
    9.19 +    EF_SF   = 0x00000080,
    9.20 +    EF_TF   = 0x00000100,
    9.21 +    EF_IE   = 0x00000200,
    9.22 +    EF_DF   = 0x00000400,
    9.23 +    EF_OF   = 0x00000800,
    9.24 +    EF_IOPL = 0x00003000,
    9.25 +    EF_IOPL_RING0 = 0x00000000,
    9.26 +    EF_IOPL_RING1 = 0x00001000,
    9.27 +    EF_IOPL_RING2 = 0x00002000,
    9.28 +    EF_NT   = 0x00004000,   /* nested task */
    9.29 +    EF_RF   = 0x00010000,   /* resume */
    9.30 +    EF_VM   = 0x00020000,   /* virtual mode */
    9.31 +    EF_AC   = 0x00040000,   /* alignment */
    9.32 +    EF_VIF  = 0x00080000,   /* virtual interrupt */
    9.33 +    EF_VIP  = 0x00100000,   /* virtual interrupt pending */
    9.34 +    EF_ID   = 0x00200000,   /* id */
    9.35 +};
    9.36 +
    9.37 +#endif /* __X86_REGS_H__ */
    10.1 --- a/xen/include/asm-x86/x86_32/regs.h	Tue Feb 01 09:24:57 2005 +0000
    10.2 +++ b/xen/include/asm-x86/x86_32/regs.h	Tue Feb 01 21:26:34 2005 +0000
    10.3 @@ -3,6 +3,9 @@
    10.4  
    10.5  #include <asm/types.h>
    10.6  
    10.7 +/* So that we can use 'l' modifier in printf-style format strings. */
    10.8 +#define u32 unsigned long
    10.9 +
   10.10  struct xen_regs
   10.11  {
   10.12      /* All saved activations contain the following fields. */
   10.13 @@ -28,28 +31,7 @@ struct xen_regs
   10.14      u32 gs;
   10.15  } __attribute__ ((packed));
   10.16  
   10.17 -enum EFLAGS {
   10.18 -    EF_CF   = 0x00000001,
   10.19 -    EF_PF   = 0x00000004,
   10.20 -    EF_AF   = 0x00000010,
   10.21 -    EF_ZF   = 0x00000040,
   10.22 -    EF_SF   = 0x00000080,
   10.23 -    EF_TF   = 0x00000100,
   10.24 -    EF_IE   = 0x00000200,
   10.25 -    EF_DF   = 0x00000400,
   10.26 -    EF_OF   = 0x00000800,
   10.27 -    EF_IOPL = 0x00003000,
   10.28 -    EF_IOPL_RING0 = 0x00000000,
   10.29 -    EF_IOPL_RING1 = 0x00001000,
   10.30 -    EF_IOPL_RING2 = 0x00002000,
   10.31 -    EF_NT   = 0x00004000,   /* nested task */
   10.32 -    EF_RF   = 0x00010000,   /* resume */
   10.33 -    EF_VM   = 0x00020000,   /* virtual mode */
   10.34 -    EF_AC   = 0x00040000,   /* alignment */
   10.35 -    EF_VIF  = 0x00080000,   /* virtual interrupt */
   10.36 -    EF_VIP  = 0x00100000,   /* virtual interrupt pending */
   10.37 -    EF_ID   = 0x00200000,   /* id */
   10.38 -};
   10.39 +#undef u32
   10.40  
   10.41  #define VM86_MODE(_r) ((_r)->eflags & EF_VM)
   10.42  #define RING_0(_r)    (((_r)->cs & 3) == 0)
    11.1 --- a/xen/include/asm-x86/x86_64/desc.h	Tue Feb 01 09:24:57 2005 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,118 +0,0 @@
    11.4 -#ifndef __ARCH_DESC_H
    11.5 -#define __ARCH_DESC_H
    11.6 -
    11.7 -#define LDT_ENTRY_SIZE 16
    11.8 -
    11.9 -#define __DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY
   11.10 -
   11.11 -#define __FIRST_PER_CPU_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8)
   11.12 -
   11.13 -#define __CPU_DESC_INDEX(x,field) \
   11.14 -	((x) * sizeof(struct per_cpu_gdt) + offsetof(struct per_cpu_gdt, field) + (__FIRST_PER_CPU_ENTRY*8))
   11.15 -#define __LDT(n) (((n)<<1) + __FIRST_LDT_ENTRY)
   11.16 -
   11.17 -#define load_TR(cpu) asm volatile("ltr %w0"::"r" (__CPU_DESC_INDEX(cpu, tss)));
   11.18 -#define __load_LDT(cpu) asm volatile("lldt %w0"::"r" (__CPU_DESC_INDEX(cpu, ldt)));
   11.19 -#define clear_LDT(n)  asm volatile("lldt %w0"::"r" (0))
   11.20 -
   11.21 -/*
   11.22 - * Guest OS must provide its own code selectors, or use the one we provide. The
   11.23 - * RPL must be 1, as we only create bounce frames to ring 1. Any LDT selector
   11.24 - * value is okay. Note that checking only the RPL is insufficient: if the
   11.25 - * selector is poked into an interrupt, trap or call gate then the RPL is
   11.26 - * ignored when the gate is accessed.
   11.27 - */
   11.28 -#define VALID_SEL(_s)                                                      \
   11.29 -    (((((_s)>>3) < FIRST_RESERVED_GDT_ENTRY) ||                            \
   11.30 -      (((_s)>>3) >  LAST_RESERVED_GDT_ENTRY) ||                            \
   11.31 -      ((_s)&4)) &&                                                         \
   11.32 -     (((_s)&3) == 0))
   11.33 -#define VALID_CODESEL(_s) ((_s) == FLAT_RING3_CS || VALID_SEL(_s))
   11.34 -
   11.35 -/* These are bitmasks for the first 32 bits of a descriptor table entry. */
   11.36 -#define _SEGMENT_TYPE    (15<< 8)
   11.37 -#define _SEGMENT_S       ( 1<<12) /* System descriptor (yes iff S==0) */
   11.38 -#define _SEGMENT_DPL     ( 3<<13) /* Descriptor Privilege Level */
   11.39 -#define _SEGMENT_P       ( 1<<15) /* Segment Present */
   11.40 -#define _SEGMENT_G       ( 1<<23) /* Granularity */
   11.41 -
   11.42 -#ifndef __ASSEMBLY__
   11.43 -
   11.44 -enum { 
   11.45 -	GATE_INTERRUPT = 0xE, 
   11.46 -	GATE_TRAP = 0xF, 	
   11.47 -	GATE_CALL = 0xC,
   11.48 -}; 	
   11.49 -
   11.50 -// 16byte gate
   11.51 -struct gate_struct {          
   11.52 -	u16 offset_low;
   11.53 -	u16 segment; 
   11.54 -	unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
   11.55 -	u16 offset_middle;
   11.56 -	u32 offset_high;
   11.57 -	u32 zero1; 
   11.58 -} __attribute__((packed));
   11.59 -
   11.60 -// 8 byte segment descriptor
   11.61 -struct desc_struct { 
   11.62 -	u16 limit0;
   11.63 -	u16 base0;
   11.64 -	unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
   11.65 -	unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
   11.66 -} __attribute__((packed)); 
   11.67 -
   11.68 -// LDT or TSS descriptor in the GDT. 16 bytes.
   11.69 -struct ldttss_desc { 
   11.70 -	u16 limit0;
   11.71 -	u16 base0;
   11.72 -	unsigned base1 : 8, type : 5, dpl : 2, p : 1;
   11.73 -	unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
   11.74 -	u32 base3;
   11.75 -	u32 zero1; 
   11.76 -} __attribute__((packed)); 
   11.77 -
   11.78 -// Union of above structures
   11.79 -union desc_union {
   11.80 -	struct desc_struct seg;
   11.81 -	struct ldttss_desc ldttss;
   11.82 -	struct gate_struct gate;
   11.83 -};
   11.84 -
   11.85 -struct per_cpu_gdt {
   11.86 -	struct ldttss_desc tss;
   11.87 -	struct ldttss_desc ldt; 
   11.88 -} __cacheline_aligned; 
   11.89 -
   11.90 -
   11.91 -struct Xgt_desc_struct {
   11.92 -	unsigned short size;
   11.93 -	unsigned long address;
   11.94 -} __attribute__((packed));
   11.95 -
   11.96 -extern __u8 gdt_table[];
   11.97 -extern __u8 gdt_end[];
   11.98 -extern union desc_union *gdt; 
   11.99 -
  11.100 -extern struct per_cpu_gdt gdt_cpu_table[]; 
  11.101 -
  11.102 -#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF) 
  11.103 -#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
  11.104 -#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
  11.105 -
  11.106 -enum { 
  11.107 -	DESC_TSS = 0x9,
  11.108 -	DESC_LDT = 0x2,
  11.109 -}; 
  11.110 -
  11.111 -extern struct gate_struct *idt;
  11.112 -
  11.113 -#define idt_descr (*(struct Xgt_desc_struct *)((char *)&idt - 2))
  11.114 -#define gdt_descr (*(struct Xgt_desc_struct *)((char *)&gdt - 2))
  11.115 -
  11.116 -extern void set_intr_gate(unsigned int irq, void * addr);
  11.117 -extern void set_tss_desc(unsigned int n, void *addr);
  11.118 -
  11.119 -#endif /* !__ASSEMBLY__ */
  11.120 -
  11.121 -#endif
    12.1 --- a/xen/include/asm-x86/x86_64/regs.h	Tue Feb 01 09:24:57 2005 +0000
    12.2 +++ b/xen/include/asm-x86/x86_64/regs.h	Tue Feb 01 21:26:34 2005 +0000
    12.3 @@ -1,114 +1,38 @@
    12.4  #ifndef _X86_64_REGS_H
    12.5  #define _X86_64_REGS_H
    12.6  
    12.7 -#if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS) 
    12.8 -#define R15 0
    12.9 -#define R14 8
   12.10 -#define R13 16
   12.11 -#define R12 24
   12.12 -#define RBP 36
   12.13 -#define RBX 40
   12.14 -/* arguments: interrupts/hypercalls only save upto here*/
   12.15 -#define R11 48
   12.16 -#define R10 56	
   12.17 -#define R9 64
   12.18 -#define R8 72
   12.19 -#define RAX 80
   12.20 -#define RCX 88
   12.21 -#define RDX 96
   12.22 -#define RSI 104
   12.23 -#define RDI 112
   12.24 -#define ORIG_RAX 120       /* = ERROR */ 
   12.25 -/* end of arguments */ 	
   12.26 -/* cpu exception frame or undefined in case of fast hypercall. */
   12.27 -#define RIP 128
   12.28 -#define CS 136
   12.29 -#define EFLAGS 144
   12.30 -#define RSP 152
   12.31 -#define SS 160
   12.32 -#define ARGOFFSET R11
   12.33 -#endif /* __ASSEMBLY__ */
   12.34 -
   12.35 -/* top of stack page */ 
   12.36 -#define FRAME_SIZE 168
   12.37 -
   12.38 -#define PTRACE_SETOPTIONS         21
   12.39 +#include <asm/types.h>
   12.40  
   12.41 -/* options set using PTRACE_SETOPTIONS */
   12.42 -#define PTRACE_O_TRACESYSGOOD     0x00000001
   12.43 -
   12.44 -/* Dummy values for ptrace */ 
   12.45 -#define FS 1000 
   12.46 -#define GS 1008
   12.47 -
   12.48 -#ifndef __ASSEMBLY__ 
   12.49 +struct xen_regs
   12.50 +{
   12.51 +    u64 r15;
   12.52 +    u64 r14;
   12.53 +    u64 r13;
   12.54 +    u64 r12;
   12.55 +    u64 rbp;
   12.56 +    u64 rbx;
   12.57 +    u64 r11;
   12.58 +    u64 r10;	
   12.59 +    u64 r9;
   12.60 +    u64 r8;
   12.61 +    u64 rax;
   12.62 +    u64 rcx;
   12.63 +    u64 rdx;
   12.64 +    u64 rsi;
   12.65 +    u64 rdi;
   12.66 +    u32 error_code;
   12.67 +    u32 entry_vector;
   12.68 +    u64 rip;
   12.69 +    u64 cs;
   12.70 +    u64 eflags;
   12.71 +    u64 rsp;
   12.72 +    u64 ss;
   12.73 +} __attribute__ ((packed));
   12.74  
   12.75 -struct xen_regs {
   12.76 -	unsigned long r15;
   12.77 -	unsigned long r14;
   12.78 -	unsigned long r13;
   12.79 -	unsigned long r12;
   12.80 -	unsigned long rbp;
   12.81 -	unsigned long rbx;
   12.82 -/* arguments: non interrupts/hypercalls only save upto here*/
   12.83 - 	unsigned long r11;
   12.84 -	unsigned long r10;	
   12.85 -	unsigned long r9;
   12.86 -	unsigned long r8;
   12.87 -	unsigned long rax;
   12.88 -	unsigned long rcx;
   12.89 -	unsigned long rdx;
   12.90 -	unsigned long rsi;
   12.91 -	unsigned long rdi;
   12.92 -	unsigned long orig_rax;
   12.93 -/* end of arguments */ 	
   12.94 -/* cpu exception frame or undefined */
   12.95 -	unsigned long rip;
   12.96 -	unsigned long cs;
   12.97 -	unsigned long eflags; 
   12.98 -	unsigned long rsp; 
   12.99 -	unsigned long ss;
  12.100 -/* top of stack page */ 
  12.101 -};
  12.102 +#define VM86_MODE(_r) ((_r)->eflags & EF_VM)
  12.103 +#define RING_0(_r)    (((_r)->cs & 3) == 0)
  12.104 +#define RING_1(_r)    (((_r)->cs & 3) == 1)
  12.105 +#define RING_2(_r)    (((_r)->cs & 3) == 2)
  12.106 +#define RING_3(_r)    (((_r)->cs & 3) == 3)
  12.107  
  12.108  #endif
  12.109 -
  12.110 -/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
  12.111 -#define PTRACE_GETREGS            12
  12.112 -#define PTRACE_SETREGS            13
  12.113 -#define PTRACE_GETFPREGS          14
  12.114 -#define PTRACE_SETFPREGS          15
  12.115 -#define PTRACE_GETFPXREGS         18
  12.116 -#define PTRACE_SETFPXREGS         19
  12.117 -
  12.118 -#if !defined(__ASSEMBLY__) 
  12.119 -
  12.120 -#define instruction_pointer(regs) ((regs)->rip)
  12.121 -extern void show_regs(struct xen_regs *);
  12.122 -
  12.123 -enum {
  12.124 -        EF_CF   = 0x00000001,
  12.125 -        EF_PF   = 0x00000004,
  12.126 -        EF_AF   = 0x00000010,
  12.127 -        EF_ZF   = 0x00000040,
  12.128 -        EF_SF   = 0x00000080,
  12.129 -        EF_TF   = 0x00000100,
  12.130 -        EF_IE   = 0x00000200,
  12.131 -        EF_DF   = 0x00000400,
  12.132 -        EF_OF   = 0x00000800,
  12.133 -        EF_IOPL = 0x00003000,
  12.134 -        EF_IOPL_RING0 = 0x00000000,
  12.135 -        EF_IOPL_RING1 = 0x00001000,
  12.136 -        EF_IOPL_RING2 = 0x00002000,
  12.137 -        EF_NT   = 0x00004000,   /* nested task */
  12.138 -        EF_RF   = 0x00010000,   /* resume */
  12.139 -        EF_VM   = 0x00020000,   /* virtual mode */
  12.140 -        EF_AC   = 0x00040000,   /* alignment */
  12.141 -        EF_VIF  = 0x00080000,   /* virtual interrupt */
  12.142 -        EF_VIP  = 0x00100000,   /* virtual interrupt pending */
  12.143 -        EF_ID   = 0x00200000,   /* id */
  12.144 -};
  12.145 -
  12.146 -#endif
  12.147 -
  12.148 -#endif