1 /******************************************************************************
4 * Guest OS interface to x86 32-bit Xen.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 * Copyright (c) 2004-2007, K A Fraser
27 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
28 #define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
31 * Hypercall interface:
32 * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6)
34 * Access is via hypercall page (set up by guest loader or via a Xen MSR):
35 * call hypercall_page + hypercall-number * 32
36 * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
40 * These flat segments are in the Xen-private section of every GDT. Since these
41 * are also present in the initial GDT, many OSes will be able to avoid
42 * installing their own GDT.
44 #define FLAT_RING1_CS 0xe019 /* GDT index 259 */
45 #define FLAT_RING1_DS 0xe021 /* GDT index 260 */
46 #define FLAT_RING1_SS 0xe021 /* GDT index 260 */
47 #define FLAT_RING3_CS 0xe02b /* GDT index 261 */
48 #define FLAT_RING3_DS 0xe033 /* GDT index 262 */
49 #define FLAT_RING3_SS 0xe033 /* GDT index 262 */
51 #define FLAT_KERNEL_CS FLAT_RING1_CS
52 #define FLAT_KERNEL_DS FLAT_RING1_DS
53 #define FLAT_KERNEL_SS FLAT_RING1_SS
54 #define FLAT_USER_CS FLAT_RING3_CS
55 #define FLAT_USER_DS FLAT_RING3_DS
56 #define FLAT_USER_SS FLAT_RING3_SS
58 #define __HYPERVISOR_VIRT_START_PAE 0xF5800000
59 #define __MACH2PHYS_VIRT_START_PAE 0xF5800000
60 #define __MACH2PHYS_VIRT_END_PAE 0xF6800000
61 #define HYPERVISOR_VIRT_START_PAE \
62 mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
63 #define MACH2PHYS_VIRT_START_PAE \
64 mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
65 #define MACH2PHYS_VIRT_END_PAE \
66 mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
68 /* Non-PAE bounds are obsolete. */
69 #define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
70 #define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000
71 #define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000
72 #define HYPERVISOR_VIRT_START_NONPAE \
73 mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
74 #define MACH2PHYS_VIRT_START_NONPAE \
75 mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
76 #define MACH2PHYS_VIRT_END_NONPAE \
77 mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
79 #define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
80 #define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE
81 #define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE
83 #ifndef HYPERVISOR_VIRT_START
84 #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
87 #define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
88 #define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
89 #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
90 #ifndef machine_to_phys_mapping
91 #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
94 /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
95 #if defined(__XEN__) || defined(__XEN_TOOLS__)
96 #undef ___DEFINE_XEN_GUEST_HANDLE
97 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
98 typedef struct { type *p; } \
99 __guest_handle_ ## name; \
100 typedef struct { union { type *p; uint64_aligned_t q; }; } \
101 __guest_handle_64_ ## name
102 #undef set_xen_guest_handle_raw
103 #define set_xen_guest_handle_raw(hnd, val) \
104 do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
107 #define int64_aligned_t int64_t __attribute__((aligned(8)))
108 #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
109 #define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
110 #define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name)
115 struct cpu_user_regs {
123 uint16_t error_code; /* private */
124 uint16_t entry_vector; /* private */
127 uint8_t saved_upcall_mask;
129 uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
137 typedef struct cpu_user_regs cpu_user_regs_t;
138 DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
141 * Page-directory addresses above 4GB do not fit into architectural %cr3.
142 * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
143 * must use the following accessor macros to pack/unpack valid MFNs.
145 #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
146 #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
148 struct arch_vcpu_info {
150 unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
152 typedef struct arch_vcpu_info arch_vcpu_info_t;
154 struct xen_callback {
158 typedef struct xen_callback xen_callback_t;
160 #endif /* !__ASSEMBLY__ */
162 #endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
167 * c-file-style: "BSD"
170 * indent-tabs-mode: nil