Home | History | Annotate | Download | only in vki
      1 #ifndef __VKI_XEN_X86_H
      2 #define __VKI_XEN_X86_H
      3 
      4 #if defined(__i386__)
      5 #define ___DEFINE_VKI_XEN_GUEST_HANDLE(name, type)			\
      6     typedef struct { type *p; }						\
      7         __vki_xen_guest_handle_ ## name;                                \
      8     typedef struct { union { type *p; vki_xen_uint64_aligned_t q; }; }  \
      9         __vki_xen_guest_handle_64_ ## name
     10 #define vki_xen_uint64_aligned_t vki_uint64_t __attribute__((aligned(8)))
     11 #define __VKI_XEN_GUEST_HANDLE_64(name) __vki_xen_guest_handle_64_ ## name
     12 #define VKI_XEN_GUEST_HANDLE_64(name) __VKI_XEN_GUEST_HANDLE_64(name)
     13 #else
     14 #define ___DEFINE_VKI_XEN_GUEST_HANDLE(name, type) \
     15     typedef struct { type *p; } __vki_xen_guest_handle_ ## name
     16 #define vki_xen_uint64_aligned_t vki_uint64_t
     17 #define __DEFINE_VKI_XEN_GUEST_HANDLE(name, type) \
     18     ___DEFINE_VKI_XEN_GUEST_HANDLE(name, type);   \
     19     ___DEFINE_VKI_XEN_GUEST_HANDLE(const_##name, const type)
     20 #define DEFINE_VKI_XEN_GUEST_HANDLE(name)   __DEFINE_VKI_XEN_GUEST_HANDLE(name, name)
     21 #define VKI_XEN_GUEST_HANDLE_64(name) VKI_XEN_GUEST_HANDLE(name)
     22 #endif
     23 
     24 #define __VKI_XEN_GUEST_HANDLE(name)  __vki_xen_guest_handle_ ## name
     25 #define VKI_XEN_GUEST_HANDLE(name)    __VKI_XEN_GUEST_HANDLE(name)
     26 
     27 typedef unsigned long vki_xen_pfn_t;
     28 typedef unsigned long vki_xen_ulong_t;
     29 
     30 #if defined(__i386__)
     31 struct vki_xen_cpu_user_regs {
     32     vki_uint32_t ebx;
     33     vki_uint32_t ecx;
     34     vki_uint32_t edx;
     35     vki_uint32_t esi;
     36     vki_uint32_t edi;
     37     vki_uint32_t ebp;
     38     vki_uint32_t eax;
     39     vki_uint16_t error_code;    /* private */
     40     vki_uint16_t entry_vector;  /* private */
     41     vki_uint32_t eip;
     42     vki_uint16_t cs;
     43     vki_uint8_t  saved_upcall_mask;
     44     vki_uint8_t  _pad0;
     45     vki_uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
     46     vki_uint32_t esp;
     47     vki_uint16_t ss, _pad1;
     48     vki_uint16_t es, _pad2;
     49     vki_uint16_t ds, _pad3;
     50     vki_uint16_t fs, _pad4;
     51     vki_uint16_t gs, _pad5;
     52 };
     53 #else
     54 struct vki_xen_cpu_user_regs {
     55     vki_uint64_t r15;
     56     vki_uint64_t r14;
     57     vki_uint64_t r13;
     58     vki_uint64_t r12;
     59     vki_uint64_t rbp;
     60     vki_uint64_t rbx;
     61     vki_uint64_t r11;
     62     vki_uint64_t r10;
     63     vki_uint64_t r9;
     64     vki_uint64_t r8;
     65     vki_uint64_t rax;
     66     vki_uint64_t rcx;
     67     vki_uint64_t rdx;
     68     vki_uint64_t rsi;
     69     vki_uint64_t rdi;
     70     vki_uint32_t error_code;    /* private */
     71     vki_uint32_t entry_vector;  /* private */
     72     vki_uint64_t rip;
     73     vki_uint16_t cs, _pad0[1];
     74     vki_uint8_t  saved_upcall_mask;
     75     vki_uint8_t  _pad1[3];
     76     vki_uint64_t rflags;      /* rflags.IF == !saved_upcall_mask */
     77     vki_uint64_t rsp;
     78     vki_uint16_t ss, _pad2[3];
     79     vki_uint16_t es, _pad3[3];
     80     vki_uint16_t ds, _pad4[3];
     81     vki_uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
     82     vki_uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
     83 };
     84 #endif
     85 
     86 struct vki_xen_trap_info {
     87     vki_uint8_t   vector;  /* exception vector                              */
     88     vki_uint8_t   flags;   /* 0-3: privilege level; 4: clear event enable?  */
     89     vki_uint16_t  cs;      /* code selector                                 */
     90     unsigned long address; /* code offset                                   */
     91 };
     92 
     93 struct vki_xen_vcpu_guest_context {
     94     /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
     95     struct { char x[512]; } fpu_ctxt;       /* User-level FPU registers     */
     96     unsigned long flags;                    /* VGCF_* flags                 */
     97     struct vki_xen_cpu_user_regs user_regs; /* User-level CPU registers     */
     98     struct vki_xen_trap_info trap_ctxt[256];/* Virtual IDT                  */
     99     unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
    100     unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
    101     unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
    102     /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
    103     unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
    104     unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
    105 #ifdef __i386__
    106     unsigned long event_callback_cs;        /* CS:EIP of event callback     */
    107     unsigned long event_callback_eip;
    108     unsigned long failsafe_callback_cs;     /* CS:EIP of failsafe callback  */
    109     unsigned long failsafe_callback_eip;
    110 #else
    111     unsigned long event_callback_eip;
    112     unsigned long failsafe_callback_eip;
    113     unsigned long syscall_callback_eip;
    114 #endif
    115     unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
    116 #ifdef __x86_64__
    117     /* Segment base addresses. */
    118     vki_uint64_t  fs_base;
    119     vki_uint64_t  gs_base_kernel;
    120     vki_uint64_t  gs_base_user;
    121 #endif
    122 };
    123 typedef struct vki_xen_vcpu_guest_context vki_xen_vcpu_guest_context_t;
    124 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_vcpu_guest_context_t);
    125 
    126 #endif // __VKI_XEN_H
    127 
    128 /*--------------------------------------------------------------------*/
    129 /*--- end                                                          ---*/
    130 /*--------------------------------------------------------------------*/
    131