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