iPXE
xen-x86_32.h
Go to the documentation of this file.
1 /******************************************************************************
2  * xen-x86_32.h
3  *
4  * Guest OS interface to x86 32-bit Xen.
5  *
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:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
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.
23  *
24  * Copyright (c) 2004-2007, K A Fraser
25  */
26 
27 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
28 #define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
29 
30 FILE_LICENCE ( MIT );
31 
32 /*
33  * Hypercall interface:
34  * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6)
35  * Output: %eax
36  * Access is via hypercall page (set up by guest loader or via a Xen MSR):
37  * call hypercall_page + hypercall-number * 32
38  * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
39  */
40 
41 /*
42  * These flat segments are in the Xen-private section of every GDT. Since these
43  * are also present in the initial GDT, many OSes will be able to avoid
44  * installing their own GDT.
45  */
46 #define FLAT_RING1_CS 0xe019 /* GDT index 259 */
47 #define FLAT_RING1_DS 0xe021 /* GDT index 260 */
48 #define FLAT_RING1_SS 0xe021 /* GDT index 260 */
49 #define FLAT_RING3_CS 0xe02b /* GDT index 261 */
50 #define FLAT_RING3_DS 0xe033 /* GDT index 262 */
51 #define FLAT_RING3_SS 0xe033 /* GDT index 262 */
52 
53 #define FLAT_KERNEL_CS FLAT_RING1_CS
54 #define FLAT_KERNEL_DS FLAT_RING1_DS
55 #define FLAT_KERNEL_SS FLAT_RING1_SS
56 #define FLAT_USER_CS FLAT_RING3_CS
57 #define FLAT_USER_DS FLAT_RING3_DS
58 #define FLAT_USER_SS FLAT_RING3_SS
59 
60 #define __HYPERVISOR_VIRT_START_PAE 0xF5800000
61 #define __MACH2PHYS_VIRT_START_PAE 0xF5800000
62 #define __MACH2PHYS_VIRT_END_PAE 0xF6800000
63 #define HYPERVISOR_VIRT_START_PAE \
64  mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
65 #define MACH2PHYS_VIRT_START_PAE \
66  mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
67 #define MACH2PHYS_VIRT_END_PAE \
68  mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
69 
70 /* Non-PAE bounds are obsolete. */
71 #define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
72 #define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000
73 #define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000
74 #define HYPERVISOR_VIRT_START_NONPAE \
75  mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
76 #define MACH2PHYS_VIRT_START_NONPAE \
77  mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
78 #define MACH2PHYS_VIRT_END_NONPAE \
79  mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
80 
81 #define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
82 #define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE
83 #define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE
84 
85 #ifndef HYPERVISOR_VIRT_START
86 #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
87 #endif
88 
89 #define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
90 #define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
91 #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
92 #ifndef machine_to_phys_mapping
93 #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
94 #endif
95 
96 /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
97 #if defined(__XEN__) || defined(__XEN_TOOLS__)
98 #undef ___DEFINE_XEN_GUEST_HANDLE
99 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
100  typedef struct { type *p; } \
101  __guest_handle_ ## name; \
102  typedef struct { union { type *p; uint64_aligned_t q; }; } \
103  __guest_handle_64_ ## name
104 #undef set_xen_guest_handle_raw
105 #define set_xen_guest_handle_raw(hnd, val) \
106  do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
107  (hnd).p = val; \
108  } while ( 0 )
109 #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
110 #define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
111 #define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name)
112 #endif
113 
114 #ifndef __ASSEMBLY__
115 
124  uint16_t error_code; /* private */
125  uint16_t entry_vector; /* private */
130  uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
137 };
140 
141 /*
142  * Page-directory addresses above 4GB do not fit into architectural %cr3.
143  * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
144  * must use the following accessor macros to pack/unpack valid MFNs.
145  */
146 #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
147 #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
148 
149 struct arch_vcpu_info {
150  unsigned long cr2;
151  unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
152 };
154 
155 struct xen_callback {
156  unsigned long cs;
157  unsigned long eip;
158 };
160 
161 #endif /* !__ASSEMBLY__ */
162 
163 #endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
164 
165 /*
166  * Local variables:
167  * mode: C
168  * c-file-style: "BSD"
169  * c-basic-offset: 4
170  * tab-width: 4
171  * indent-tabs-mode: nil
172  * End:
173  */
unsigned short uint16_t
Definition: stdint.h:11
uint16_t cs
Definition: xen-x86_32.h:127
uint16_t error_code
Definition: xen-x86_32.h:124
uint32_t ebx
Definition: xen-x86_32.h:117
DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t)
uint32_t eip
Definition: xen-x86_32.h:126
uint32_t eflags
Definition: xen-x86_32.h:130
uint8_t _pad0
Definition: xen-x86_32.h:129
uint8_t saved_upcall_mask
Definition: xen-x86_32.h:128
unsigned long pad[5]
Definition: xen-x86_32.h:151
unsigned long cs
Definition: xen-x86_32.h:156
uint16_t ss
Definition: xen-x86_32.h:132
uint16_t _pad3
Definition: xen-x86_32.h:134
uint32_t ecx
Definition: xen-x86_32.h:118
uint16_t entry_vector
Definition: xen-x86_32.h:125
uint16_t es
Definition: xen-x86_32.h:133
uint16_t _pad4
Definition: xen-x86_32.h:135
uint32_t ebp
Definition: xen-x86_32.h:122
unsigned char uint8_t
Definition: stdint.h:10
uint16_t _pad2
Definition: xen-x86_32.h:133
unsigned int uint32_t
Definition: stdint.h:12
uint32_t edi
Definition: xen-x86_32.h:121
uint16_t _pad5
Definition: xen-x86_32.h:136
uint32_t esp
Definition: xen-x86_32.h:131
uint32_t eax
Definition: xen-x86_32.h:123
unsigned long cr2
Definition: xen-x86_32.h:150
uint64_t xen_callback_t
Definition: arch-arm.h:317
uint32_t esi
Definition: xen-x86_32.h:120
uint32_t edx
Definition: xen-x86_32.h:119
unsigned long eip
Definition: xen-x86_32.h:157
uint16_t _pad1
Definition: xen-x86_32.h:132
uint16_t fs
Definition: xen-x86_32.h:135
uint16_t ds
Definition: xen-x86_32.h:134
FILE_LICENCE(MIT)
uint16_t gs
Definition: xen-x86_32.h:136