1 /* $NetBSD: xen-x86_32.h,v 1.3 2008/01/23 19:46:46 bouyer Exp $ */
2 /******************************************************************************
5 * Guest OS interface to x86 32-bit Xen.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Copyright (c) 2004-2007, K A Fraser
28 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
29 #define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
32 * Hypercall interface:
33 * Input: %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
35 * Access is via hypercall page (set up by guest loader or via a Xen MSR):
36 * call hypercall_page + hypercall-number * 32
37 * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
40 #if __XEN_INTERFACE_VERSION__ < 0x00030203
42 * Legacy hypercall interface:
43 * As above, except the entry sequence to the hypervisor is:
44 * mov $hypercall-number*32,%eax ; int $0x82
46 #define TRAP_INSTR "int $0x82"
50 * These flat segments are in the Xen-private section of every GDT. Since these
51 * are also present in the initial GDT, many OSes will be able to avoid
52 * installing their own GDT.
54 #define FLAT_RING1_CS 0xe019 /* GDT index 259 */
55 #define FLAT_RING1_DS 0xe021 /* GDT index 260 */
56 #define FLAT_RING1_SS 0xe021 /* GDT index 260 */
57 #define FLAT_RING3_CS 0xe02b /* GDT index 261 */
58 #define FLAT_RING3_DS 0xe033 /* GDT index 262 */
59 #define FLAT_RING3_SS 0xe033 /* GDT index 262 */
61 #define FLAT_KERNEL_CS FLAT_RING1_CS
62 #define FLAT_KERNEL_DS FLAT_RING1_DS
63 #define FLAT_KERNEL_SS FLAT_RING1_SS
64 #define FLAT_USER_CS FLAT_RING3_CS
65 #define FLAT_USER_DS FLAT_RING3_DS
66 #define FLAT_USER_SS FLAT_RING3_SS
68 #define __HYPERVISOR_VIRT_START_PAE 0xF5800000
69 #define __MACH2PHYS_VIRT_START_PAE 0xF5800000
70 #define __MACH2PHYS_VIRT_END_PAE 0xF6800000
71 #define HYPERVISOR_VIRT_START_PAE \
72 mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
73 #define MACH2PHYS_VIRT_START_PAE \
74 mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
75 #define MACH2PHYS_VIRT_END_PAE \
76 mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
78 #define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
79 #define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000
80 #define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000
81 #define HYPERVISOR_VIRT_START_NONPAE \
82 mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
83 #define MACH2PHYS_VIRT_START_NONPAE \
84 mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
85 #define MACH2PHYS_VIRT_END_NONPAE \
86 mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
89 #define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
90 #define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE
91 #define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE
93 #define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_NONPAE
94 #define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_NONPAE
95 #define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_NONPAE
98 #ifndef HYPERVISOR_VIRT_START
99 #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
102 #define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
103 #define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
104 #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
105 #ifndef machine_to_phys_mapping
106 #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
109 /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
110 #if defined(__XEN__) || defined(__XEN_TOOLS__)
111 #undef ___DEFINE_XEN_GUEST_HANDLE
112 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
113 typedef struct { type *p; } \
114 __guest_handle_ ## name; \
115 typedef struct { union { type *p; uint64_aligned_t q; }; } \
116 __guest_handle_64_ ## name
117 #undef set_xen_guest_handle
118 #define set_xen_guest_handle(hnd, val) \
119 do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
122 #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
123 #define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
124 #define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name)
129 struct cpu_user_regs
{
137 uint16_t error_code
; /* private */
138 uint16_t entry_vector
; /* private */
141 uint8_t saved_upcall_mask
;
143 uint32_t eflags
; /* eflags.IF == !saved_upcall_mask */
151 typedef struct cpu_user_regs cpu_user_regs_t
;
152 DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t
);
155 * Page-directory addresses above 4GB do not fit into architectural %cr3.
156 * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
157 * must use the following accessor macros to pack/unpack valid MFNs.
159 #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
160 #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
162 struct arch_vcpu_info
{
164 unsigned long pad
[5]; /* sizeof(vcpu_info_t) == 64 */
166 typedef struct arch_vcpu_info arch_vcpu_info_t
;
168 struct xen_callback
{
172 typedef struct xen_callback xen_callback_t
;
174 #endif /* !__ASSEMBLY__ */
176 #endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
184 * indent-tabs-mode: nil