debuggers.hg

view xen/include/public/arch-x86/xen.h @ 16712:ad0f20f5590a

Rename uintN_t guest handles to uintN, to avoid nameclash with uintN_t
macros during the handle definitions.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Dec 28 15:44:51 2007 +0000 (2007-12-28)
parents 0f196e11a143
children 692a91e3b262
line source
1 /******************************************************************************
2 * arch-x86/xen.h
3 *
4 * Guest OS interface to x86 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-2006, K A Fraser
25 */
27 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
28 #define __XEN_PUBLIC_ARCH_X86_XEN_H__
30 /* Structural guest handles introduced in 0x00030201. */
31 #if __XEN_INTERFACE_VERSION__ >= 0x00030201
32 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
33 typedef struct { type *p; } __guest_handle_ ## name
34 #else
35 #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
36 typedef type * __guest_handle_ ## name
37 #endif
39 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
40 ___DEFINE_XEN_GUEST_HANDLE(name, type)
41 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
42 #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name
43 #define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name)
44 #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
45 #ifdef __XEN_TOOLS__
46 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
47 #endif
49 #if defined(__i386__)
50 #include "xen-x86_32.h"
51 #elif defined(__x86_64__)
52 #include "xen-x86_64.h"
53 #endif
55 #ifndef __ASSEMBLY__
56 /* Guest handles for primitive C types. */
57 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
58 __DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
59 __DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
60 DEFINE_XEN_GUEST_HANDLE(char);
61 DEFINE_XEN_GUEST_HANDLE(int);
62 DEFINE_XEN_GUEST_HANDLE(long);
63 DEFINE_XEN_GUEST_HANDLE(void);
65 typedef unsigned long xen_pfn_t;
66 DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
67 #define PRI_xen_pfn "lx"
68 #endif
70 /*
71 * SEGMENT DESCRIPTOR TABLES
72 */
73 /*
74 * A number of GDT entries are reserved by Xen. These are not situated at the
75 * start of the GDT because some stupid OSes export hard-coded selector values
76 * in their ABI. These hard-coded values are always near the start of the GDT,
77 * so Xen places itself out of the way, at the far end of the GDT.
78 */
79 #define FIRST_RESERVED_GDT_PAGE 14
80 #define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
81 #define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
83 /* Maximum number of virtual CPUs in multi-processor guests. */
84 #define MAX_VIRT_CPUS 32
86 #ifndef __ASSEMBLY__
88 typedef unsigned long xen_ulong_t;
90 /*
91 * Send an array of these to HYPERVISOR_set_trap_table().
92 * The privilege level specifies which modes may enter a trap via a software
93 * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
94 * privilege levels as follows:
95 * Level == 0: Noone may enter
96 * Level == 1: Kernel may enter
97 * Level == 2: Kernel may enter
98 * Level == 3: Everyone may enter
99 */
100 #define TI_GET_DPL(_ti) ((_ti)->flags & 3)
101 #define TI_GET_IF(_ti) ((_ti)->flags & 4)
102 #define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
103 #define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
104 struct trap_info {
105 uint8_t vector; /* exception vector */
106 uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
107 uint16_t cs; /* code selector */
108 unsigned long address; /* code offset */
109 };
110 typedef struct trap_info trap_info_t;
111 DEFINE_XEN_GUEST_HANDLE(trap_info_t);
113 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
115 /*
116 * The following is all CPU context. Note that the fpu_ctxt block is filled
117 * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
118 */
119 struct vcpu_guest_context {
120 /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
121 struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
122 #define VGCF_I387_VALID (1<<0)
123 #define VGCF_IN_KERNEL (1<<2)
124 #define _VGCF_i387_valid 0
125 #define VGCF_i387_valid (1<<_VGCF_i387_valid)
126 #define _VGCF_in_kernel 2
127 #define VGCF_in_kernel (1<<_VGCF_in_kernel)
128 #define _VGCF_failsafe_disables_events 3
129 #define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
130 #define _VGCF_syscall_disables_events 4
131 #define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
132 #define _VGCF_online 5
133 #define VGCF_online (1<<_VGCF_online)
134 unsigned long flags; /* VGCF_* flags */
135 struct cpu_user_regs user_regs; /* User-level CPU registers */
136 struct trap_info trap_ctxt[256]; /* Virtual IDT */
137 unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
138 unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
139 unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
140 /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
141 unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
142 unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
143 #ifdef __i386__
144 unsigned long event_callback_cs; /* CS:EIP of event callback */
145 unsigned long event_callback_eip;
146 unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
147 unsigned long failsafe_callback_eip;
148 #else
149 unsigned long event_callback_eip;
150 unsigned long failsafe_callback_eip;
151 #ifdef __XEN__
152 union {
153 unsigned long syscall_callback_eip;
154 struct {
155 unsigned int event_callback_cs; /* compat CS of event cb */
156 unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */
157 };
158 };
159 #else
160 unsigned long syscall_callback_eip;
161 #endif
162 #endif
163 unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
164 #ifdef __x86_64__
165 /* Segment base addresses. */
166 uint64_t fs_base;
167 uint64_t gs_base_kernel;
168 uint64_t gs_base_user;
169 #endif
170 };
171 typedef struct vcpu_guest_context vcpu_guest_context_t;
172 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
174 struct arch_shared_info {
175 unsigned long max_pfn; /* max pfn that appears in table */
176 /* Frame containing list of mfns containing list of mfns containing p2m. */
177 xen_pfn_t pfn_to_mfn_frame_list_list;
178 unsigned long nmi_reason;
179 uint64_t pad[32];
180 };
181 typedef struct arch_shared_info arch_shared_info_t;
183 #endif /* !__ASSEMBLY__ */
185 /*
186 * Prefix forces emulation of some non-trapping instructions.
187 * Currently only CPUID.
188 */
189 #ifdef __ASSEMBLY__
190 #define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
191 #define XEN_CPUID XEN_EMULATE_PREFIX cpuid
192 #else
193 #define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
194 #define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
195 #endif
197 #endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
199 /*
200 * Local variables:
201 * mode: C
202 * c-set-style: "BSD"
203 * c-basic-offset: 4
204 * tab-width: 4
205 * indent-tabs-mode: nil
206 * End:
207 */