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