ia64/xen-unstable

changeset 13162:71c40c3f92f7

Create new public header directory for x86-specific definitions.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Dec 21 16:20:11 2006 +0000 (2006-12-21)
parents 8348f40ba2b7
children 2ae2204bbef3
files tools/Rules.mk xen/include/public/arch-x86/xen-x86_32.h xen/include/public/arch-x86/xen-x86_64.h xen/include/public/arch-x86/xen.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h xen/include/public/xen.h
line diff
     1.1 --- a/tools/Rules.mk	Thu Dec 21 14:49:19 2006 +0000
     1.2 +++ b/tools/Rules.mk	Thu Dec 21 16:20:11 2006 +0000
     1.3 @@ -50,5 +50,7 @@ mk-symlinks-xen:
     1.4  	( cd xen/hvm && ln -sf ../../$(XEN_ROOT)/xen/include/public/hvm/*.h . )
     1.5  	mkdir -p xen/io
     1.6  	( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
     1.7 +	mkdir -p xen/arch-x86
     1.8 +	( cd xen/arch-x86 && ln -sf ../../$(XEN_ROOT)/xen/include/public/arch-x86/*.h . )
     1.9  
    1.10  mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/include/public/arch-x86/xen-x86_32.h	Thu Dec 21 16:20:11 2006 +0000
     2.3 @@ -0,0 +1,151 @@
     2.4 +/******************************************************************************
     2.5 + * xen-x86_32.h
     2.6 + * 
     2.7 + * Guest OS interface to x86 32-bit Xen.
     2.8 + * 
     2.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    2.10 + * of this software and associated documentation files (the "Software"), to
    2.11 + * deal in the Software without restriction, including without limitation the
    2.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    2.13 + * sell copies of the Software, and to permit persons to whom the Software is
    2.14 + * furnished to do so, subject to the following conditions:
    2.15 + *
    2.16 + * The above copyright notice and this permission notice shall be included in
    2.17 + * all copies or substantial portions of the Software.
    2.18 + *
    2.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    2.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    2.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    2.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    2.25 + * DEALINGS IN THE SOFTWARE.
    2.26 + *
    2.27 + * Copyright (c) 2004-2006, K A Fraser
    2.28 + */
    2.29 +
    2.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
    2.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
    2.32 +
    2.33 +/*
    2.34 + * Hypercall interface:
    2.35 + *  Input:  %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
    2.36 + *  Output: %eax
    2.37 + * Access is via hypercall page (set up by guest loader or via a Xen MSR):
    2.38 + *  call hypercall_page + hypercall-number * 32
    2.39 + * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
    2.40 + */
    2.41 +
    2.42 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
    2.43 +/*
    2.44 + * Legacy hypercall interface:
    2.45 + * As above, except the entry sequence to the hypervisor is:
    2.46 + *  mov $hypercall-number*32,%eax ; int $0x82
    2.47 + */
    2.48 +#define TRAP_INSTR "int $0x82"
    2.49 +#endif
    2.50 +
    2.51 +/*
    2.52 + * These flat segments are in the Xen-private section of every GDT. Since these
    2.53 + * are also present in the initial GDT, many OSes will be able to avoid
    2.54 + * installing their own GDT.
    2.55 + */
    2.56 +#define FLAT_RING1_CS 0xe019    /* GDT index 259 */
    2.57 +#define FLAT_RING1_DS 0xe021    /* GDT index 260 */
    2.58 +#define FLAT_RING1_SS 0xe021    /* GDT index 260 */
    2.59 +#define FLAT_RING3_CS 0xe02b    /* GDT index 261 */
    2.60 +#define FLAT_RING3_DS 0xe033    /* GDT index 262 */
    2.61 +#define FLAT_RING3_SS 0xe033    /* GDT index 262 */
    2.62 +
    2.63 +#define FLAT_KERNEL_CS FLAT_RING1_CS
    2.64 +#define FLAT_KERNEL_DS FLAT_RING1_DS
    2.65 +#define FLAT_KERNEL_SS FLAT_RING1_SS
    2.66 +#define FLAT_USER_CS    FLAT_RING3_CS
    2.67 +#define FLAT_USER_DS    FLAT_RING3_DS
    2.68 +#define FLAT_USER_SS    FLAT_RING3_SS
    2.69 +
    2.70 +/*
    2.71 + * Virtual addresses beyond this are not modifiable by guest OSes. The 
    2.72 + * machine->physical mapping table starts at this address, read-only.
    2.73 + */
    2.74 +#ifdef CONFIG_X86_PAE
    2.75 +#define __HYPERVISOR_VIRT_START 0xF5800000
    2.76 +#define __MACH2PHYS_VIRT_START  0xF5800000
    2.77 +#define __MACH2PHYS_VIRT_END    0xF6800000
    2.78 +#else
    2.79 +#define __HYPERVISOR_VIRT_START 0xFC000000
    2.80 +#define __MACH2PHYS_VIRT_START  0xFC000000
    2.81 +#define __MACH2PHYS_VIRT_END    0xFC400000
    2.82 +#endif
    2.83 +
    2.84 +#ifndef HYPERVISOR_VIRT_START
    2.85 +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
    2.86 +#endif
    2.87 +
    2.88 +#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
    2.89 +#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
    2.90 +#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
    2.91 +#ifndef machine_to_phys_mapping
    2.92 +#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
    2.93 +#endif
    2.94 +
    2.95 +#ifndef __ASSEMBLY__
    2.96 +
    2.97 +struct cpu_user_regs {
    2.98 +    uint32_t ebx;
    2.99 +    uint32_t ecx;
   2.100 +    uint32_t edx;
   2.101 +    uint32_t esi;
   2.102 +    uint32_t edi;
   2.103 +    uint32_t ebp;
   2.104 +    uint32_t eax;
   2.105 +    uint16_t error_code;    /* private */
   2.106 +    uint16_t entry_vector;  /* private */
   2.107 +    uint32_t eip;
   2.108 +    uint16_t cs;
   2.109 +    uint8_t  saved_upcall_mask;
   2.110 +    uint8_t  _pad0;
   2.111 +    uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
   2.112 +    uint32_t esp;
   2.113 +    uint16_t ss, _pad1;
   2.114 +    uint16_t es, _pad2;
   2.115 +    uint16_t ds, _pad3;
   2.116 +    uint16_t fs, _pad4;
   2.117 +    uint16_t gs, _pad5;
   2.118 +};
   2.119 +typedef struct cpu_user_regs cpu_user_regs_t;
   2.120 +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
   2.121 +
   2.122 +/*
   2.123 + * Page-directory addresses above 4GB do not fit into architectural %cr3.
   2.124 + * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
   2.125 + * must use the following accessor macros to pack/unpack valid MFNs.
   2.126 + */
   2.127 +#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
   2.128 +#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
   2.129 +
   2.130 +struct arch_vcpu_info {
   2.131 +    unsigned long cr2;
   2.132 +    unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
   2.133 +};
   2.134 +typedef struct arch_vcpu_info arch_vcpu_info_t;
   2.135 +
   2.136 +struct xen_callback {
   2.137 +    unsigned long cs;
   2.138 +    unsigned long eip;
   2.139 +};
   2.140 +typedef struct xen_callback xen_callback_t;
   2.141 +
   2.142 +#endif /* !__ASSEMBLY__ */
   2.143 +
   2.144 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
   2.145 +
   2.146 +/*
   2.147 + * Local variables:
   2.148 + * mode: C
   2.149 + * c-set-style: "BSD"
   2.150 + * c-basic-offset: 4
   2.151 + * tab-width: 4
   2.152 + * indent-tabs-mode: nil
   2.153 + * End:
   2.154 + */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/include/public/arch-x86/xen-x86_64.h	Thu Dec 21 16:20:11 2006 +0000
     3.3 @@ -0,0 +1,208 @@
     3.4 +/******************************************************************************
     3.5 + * xen-x86_64.h
     3.6 + * 
     3.7 + * Guest OS interface to x86 64-bit Xen.
     3.8 + * 
     3.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    3.10 + * of this software and associated documentation files (the "Software"), to
    3.11 + * deal in the Software without restriction, including without limitation the
    3.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    3.13 + * sell copies of the Software, and to permit persons to whom the Software is
    3.14 + * furnished to do so, subject to the following conditions:
    3.15 + *
    3.16 + * The above copyright notice and this permission notice shall be included in
    3.17 + * all copies or substantial portions of the Software.
    3.18 + *
    3.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    3.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    3.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    3.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    3.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    3.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    3.25 + * DEALINGS IN THE SOFTWARE.
    3.26 + *
    3.27 + * Copyright (c) 2004-2006, K A Fraser
    3.28 + */
    3.29 +
    3.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
    3.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
    3.32 +
    3.33 +/*
    3.34 + * Hypercall interface:
    3.35 + *  Input:  %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5)
    3.36 + *  Output: %rax
    3.37 + * Access is via hypercall page (set up by guest loader or via a Xen MSR):
    3.38 + *  call hypercall_page + hypercall-number * 32
    3.39 + * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi)
    3.40 + */
    3.41 +
    3.42 +#if __XEN_INTERFACE_VERSION__ < 0x00030203
    3.43 +/*
    3.44 + * Legacy hypercall interface:
    3.45 + * As above, except the entry sequence to the hypervisor is:
    3.46 + *  mov $hypercall-number*32,%eax ; syscall
    3.47 + * Clobbered: %rcx, %r11, argument registers (as above)
    3.48 + */
    3.49 +#define TRAP_INSTR "syscall"
    3.50 +#endif
    3.51 +
    3.52 +/*
    3.53 + * 64-bit segment selectors
    3.54 + * These flat segments are in the Xen-private section of every GDT. Since these
    3.55 + * are also present in the initial GDT, many OSes will be able to avoid
    3.56 + * installing their own GDT.
    3.57 + */
    3.58 +
    3.59 +#define FLAT_RING3_CS32 0xe023  /* GDT index 260 */
    3.60 +#define FLAT_RING3_CS64 0xe033  /* GDT index 261 */
    3.61 +#define FLAT_RING3_DS32 0xe02b  /* GDT index 262 */
    3.62 +#define FLAT_RING3_DS64 0x0000  /* NULL selector */
    3.63 +#define FLAT_RING3_SS32 0xe02b  /* GDT index 262 */
    3.64 +#define FLAT_RING3_SS64 0xe02b  /* GDT index 262 */
    3.65 +
    3.66 +#define FLAT_KERNEL_DS64 FLAT_RING3_DS64
    3.67 +#define FLAT_KERNEL_DS32 FLAT_RING3_DS32
    3.68 +#define FLAT_KERNEL_DS   FLAT_KERNEL_DS64
    3.69 +#define FLAT_KERNEL_CS64 FLAT_RING3_CS64
    3.70 +#define FLAT_KERNEL_CS32 FLAT_RING3_CS32
    3.71 +#define FLAT_KERNEL_CS   FLAT_KERNEL_CS64
    3.72 +#define FLAT_KERNEL_SS64 FLAT_RING3_SS64
    3.73 +#define FLAT_KERNEL_SS32 FLAT_RING3_SS32
    3.74 +#define FLAT_KERNEL_SS   FLAT_KERNEL_SS64
    3.75 +
    3.76 +#define FLAT_USER_DS64 FLAT_RING3_DS64
    3.77 +#define FLAT_USER_DS32 FLAT_RING3_DS32
    3.78 +#define FLAT_USER_DS   FLAT_USER_DS64
    3.79 +#define FLAT_USER_CS64 FLAT_RING3_CS64
    3.80 +#define FLAT_USER_CS32 FLAT_RING3_CS32
    3.81 +#define FLAT_USER_CS   FLAT_USER_CS64
    3.82 +#define FLAT_USER_SS64 FLAT_RING3_SS64
    3.83 +#define FLAT_USER_SS32 FLAT_RING3_SS32
    3.84 +#define FLAT_USER_SS   FLAT_USER_SS64
    3.85 +
    3.86 +#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
    3.87 +#define __HYPERVISOR_VIRT_END   0xFFFF880000000000
    3.88 +#define __MACH2PHYS_VIRT_START  0xFFFF800000000000
    3.89 +#define __MACH2PHYS_VIRT_END    0xFFFF804000000000
    3.90 +
    3.91 +#ifndef HYPERVISOR_VIRT_START
    3.92 +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
    3.93 +#define HYPERVISOR_VIRT_END   mk_unsigned_long(__HYPERVISOR_VIRT_END)
    3.94 +#endif
    3.95 +
    3.96 +#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
    3.97 +#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
    3.98 +#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
    3.99 +#ifndef machine_to_phys_mapping
   3.100 +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
   3.101 +#endif
   3.102 +
   3.103 +#ifndef __ASSEMBLY__
   3.104 +
   3.105 +/*
   3.106 + * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
   3.107 + *  @which == SEGBASE_*  ;  @base == 64-bit base address
   3.108 + * Returns 0 on success.
   3.109 + */
   3.110 +#define SEGBASE_FS          0
   3.111 +#define SEGBASE_GS_USER     1
   3.112 +#define SEGBASE_GS_KERNEL   2
   3.113 +#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */
   3.114 +
   3.115 +/*
   3.116 + * int HYPERVISOR_iret(void)
   3.117 + * All arguments are on the kernel stack, in the following format.
   3.118 + * Never returns if successful. Current kernel context is lost.
   3.119 + * The saved CS is mapped as follows:
   3.120 + *   RING0 -> RING3 kernel mode.
   3.121 + *   RING1 -> RING3 kernel mode.
   3.122 + *   RING2 -> RING3 kernel mode.
   3.123 + *   RING3 -> RING3 user mode.
   3.124 + * However RING0 indicates that the guest kernel should return to iteself
   3.125 + * directly with
   3.126 + *      orb   $3,1*8(%rsp)
   3.127 + *      iretq
   3.128 + * If flags contains VGCF_in_syscall:
   3.129 + *   Restore RAX, RIP, RFLAGS, RSP.
   3.130 + *   Discard R11, RCX, CS, SS.
   3.131 + * Otherwise:
   3.132 + *   Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP.
   3.133 + * All other registers are saved on hypercall entry and restored to user.
   3.134 + */
   3.135 +/* Guest exited in SYSCALL context? Return to guest with SYSRET? */
   3.136 +#define _VGCF_in_syscall 8
   3.137 +#define VGCF_in_syscall  (1<<_VGCF_in_syscall)
   3.138 +#define VGCF_IN_SYSCALL  VGCF_in_syscall
   3.139 +struct iret_context {
   3.140 +    /* Top of stack (%rsp at point of hypercall). */
   3.141 +    uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
   3.142 +    /* Bottom of iret stack frame. */
   3.143 +};
   3.144 +
   3.145 +#ifdef __GNUC__
   3.146 +/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
   3.147 +#define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
   3.148 +#else
   3.149 +/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
   3.150 +#define __DECL_REG(name) uint64_t r ## name
   3.151 +#endif
   3.152 +
   3.153 +struct cpu_user_regs {
   3.154 +    uint64_t r15;
   3.155 +    uint64_t r14;
   3.156 +    uint64_t r13;
   3.157 +    uint64_t r12;
   3.158 +    __DECL_REG(bp);
   3.159 +    __DECL_REG(bx);
   3.160 +    uint64_t r11;
   3.161 +    uint64_t r10;
   3.162 +    uint64_t r9;
   3.163 +    uint64_t r8;
   3.164 +    __DECL_REG(ax);
   3.165 +    __DECL_REG(cx);
   3.166 +    __DECL_REG(dx);
   3.167 +    __DECL_REG(si);
   3.168 +    __DECL_REG(di);
   3.169 +    uint32_t error_code;    /* private */
   3.170 +    uint32_t entry_vector;  /* private */
   3.171 +    __DECL_REG(ip);
   3.172 +    uint16_t cs, _pad0[1];
   3.173 +    uint8_t  saved_upcall_mask;
   3.174 +    uint8_t  _pad1[3];
   3.175 +    __DECL_REG(flags);      /* rflags.IF == !saved_upcall_mask */
   3.176 +    __DECL_REG(sp);
   3.177 +    uint16_t ss, _pad2[3];
   3.178 +    uint16_t es, _pad3[3];
   3.179 +    uint16_t ds, _pad4[3];
   3.180 +    uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
   3.181 +    uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
   3.182 +};
   3.183 +typedef struct cpu_user_regs cpu_user_regs_t;
   3.184 +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
   3.185 +
   3.186 +#undef __DECL_REG
   3.187 +
   3.188 +#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
   3.189 +#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
   3.190 +
   3.191 +struct arch_vcpu_info {
   3.192 +    unsigned long cr2;
   3.193 +    unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
   3.194 +};
   3.195 +typedef struct arch_vcpu_info arch_vcpu_info_t;
   3.196 +
   3.197 +typedef unsigned long xen_callback_t;
   3.198 +
   3.199 +#endif /* !__ASSEMBLY__ */
   3.200 +
   3.201 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */
   3.202 +
   3.203 +/*
   3.204 + * Local variables:
   3.205 + * mode: C
   3.206 + * c-set-style: "BSD"
   3.207 + * c-basic-offset: 4
   3.208 + * tab-width: 4
   3.209 + * indent-tabs-mode: nil
   3.210 + * End:
   3.211 + */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/xen/include/public/arch-x86/xen.h	Thu Dec 21 16:20:11 2006 +0000
     4.3 @@ -0,0 +1,190 @@
     4.4 +/******************************************************************************
     4.5 + * arch-x86/xen.h
     4.6 + * 
     4.7 + * Guest OS interface to x86 Xen.
     4.8 + * 
     4.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    4.10 + * of this software and associated documentation files (the "Software"), to
    4.11 + * deal in the Software without restriction, including without limitation the
    4.12 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    4.13 + * sell copies of the Software, and to permit persons to whom the Software is
    4.14 + * furnished to do so, subject to the following conditions:
    4.15 + *
    4.16 + * The above copyright notice and this permission notice shall be included in
    4.17 + * all copies or substantial portions of the Software.
    4.18 + *
    4.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    4.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    4.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    4.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    4.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    4.24 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    4.25 + * DEALINGS IN THE SOFTWARE.
    4.26 + *
    4.27 + * Copyright (c) 2004-2006, K A Fraser
    4.28 + */
    4.29 +
    4.30 +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
    4.31 +#define __XEN_PUBLIC_ARCH_X86_XEN_H__
    4.32 +
    4.33 +/* Structural guest handles introduced in 0x00030201. */
    4.34 +#if __XEN_INTERFACE_VERSION__ >= 0x00030201
    4.35 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    4.36 +    typedef struct { type *p; } __guest_handle_ ## name
    4.37 +#else
    4.38 +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    4.39 +    typedef type * __guest_handle_ ## name
    4.40 +#endif
    4.41 +
    4.42 +#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
    4.43 +#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
    4.44 +#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
    4.45 +#ifdef __XEN_TOOLS__
    4.46 +#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    4.47 +#endif
    4.48 +
    4.49 +#ifndef __ASSEMBLY__
    4.50 +/* Guest handles for primitive C types. */
    4.51 +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
    4.52 +__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
    4.53 +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
    4.54 +DEFINE_XEN_GUEST_HANDLE(char);
    4.55 +DEFINE_XEN_GUEST_HANDLE(int);
    4.56 +DEFINE_XEN_GUEST_HANDLE(long);
    4.57 +DEFINE_XEN_GUEST_HANDLE(void);
    4.58 +
    4.59 +typedef unsigned long xen_pfn_t;
    4.60 +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    4.61 +#endif
    4.62 +
    4.63 +#if defined(__i386__)
    4.64 +#include "xen-x86_32.h"
    4.65 +#elif defined(__x86_64__)
    4.66 +#include "xen-x86_64.h"
    4.67 +#endif
    4.68 +
    4.69 +/*
    4.70 + * SEGMENT DESCRIPTOR TABLES
    4.71 + */
    4.72 +/*
    4.73 + * A number of GDT entries are reserved by Xen. These are not situated at the
    4.74 + * start of the GDT because some stupid OSes export hard-coded selector values
    4.75 + * in their ABI. These hard-coded values are always near the start of the GDT,
    4.76 + * so Xen places itself out of the way, at the far end of the GDT.
    4.77 + */
    4.78 +#define FIRST_RESERVED_GDT_PAGE  14
    4.79 +#define FIRST_RESERVED_GDT_BYTE  (FIRST_RESERVED_GDT_PAGE * 4096)
    4.80 +#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
    4.81 +
    4.82 +/* Maximum number of virtual CPUs in multi-processor guests. */
    4.83 +#define MAX_VIRT_CPUS 32
    4.84 +
    4.85 +#ifndef __ASSEMBLY__
    4.86 +
    4.87 +typedef unsigned long xen_ulong_t;
    4.88 +
    4.89 +/*
    4.90 + * Send an array of these to HYPERVISOR_set_trap_table().
    4.91 + * The privilege level specifies which modes may enter a trap via a software
    4.92 + * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
    4.93 + * privilege levels as follows:
    4.94 + *  Level == 0: Noone may enter
    4.95 + *  Level == 1: Kernel may enter
    4.96 + *  Level == 2: Kernel may enter
    4.97 + *  Level == 3: Everyone may enter
    4.98 + */
    4.99 +#define TI_GET_DPL(_ti)      ((_ti)->flags & 3)
   4.100 +#define TI_GET_IF(_ti)       ((_ti)->flags & 4)
   4.101 +#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
   4.102 +#define TI_SET_IF(_ti,_if)   ((_ti)->flags |= ((!!(_if))<<2))
   4.103 +struct trap_info {
   4.104 +    uint8_t       vector;  /* exception vector                              */
   4.105 +    uint8_t       flags;   /* 0-3: privilege level; 4: clear event enable?  */
   4.106 +    uint16_t      cs;      /* code selector                                 */
   4.107 +    unsigned long address; /* code offset                                   */
   4.108 +};
   4.109 +typedef struct trap_info trap_info_t;
   4.110 +DEFINE_XEN_GUEST_HANDLE(trap_info_t);
   4.111 +
   4.112 +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
   4.113 +
   4.114 +/*
   4.115 + * The following is all CPU context. Note that the fpu_ctxt block is filled 
   4.116 + * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
   4.117 + */
   4.118 +struct vcpu_guest_context {
   4.119 +    /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
   4.120 +    struct { char x[512]; } fpu_ctxt;       /* User-level FPU registers     */
   4.121 +#define VGCF_I387_VALID                (1<<0)
   4.122 +#define VGCF_IN_KERNEL                 (1<<2)
   4.123 +#define _VGCF_i387_valid               0
   4.124 +#define VGCF_i387_valid                (1<<_VGCF_i387_valid)
   4.125 +#define _VGCF_in_kernel                2
   4.126 +#define VGCF_in_kernel                 (1<<_VGCF_in_kernel)
   4.127 +#define _VGCF_failsafe_disables_events 3
   4.128 +#define VGCF_failsafe_disables_events  (1<<_VGCF_failsafe_disables_events)
   4.129 +#define _VGCF_syscall_disables_events  4
   4.130 +#define VGCF_syscall_disables_events   (1<<_VGCF_syscall_disables_events)
   4.131 +    unsigned long flags;                    /* VGCF_* flags                 */
   4.132 +    struct cpu_user_regs user_regs;         /* User-level CPU registers     */
   4.133 +    struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
   4.134 +    unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
   4.135 +    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
   4.136 +    unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
   4.137 +    unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
   4.138 +    unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
   4.139 +#ifdef __i386__
   4.140 +    unsigned long event_callback_cs;        /* CS:EIP of event callback     */
   4.141 +    unsigned long event_callback_eip;
   4.142 +    unsigned long failsafe_callback_cs;     /* CS:EIP of failsafe callback  */
   4.143 +    unsigned long failsafe_callback_eip;
   4.144 +#else
   4.145 +    unsigned long event_callback_eip;
   4.146 +    unsigned long failsafe_callback_eip;
   4.147 +    unsigned long syscall_callback_eip;
   4.148 +#endif
   4.149 +    unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
   4.150 +#ifdef __x86_64__
   4.151 +    /* Segment base addresses. */
   4.152 +    uint64_t      fs_base;
   4.153 +    uint64_t      gs_base_kernel;
   4.154 +    uint64_t      gs_base_user;
   4.155 +#endif
   4.156 +};
   4.157 +typedef struct vcpu_guest_context vcpu_guest_context_t;
   4.158 +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   4.159 +
   4.160 +struct arch_shared_info {
   4.161 +    unsigned long max_pfn;                  /* max pfn that appears in table */
   4.162 +    /* Frame containing list of mfns containing list of mfns containing p2m. */
   4.163 +    xen_pfn_t     pfn_to_mfn_frame_list_list;
   4.164 +    unsigned long nmi_reason;
   4.165 +    uint64_t pad[32];
   4.166 +};
   4.167 +typedef struct arch_shared_info arch_shared_info_t;
   4.168 +
   4.169 +#endif /* !__ASSEMBLY__ */
   4.170 +
   4.171 +/*
   4.172 + * Prefix forces emulation of some non-trapping instructions.
   4.173 + * Currently only CPUID.
   4.174 + */
   4.175 +#ifdef __ASSEMBLY__
   4.176 +#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
   4.177 +#define XEN_CPUID          XEN_EMULATE_PREFIX cpuid
   4.178 +#else
   4.179 +#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
   4.180 +#define XEN_CPUID          XEN_EMULATE_PREFIX "cpuid"
   4.181 +#endif
   4.182 +
   4.183 +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
   4.184 +
   4.185 +/*
   4.186 + * Local variables:
   4.187 + * mode: C
   4.188 + * c-set-style: "BSD"
   4.189 + * c-basic-offset: 4
   4.190 + * tab-width: 4
   4.191 + * indent-tabs-mode: nil
   4.192 + * End:
   4.193 + */
     5.1 --- a/xen/include/public/arch-x86_32.h	Thu Dec 21 14:49:19 2006 +0000
     5.2 +++ b/xen/include/public/arch-x86_32.h	Thu Dec 21 16:20:11 2006 +0000
     5.3 @@ -21,250 +21,7 @@
     5.4   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     5.5   * DEALINGS IN THE SOFTWARE.
     5.6   *
     5.7 - * Copyright (c) 2004, K A Fraser
     5.8 - */
     5.9 -
    5.10 -#ifndef __XEN_PUBLIC_ARCH_X86_32_H__
    5.11 -#define __XEN_PUBLIC_ARCH_X86_32_H__
    5.12 -
    5.13 -/*
    5.14 - * Hypercall interface:
    5.15 - *  Input:  %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
    5.16 - *  Output: %eax
    5.17 - * Access is via hypercall page (set up by guest loader or via a Xen MSR):
    5.18 - *  call hypercall_page + hypercall-number * 32
    5.19 - * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
    5.20 + * Copyright (c) 2004-2006, K A Fraser
    5.21   */
    5.22  
    5.23 -#if __XEN_INTERFACE_VERSION__ < 0x00030203
    5.24 -/*
    5.25 - * Legacy hypercall interface:
    5.26 - * As above, except the entry sequence to the hypervisor is:
    5.27 - *  mov $hypercall-number*32,%eax ; int $0x82
    5.28 - */
    5.29 -#define TRAP_INSTR "int $0x82"
    5.30 -#endif
    5.31 -
    5.32 -/* Structural guest handles introduced in 0x00030201. */
    5.33 -#if __XEN_INTERFACE_VERSION__ >= 0x00030201
    5.34 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    5.35 -    typedef struct { type *p; } __guest_handle_ ## name
    5.36 -#else
    5.37 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    5.38 -    typedef type * __guest_handle_ ## name
    5.39 -#endif
    5.40 -
    5.41 -#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
    5.42 -#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
    5.43 -#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
    5.44 -#ifdef __XEN_TOOLS__
    5.45 -#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    5.46 -#endif
    5.47 -
    5.48 -#ifndef __ASSEMBLY__
    5.49 -/* Guest handles for primitive C types. */
    5.50 -__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
    5.51 -__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
    5.52 -__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
    5.53 -DEFINE_XEN_GUEST_HANDLE(char);
    5.54 -DEFINE_XEN_GUEST_HANDLE(int);
    5.55 -DEFINE_XEN_GUEST_HANDLE(long);
    5.56 -DEFINE_XEN_GUEST_HANDLE(void);
    5.57 -
    5.58 -typedef unsigned long xen_pfn_t;
    5.59 -DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    5.60 -#endif
    5.61 -
    5.62 -/*
    5.63 - * SEGMENT DESCRIPTOR TABLES
    5.64 - */
    5.65 -/*
    5.66 - * A number of GDT entries are reserved by Xen. These are not situated at the
    5.67 - * start of the GDT because some stupid OSes export hard-coded selector values
    5.68 - * in their ABI. These hard-coded values are always near the start of the GDT,
    5.69 - * so Xen places itself out of the way, at the far end of the GDT.
    5.70 - */
    5.71 -#define FIRST_RESERVED_GDT_PAGE  14
    5.72 -#define FIRST_RESERVED_GDT_BYTE  (FIRST_RESERVED_GDT_PAGE * 4096)
    5.73 -#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
    5.74 -
    5.75 -/*
    5.76 - * These flat segments are in the Xen-private section of every GDT. Since these
    5.77 - * are also present in the initial GDT, many OSes will be able to avoid
    5.78 - * installing their own GDT.
    5.79 - */
    5.80 -#define FLAT_RING1_CS 0xe019    /* GDT index 259 */
    5.81 -#define FLAT_RING1_DS 0xe021    /* GDT index 260 */
    5.82 -#define FLAT_RING1_SS 0xe021    /* GDT index 260 */
    5.83 -#define FLAT_RING3_CS 0xe02b    /* GDT index 261 */
    5.84 -#define FLAT_RING3_DS 0xe033    /* GDT index 262 */
    5.85 -#define FLAT_RING3_SS 0xe033    /* GDT index 262 */
    5.86 -
    5.87 -#define FLAT_KERNEL_CS FLAT_RING1_CS
    5.88 -#define FLAT_KERNEL_DS FLAT_RING1_DS
    5.89 -#define FLAT_KERNEL_SS FLAT_RING1_SS
    5.90 -#define FLAT_USER_CS    FLAT_RING3_CS
    5.91 -#define FLAT_USER_DS    FLAT_RING3_DS
    5.92 -#define FLAT_USER_SS    FLAT_RING3_SS
    5.93 -
    5.94 -/*
    5.95 - * Virtual addresses beyond this are not modifiable by guest OSes. The 
    5.96 - * machine->physical mapping table starts at this address, read-only.
    5.97 - */
    5.98 -#ifdef CONFIG_X86_PAE
    5.99 -#define __HYPERVISOR_VIRT_START 0xF5800000
   5.100 -#define __MACH2PHYS_VIRT_START  0xF5800000
   5.101 -#define __MACH2PHYS_VIRT_END    0xF6800000
   5.102 -#else
   5.103 -#define __HYPERVISOR_VIRT_START 0xFC000000
   5.104 -#define __MACH2PHYS_VIRT_START  0xFC000000
   5.105 -#define __MACH2PHYS_VIRT_END    0xFC400000
   5.106 -#endif
   5.107 -
   5.108 -#ifndef HYPERVISOR_VIRT_START
   5.109 -#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
   5.110 -#endif
   5.111 -
   5.112 -#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
   5.113 -#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
   5.114 -#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
   5.115 -#ifndef machine_to_phys_mapping
   5.116 -#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
   5.117 -#endif
   5.118 -
   5.119 -/* Maximum number of virtual CPUs in multi-processor guests. */
   5.120 -#define MAX_VIRT_CPUS 32
   5.121 -
   5.122 -#ifndef __ASSEMBLY__
   5.123 -
   5.124 -typedef unsigned long xen_ulong_t;
   5.125 -
   5.126 -/*
   5.127 - * Send an array of these to HYPERVISOR_set_trap_table()
   5.128 - */
   5.129 -#define TI_GET_DPL(_ti)      ((_ti)->flags & 3)
   5.130 -#define TI_GET_IF(_ti)       ((_ti)->flags & 4)
   5.131 -#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
   5.132 -#define TI_SET_IF(_ti,_if)   ((_ti)->flags |= ((!!(_if))<<2))
   5.133 -struct trap_info {
   5.134 -    uint8_t       vector;  /* exception vector                              */
   5.135 -    uint8_t       flags;   /* 0-3: privilege level; 4: clear event enable?  */
   5.136 -    uint16_t      cs;      /* code selector                                 */
   5.137 -    unsigned long address; /* code offset                                   */
   5.138 -};
   5.139 -typedef struct trap_info trap_info_t;
   5.140 -DEFINE_XEN_GUEST_HANDLE(trap_info_t);
   5.141 -
   5.142 -struct cpu_user_regs {
   5.143 -    uint32_t ebx;
   5.144 -    uint32_t ecx;
   5.145 -    uint32_t edx;
   5.146 -    uint32_t esi;
   5.147 -    uint32_t edi;
   5.148 -    uint32_t ebp;
   5.149 -    uint32_t eax;
   5.150 -    uint16_t error_code;    /* private */
   5.151 -    uint16_t entry_vector;  /* private */
   5.152 -    uint32_t eip;
   5.153 -    uint16_t cs;
   5.154 -    uint8_t  saved_upcall_mask;
   5.155 -    uint8_t  _pad0;
   5.156 -    uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
   5.157 -    uint32_t esp;
   5.158 -    uint16_t ss, _pad1;
   5.159 -    uint16_t es, _pad2;
   5.160 -    uint16_t ds, _pad3;
   5.161 -    uint16_t fs, _pad4;
   5.162 -    uint16_t gs, _pad5;
   5.163 -};
   5.164 -typedef struct cpu_user_regs cpu_user_regs_t;
   5.165 -DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
   5.166 -
   5.167 -typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
   5.168 -
   5.169 -/*
   5.170 - * The following is all CPU context. Note that the fpu_ctxt block is filled 
   5.171 - * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
   5.172 - */
   5.173 -struct vcpu_guest_context {
   5.174 -    /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
   5.175 -    struct { char x[512]; } fpu_ctxt;       /* User-level FPU registers     */
   5.176 -#define VGCF_I387_VALID                (1<<0)
   5.177 -#define VGCF_IN_KERNEL                 (1<<2)
   5.178 -#define _VGCF_i387_valid               0
   5.179 -#define VGCF_i387_valid                (1<<_VGCF_i387_valid)
   5.180 -#define _VGCF_in_kernel                2
   5.181 -#define VGCF_in_kernel                 (1<<_VGCF_in_kernel)
   5.182 -#define _VGCF_failsafe_disables_events 3
   5.183 -#define VGCF_failsafe_disables_events  (1<<_VGCF_failsafe_disables_events)
   5.184 -    unsigned long flags;                    /* VGCF_* flags                 */
   5.185 -    struct cpu_user_regs user_regs;         /* User-level CPU registers     */
   5.186 -    struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
   5.187 -    unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
   5.188 -    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
   5.189 -    unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
   5.190 -    unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
   5.191 -    unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
   5.192 -    unsigned long event_callback_cs;        /* CS:EIP of event callback     */
   5.193 -    unsigned long event_callback_eip;
   5.194 -    unsigned long failsafe_callback_cs;     /* CS:EIP of failsafe callback  */
   5.195 -    unsigned long failsafe_callback_eip;
   5.196 -    unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
   5.197 -};
   5.198 -typedef struct vcpu_guest_context vcpu_guest_context_t;
   5.199 -DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   5.200 -
   5.201 -/*
   5.202 - * Page-directory addresses above 4GB do not fit into architectural %cr3.
   5.203 - * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
   5.204 - * must use the following accessor macros to pack/unpack valid MFNs.
   5.205 - */
   5.206 -#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
   5.207 -#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
   5.208 -
   5.209 -struct arch_shared_info {
   5.210 -    unsigned long max_pfn;                  /* max pfn that appears in table */
   5.211 -    /* Frame containing list of mfns containing list of mfns containing p2m. */
   5.212 -    xen_pfn_t     pfn_to_mfn_frame_list_list;
   5.213 -    unsigned long nmi_reason;
   5.214 -    uint64_t pad[32];
   5.215 -};
   5.216 -typedef struct arch_shared_info arch_shared_info_t;
   5.217 -
   5.218 -struct arch_vcpu_info {
   5.219 -    unsigned long cr2;
   5.220 -    unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
   5.221 -};
   5.222 -typedef struct arch_vcpu_info arch_vcpu_info_t;
   5.223 -
   5.224 -struct xen_callback {
   5.225 -    unsigned long cs;
   5.226 -    unsigned long eip;
   5.227 -};
   5.228 -typedef struct xen_callback xen_callback_t;
   5.229 -
   5.230 -#endif /* !__ASSEMBLY__ */
   5.231 -
   5.232 -/*
   5.233 - * Prefix forces emulation of some non-trapping instructions.
   5.234 - * Currently only CPUID.
   5.235 - */
   5.236 -#ifdef __ASSEMBLY__
   5.237 -#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
   5.238 -#define XEN_CPUID          XEN_EMULATE_PREFIX cpuid
   5.239 -#else
   5.240 -#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
   5.241 -#define XEN_CPUID          XEN_EMULATE_PREFIX "cpuid"
   5.242 -#endif
   5.243 -
   5.244 -#endif
   5.245 -
   5.246 -/*
   5.247 - * Local variables:
   5.248 - * mode: C
   5.249 - * c-set-style: "BSD"
   5.250 - * c-basic-offset: 4
   5.251 - * tab-width: 4
   5.252 - * indent-tabs-mode: nil
   5.253 - * End:
   5.254 - */
   5.255 +#include "arch-x86/xen.h"
     6.1 --- a/xen/include/public/arch-x86_64.h	Thu Dec 21 14:49:19 2006 +0000
     6.2 +++ b/xen/include/public/arch-x86_64.h	Thu Dec 21 16:20:11 2006 +0000
     6.3 @@ -21,319 +21,7 @@
     6.4   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     6.5   * DEALINGS IN THE SOFTWARE.
     6.6   *
     6.7 - * Copyright (c) 2004, K A Fraser
     6.8 - */
     6.9 -
    6.10 -#ifndef __XEN_PUBLIC_ARCH_X86_64_H__
    6.11 -#define __XEN_PUBLIC_ARCH_X86_64_H__
    6.12 -
    6.13 -/*
    6.14 - * Hypercall interface:
    6.15 - *  Input:  %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5)
    6.16 - *  Output: %rax
    6.17 - * Access is via hypercall page (set up by guest loader or via a Xen MSR):
    6.18 - *  call hypercall_page + hypercall-number * 32
    6.19 - * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi)
    6.20 - */
    6.21 -
    6.22 -#if __XEN_INTERFACE_VERSION__ < 0x00030203
    6.23 -/*
    6.24 - * Legacy hypercall interface:
    6.25 - * As above, except the entry sequence to the hypervisor is:
    6.26 - *  mov $hypercall-number*32,%eax ; syscall
    6.27 - * Clobbered: %rcx, %r11, argument registers (as above)
    6.28 - */
    6.29 -#define TRAP_INSTR "syscall"
    6.30 -#endif
    6.31 -
    6.32 -/* Structural guest handles introduced in 0x00030201. */
    6.33 -#if __XEN_INTERFACE_VERSION__ >= 0x00030201
    6.34 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    6.35 -    typedef struct { type *p; } __guest_handle_ ## name
    6.36 -#else
    6.37 -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
    6.38 -    typedef type * __guest_handle_ ## name
    6.39 -#endif
    6.40 -
    6.41 -#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
    6.42 -#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
    6.43 -#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
    6.44 -#ifdef __XEN_TOOLS__
    6.45 -#define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
    6.46 -#endif
    6.47 -
    6.48 -#ifndef __ASSEMBLY__
    6.49 -/* Guest handles for primitive C types. */
    6.50 -__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
    6.51 -__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
    6.52 -__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
    6.53 -DEFINE_XEN_GUEST_HANDLE(char);
    6.54 -DEFINE_XEN_GUEST_HANDLE(int);
    6.55 -DEFINE_XEN_GUEST_HANDLE(long);
    6.56 -DEFINE_XEN_GUEST_HANDLE(void);
    6.57 -
    6.58 -typedef unsigned long xen_pfn_t;
    6.59 -DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
    6.60 -#endif
    6.61 -
    6.62 -/*
    6.63 - * SEGMENT DESCRIPTOR TABLES
    6.64 - */
    6.65 -/*
    6.66 - * A number of GDT entries are reserved by Xen. These are not situated at the
    6.67 - * start of the GDT because some stupid OSes export hard-coded selector values
    6.68 - * in their ABI. These hard-coded values are always near the start of the GDT,
    6.69 - * so Xen places itself out of the way, at the far end of the GDT.
    6.70 - */
    6.71 -#define FIRST_RESERVED_GDT_PAGE  14
    6.72 -#define FIRST_RESERVED_GDT_BYTE  (FIRST_RESERVED_GDT_PAGE * 4096)
    6.73 -#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
    6.74 -
    6.75 -/*
    6.76 - * 64-bit segment selectors
    6.77 - * These flat segments are in the Xen-private section of every GDT. Since these
    6.78 - * are also present in the initial GDT, many OSes will be able to avoid
    6.79 - * installing their own GDT.
    6.80 + * Copyright (c) 2004-2006, K A Fraser
    6.81   */
    6.82  
    6.83 -#define FLAT_RING3_CS32 0xe023  /* GDT index 260 */
    6.84 -#define FLAT_RING3_CS64 0xe033  /* GDT index 261 */
    6.85 -#define FLAT_RING3_DS32 0xe02b  /* GDT index 262 */
    6.86 -#define FLAT_RING3_DS64 0x0000  /* NULL selector */
    6.87 -#define FLAT_RING3_SS32 0xe02b  /* GDT index 262 */
    6.88 -#define FLAT_RING3_SS64 0xe02b  /* GDT index 262 */
    6.89 -
    6.90 -#define FLAT_KERNEL_DS64 FLAT_RING3_DS64
    6.91 -#define FLAT_KERNEL_DS32 FLAT_RING3_DS32
    6.92 -#define FLAT_KERNEL_DS   FLAT_KERNEL_DS64
    6.93 -#define FLAT_KERNEL_CS64 FLAT_RING3_CS64
    6.94 -#define FLAT_KERNEL_CS32 FLAT_RING3_CS32
    6.95 -#define FLAT_KERNEL_CS   FLAT_KERNEL_CS64
    6.96 -#define FLAT_KERNEL_SS64 FLAT_RING3_SS64
    6.97 -#define FLAT_KERNEL_SS32 FLAT_RING3_SS32
    6.98 -#define FLAT_KERNEL_SS   FLAT_KERNEL_SS64
    6.99 -
   6.100 -#define FLAT_USER_DS64 FLAT_RING3_DS64
   6.101 -#define FLAT_USER_DS32 FLAT_RING3_DS32
   6.102 -#define FLAT_USER_DS   FLAT_USER_DS64
   6.103 -#define FLAT_USER_CS64 FLAT_RING3_CS64
   6.104 -#define FLAT_USER_CS32 FLAT_RING3_CS32
   6.105 -#define FLAT_USER_CS   FLAT_USER_CS64
   6.106 -#define FLAT_USER_SS64 FLAT_RING3_SS64
   6.107 -#define FLAT_USER_SS32 FLAT_RING3_SS32
   6.108 -#define FLAT_USER_SS   FLAT_USER_SS64
   6.109 -
   6.110 -#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
   6.111 -#define __HYPERVISOR_VIRT_END   0xFFFF880000000000
   6.112 -#define __MACH2PHYS_VIRT_START  0xFFFF800000000000
   6.113 -#define __MACH2PHYS_VIRT_END    0xFFFF804000000000
   6.114 -
   6.115 -#ifndef HYPERVISOR_VIRT_START
   6.116 -#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
   6.117 -#define HYPERVISOR_VIRT_END   mk_unsigned_long(__HYPERVISOR_VIRT_END)
   6.118 -#endif
   6.119 -
   6.120 -#define MACH2PHYS_VIRT_START  mk_unsigned_long(__MACH2PHYS_VIRT_START)
   6.121 -#define MACH2PHYS_VIRT_END    mk_unsigned_long(__MACH2PHYS_VIRT_END)
   6.122 -#define MACH2PHYS_NR_ENTRIES  ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
   6.123 -#ifndef machine_to_phys_mapping
   6.124 -#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
   6.125 -#endif
   6.126 -
   6.127 -/* Maximum number of virtual CPUs in multi-processor guests. */
   6.128 -#define MAX_VIRT_CPUS 32
   6.129 -
   6.130 -#ifndef __ASSEMBLY__
   6.131 -
   6.132 -typedef unsigned long xen_ulong_t;
   6.133 -
   6.134 -/*
   6.135 - * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
   6.136 - *  @which == SEGBASE_*  ;  @base == 64-bit base address
   6.137 - * Returns 0 on success.
   6.138 - */
   6.139 -#define SEGBASE_FS          0
   6.140 -#define SEGBASE_GS_USER     1
   6.141 -#define SEGBASE_GS_KERNEL   2
   6.142 -#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */
   6.143 -
   6.144 -/*
   6.145 - * int HYPERVISOR_iret(void)
   6.146 - * All arguments are on the kernel stack, in the following format.
   6.147 - * Never returns if successful. Current kernel context is lost.
   6.148 - * The saved CS is mapped as follows:
   6.149 - *   RING0 -> RING3 kernel mode.
   6.150 - *   RING1 -> RING3 kernel mode.
   6.151 - *   RING2 -> RING3 kernel mode.
   6.152 - *   RING3 -> RING3 user mode.
   6.153 - * However RING0 indicates that the guest kernel should return to iteself
   6.154 - * directly with
   6.155 - *      orb   $3,1*8(%rsp)
   6.156 - *      iretq
   6.157 - * If flags contains VGCF_in_syscall:
   6.158 - *   Restore RAX, RIP, RFLAGS, RSP.
   6.159 - *   Discard R11, RCX, CS, SS.
   6.160 - * Otherwise:
   6.161 - *   Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP.
   6.162 - * All other registers are saved on hypercall entry and restored to user.
   6.163 - */
   6.164 -/* Guest exited in SYSCALL context? Return to guest with SYSRET? */
   6.165 -#define _VGCF_in_syscall 8
   6.166 -#define VGCF_in_syscall  (1<<_VGCF_in_syscall)
   6.167 -#define VGCF_IN_SYSCALL  VGCF_in_syscall
   6.168 -struct iret_context {
   6.169 -    /* Top of stack (%rsp at point of hypercall). */
   6.170 -    uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
   6.171 -    /* Bottom of iret stack frame. */
   6.172 -};
   6.173 -
   6.174 -/*
   6.175 - * Send an array of these to HYPERVISOR_set_trap_table().
   6.176 - * N.B. As in x86/32 mode, the privilege level specifies which modes may enter
   6.177 - * a trap via a software interrupt. Since rings 1 and 2 are unavailable, we
   6.178 - * allocate privilege levels as follows:
   6.179 - *  Level == 0: Noone may enter
   6.180 - *  Level == 1: Kernel may enter
   6.181 - *  Level == 2: Kernel may enter
   6.182 - *  Level == 3: Everyone may enter
   6.183 - */
   6.184 -#define TI_GET_DPL(_ti)      ((_ti)->flags & 3)
   6.185 -#define TI_GET_IF(_ti)       ((_ti)->flags & 4)
   6.186 -#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
   6.187 -#define TI_SET_IF(_ti,_if)   ((_ti)->flags |= ((!!(_if))<<2))
   6.188 -struct trap_info {
   6.189 -    uint8_t       vector;  /* exception vector                              */
   6.190 -    uint8_t       flags;   /* 0-3: privilege level; 4: clear event enable?  */
   6.191 -    uint16_t      cs;      /* code selector                                 */
   6.192 -    unsigned long address; /* code offset                                   */
   6.193 -};
   6.194 -typedef struct trap_info trap_info_t;
   6.195 -DEFINE_XEN_GUEST_HANDLE(trap_info_t);
   6.196 -
   6.197 -#ifdef __GNUC__
   6.198 -/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
   6.199 -#define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
   6.200 -#else
   6.201 -/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
   6.202 -#define __DECL_REG(name) uint64_t r ## name
   6.203 -#endif
   6.204 -
   6.205 -struct cpu_user_regs {
   6.206 -    uint64_t r15;
   6.207 -    uint64_t r14;
   6.208 -    uint64_t r13;
   6.209 -    uint64_t r12;
   6.210 -    __DECL_REG(bp);
   6.211 -    __DECL_REG(bx);
   6.212 -    uint64_t r11;
   6.213 -    uint64_t r10;
   6.214 -    uint64_t r9;
   6.215 -    uint64_t r8;
   6.216 -    __DECL_REG(ax);
   6.217 -    __DECL_REG(cx);
   6.218 -    __DECL_REG(dx);
   6.219 -    __DECL_REG(si);
   6.220 -    __DECL_REG(di);
   6.221 -    uint32_t error_code;    /* private */
   6.222 -    uint32_t entry_vector;  /* private */
   6.223 -    __DECL_REG(ip);
   6.224 -    uint16_t cs, _pad0[1];
   6.225 -    uint8_t  saved_upcall_mask;
   6.226 -    uint8_t  _pad1[3];
   6.227 -    __DECL_REG(flags);      /* rflags.IF == !saved_upcall_mask */
   6.228 -    __DECL_REG(sp);
   6.229 -    uint16_t ss, _pad2[3];
   6.230 -    uint16_t es, _pad3[3];
   6.231 -    uint16_t ds, _pad4[3];
   6.232 -    uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
   6.233 -    uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
   6.234 -};
   6.235 -typedef struct cpu_user_regs cpu_user_regs_t;
   6.236 -DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
   6.237 -
   6.238 -#undef __DECL_REG
   6.239 -
   6.240 -typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
   6.241 -
   6.242 -/*
   6.243 - * The following is all CPU context. Note that the fpu_ctxt block is filled 
   6.244 - * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
   6.245 - */
   6.246 -struct vcpu_guest_context {
   6.247 -    /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
   6.248 -    struct { char x[512]; } fpu_ctxt;       /* User-level FPU registers     */
   6.249 -#define VGCF_I387_VALID                (1<<0)
   6.250 -#define VGCF_IN_KERNEL                 (1<<2)
   6.251 -#define _VGCF_i387_valid               0
   6.252 -#define VGCF_i387_valid                (1<<_VGCF_i387_valid)
   6.253 -#define _VGCF_in_kernel                2
   6.254 -#define VGCF_in_kernel                 (1<<_VGCF_in_kernel)
   6.255 -#define _VGCF_failsafe_disables_events 3
   6.256 -#define VGCF_failsafe_disables_events  (1<<_VGCF_failsafe_disables_events)
   6.257 -#define _VGCF_syscall_disables_events  4
   6.258 -#define VGCF_syscall_disables_events   (1<<_VGCF_syscall_disables_events)
   6.259 -    unsigned long flags;                    /* VGCF_* flags                 */
   6.260 -    struct cpu_user_regs user_regs;         /* User-level CPU registers     */
   6.261 -    struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
   6.262 -    unsigned long ldt_base, ldt_ents;       /* LDT (linear address, # ents) */
   6.263 -    unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
   6.264 -    unsigned long kernel_ss, kernel_sp;     /* Virtual TSS (only SS1/SP1)   */
   6.265 -    unsigned long ctrlreg[8];               /* CR0-CR7 (control registers)  */
   6.266 -    unsigned long debugreg[8];              /* DB0-DB7 (debug registers)    */
   6.267 -    unsigned long event_callback_eip;
   6.268 -    unsigned long failsafe_callback_eip;
   6.269 -    unsigned long syscall_callback_eip;
   6.270 -    unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
   6.271 -    /* Segment base addresses. */
   6.272 -    uint64_t      fs_base;
   6.273 -    uint64_t      gs_base_kernel;
   6.274 -    uint64_t      gs_base_user;
   6.275 -};
   6.276 -typedef struct vcpu_guest_context vcpu_guest_context_t;
   6.277 -DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
   6.278 -
   6.279 -#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
   6.280 -#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
   6.281 -
   6.282 -struct arch_shared_info {
   6.283 -    unsigned long max_pfn;                  /* max pfn that appears in table */
   6.284 -    /* Frame containing list of mfns containing list of mfns containing p2m. */
   6.285 -    xen_pfn_t     pfn_to_mfn_frame_list_list;
   6.286 -    unsigned long nmi_reason;
   6.287 -    uint64_t pad[32];
   6.288 -};
   6.289 -typedef struct arch_shared_info arch_shared_info_t;
   6.290 -
   6.291 -struct arch_vcpu_info {
   6.292 -    unsigned long cr2;
   6.293 -    unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
   6.294 -};
   6.295 -typedef struct arch_vcpu_info  arch_vcpu_info_t;
   6.296 -
   6.297 -typedef unsigned long xen_callback_t;
   6.298 -
   6.299 -#endif /* !__ASSEMBLY__ */
   6.300 -
   6.301 -/*
   6.302 - * Prefix forces emulation of some non-trapping instructions.
   6.303 - * Currently only CPUID.
   6.304 - */
   6.305 -#ifdef __ASSEMBLY__
   6.306 -#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
   6.307 -#define XEN_CPUID          XEN_EMULATE_PREFIX cpuid
   6.308 -#else
   6.309 -#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
   6.310 -#define XEN_CPUID          XEN_EMULATE_PREFIX "cpuid"
   6.311 -#endif
   6.312 -
   6.313 -#endif
   6.314 -
   6.315 -/*
   6.316 - * Local variables:
   6.317 - * mode: C
   6.318 - * c-set-style: "BSD"
   6.319 - * c-basic-offset: 4
   6.320 - * tab-width: 4
   6.321 - * indent-tabs-mode: nil
   6.322 - * End:
   6.323 - */
   6.324 +#include "arch-x86/xen.h"
     7.1 --- a/xen/include/public/xen.h	Thu Dec 21 14:49:19 2006 +0000
     7.2 +++ b/xen/include/public/xen.h	Thu Dec 21 16:20:11 2006 +0000
     7.3 @@ -29,10 +29,8 @@
     7.4  
     7.5  #include "xen-compat.h"
     7.6  
     7.7 -#if defined(__i386__)
     7.8 -#include "arch-x86_32.h"
     7.9 -#elif defined(__x86_64__)
    7.10 -#include "arch-x86_64.h"
    7.11 +#if defined(__i386__) || defined(__x86_64__)
    7.12 +#include "arch-x86/xen.h"
    7.13  #elif defined(__ia64__)
    7.14  #include "arch-ia64.h"
    7.15  #elif defined(__powerpc__)