ia64/xen-unstable

view xen/include/public/arch-x86_32.h @ 12938:b58670602d35

[POWERPC][XEN] Builtin cmdline dependency rule
Rebuild cmdline.o when the user changes the CMDLINE=X argument passed to
the make invocation. I couldn't find an example of another project that
handles this case properly, so I came up with this.
Signed-off-by: Amos Waterland <apw@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Thu Oct 05 15:48:26 2006 -0500 (2006-10-05)
parents 8d0e06c38c0c
children 71c40c3f92f7
line source
1 /******************************************************************************
2 * arch-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, K A Fraser
25 */
27 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
28 #define __XEN_PUBLIC_ARCH_X86_32_H__
30 /*
31 * Hypercall interface:
32 * Input: %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
33 * Output: %eax
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)
37 */
39 #if __XEN_INTERFACE_VERSION__ < 0x00030203
40 /*
41 * Legacy hypercall interface:
42 * As above, except the entry sequence to the hypervisor is:
43 * mov $hypercall-number*32,%eax ; int $0x82
44 */
45 #define TRAP_INSTR "int $0x82"
46 #endif
48 /* Structural guest handles introduced in 0x00030201. */
49 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
50 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
51 typedef struct { type *p; } __guest_handle_ ## name
52 #else
53 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
54 typedef type * __guest_handle_ ## name
55 #endif
57 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
58 #define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
59 #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
60 #ifdef __XEN_TOOLS__
61 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
62 #endif
64 #ifndef __ASSEMBLY__
65 /* Guest handles for primitive C types. */
66 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
67 __DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
68 __DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
69 DEFINE_XEN_GUEST_HANDLE(char);
70 DEFINE_XEN_GUEST_HANDLE(int);
71 DEFINE_XEN_GUEST_HANDLE(long);
72 DEFINE_XEN_GUEST_HANDLE(void);
74 typedef unsigned long xen_pfn_t;
75 DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
76 #endif
78 /*
79 * SEGMENT DESCRIPTOR TABLES
80 */
81 /*
82 * A number of GDT entries are reserved by Xen. These are not situated at the
83 * start of the GDT because some stupid OSes export hard-coded selector values
84 * in their ABI. These hard-coded values are always near the start of the GDT,
85 * so Xen places itself out of the way, at the far end of the GDT.
86 */
87 #define FIRST_RESERVED_GDT_PAGE 14
88 #define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
89 #define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
91 /*
92 * These flat segments are in the Xen-private section of every GDT. Since these
93 * are also present in the initial GDT, many OSes will be able to avoid
94 * installing their own GDT.
95 */
96 #define FLAT_RING1_CS 0xe019 /* GDT index 259 */
97 #define FLAT_RING1_DS 0xe021 /* GDT index 260 */
98 #define FLAT_RING1_SS 0xe021 /* GDT index 260 */
99 #define FLAT_RING3_CS 0xe02b /* GDT index 261 */
100 #define FLAT_RING3_DS 0xe033 /* GDT index 262 */
101 #define FLAT_RING3_SS 0xe033 /* GDT index 262 */
103 #define FLAT_KERNEL_CS FLAT_RING1_CS
104 #define FLAT_KERNEL_DS FLAT_RING1_DS
105 #define FLAT_KERNEL_SS FLAT_RING1_SS
106 #define FLAT_USER_CS FLAT_RING3_CS
107 #define FLAT_USER_DS FLAT_RING3_DS
108 #define FLAT_USER_SS FLAT_RING3_SS
110 /*
111 * Virtual addresses beyond this are not modifiable by guest OSes. The
112 * machine->physical mapping table starts at this address, read-only.
113 */
114 #ifdef CONFIG_X86_PAE
115 #define __HYPERVISOR_VIRT_START 0xF5800000
116 #define __MACH2PHYS_VIRT_START 0xF5800000
117 #define __MACH2PHYS_VIRT_END 0xF6800000
118 #else
119 #define __HYPERVISOR_VIRT_START 0xFC000000
120 #define __MACH2PHYS_VIRT_START 0xFC000000
121 #define __MACH2PHYS_VIRT_END 0xFC400000
122 #endif
124 #ifndef HYPERVISOR_VIRT_START
125 #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
126 #endif
128 #define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
129 #define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
130 #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
131 #ifndef machine_to_phys_mapping
132 #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
133 #endif
135 /* Maximum number of virtual CPUs in multi-processor guests. */
136 #define MAX_VIRT_CPUS 32
138 #ifndef __ASSEMBLY__
140 typedef unsigned long xen_ulong_t;
142 /*
143 * Send an array of these to HYPERVISOR_set_trap_table()
144 */
145 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
146 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
147 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
148 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
149 struct trap_info {
150 uint8_t vector; /* exception vector */
151 uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
152 uint16_t cs; /* code selector */
153 unsigned long address; /* code offset */
154 };
155 typedef struct trap_info trap_info_t;
156 DEFINE_XEN_GUEST_HANDLE(trap_info_t);
158 struct cpu_user_regs {
159 uint32_t ebx;
160 uint32_t ecx;
161 uint32_t edx;
162 uint32_t esi;
163 uint32_t edi;
164 uint32_t ebp;
165 uint32_t eax;
166 uint16_t error_code; /* private */
167 uint16_t entry_vector; /* private */
168 uint32_t eip;
169 uint16_t cs;
170 uint8_t saved_upcall_mask;
171 uint8_t _pad0;
172 uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
173 uint32_t esp;
174 uint16_t ss, _pad1;
175 uint16_t es, _pad2;
176 uint16_t ds, _pad3;
177 uint16_t fs, _pad4;
178 uint16_t gs, _pad5;
179 };
180 typedef struct cpu_user_regs cpu_user_regs_t;
181 DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
183 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
185 /*
186 * The following is all CPU context. Note that the fpu_ctxt block is filled
187 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
188 */
189 struct vcpu_guest_context {
190 /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
191 struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
192 #define VGCF_I387_VALID (1<<0)
193 #define VGCF_IN_KERNEL (1<<2)
194 #define _VGCF_i387_valid 0
195 #define VGCF_i387_valid (1<<_VGCF_i387_valid)
196 #define _VGCF_in_kernel 2
197 #define VGCF_in_kernel (1<<_VGCF_in_kernel)
198 #define _VGCF_failsafe_disables_events 3
199 #define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
200 unsigned long flags; /* VGCF_* flags */
201 struct cpu_user_regs user_regs; /* User-level CPU registers */
202 struct trap_info trap_ctxt[256]; /* Virtual IDT */
203 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
204 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
205 unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
206 unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
207 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
208 unsigned long event_callback_cs; /* CS:EIP of event callback */
209 unsigned long event_callback_eip;
210 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
211 unsigned long failsafe_callback_eip;
212 unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
213 };
214 typedef struct vcpu_guest_context vcpu_guest_context_t;
215 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
217 /*
218 * Page-directory addresses above 4GB do not fit into architectural %cr3.
219 * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
220 * must use the following accessor macros to pack/unpack valid MFNs.
221 */
222 #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
223 #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
225 struct arch_shared_info {
226 unsigned long max_pfn; /* max pfn that appears in table */
227 /* Frame containing list of mfns containing list of mfns containing p2m. */
228 xen_pfn_t pfn_to_mfn_frame_list_list;
229 unsigned long nmi_reason;
230 uint64_t pad[32];
231 };
232 typedef struct arch_shared_info arch_shared_info_t;
234 struct arch_vcpu_info {
235 unsigned long cr2;
236 unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
237 };
238 typedef struct arch_vcpu_info arch_vcpu_info_t;
240 struct xen_callback {
241 unsigned long cs;
242 unsigned long eip;
243 };
244 typedef struct xen_callback xen_callback_t;
246 #endif /* !__ASSEMBLY__ */
248 /*
249 * Prefix forces emulation of some non-trapping instructions.
250 * Currently only CPUID.
251 */
252 #ifdef __ASSEMBLY__
253 #define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
254 #define XEN_CPUID XEN_EMULATE_PREFIX cpuid
255 #else
256 #define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
257 #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
258 #endif
260 #endif
262 /*
263 * Local variables:
264 * mode: C
265 * c-set-style: "BSD"
266 * c-basic-offset: 4
267 * tab-width: 4
268 * indent-tabs-mode: nil
269 * End:
270 */