Xen Test Framework
xen.h
Go to the documentation of this file.
1/*
2 * Xen public hypercall interface
3 */
4
5#ifndef XEN_PUBLIC_XEN_H
6#define XEN_PUBLIC_XEN_H
7
8#if defined(__i386__) || defined(__x86_64__)
9#include "arch-x86/xen.h"
10#else
11#error Bad architecture
12#endif
13
14#define __HYPERVISOR_set_trap_table 0
15#define __HYPERVISOR_mmu_update 1
16#define __HYPERVISOR_set_gdt 2
17#define __HYPERVISOR_stack_switch 3
18#define __HYPERVISOR_set_callbacks 4
19#define __HYPERVISOR_fpu_taskswitch 5
20#define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */
21#define __HYPERVISOR_platform_op 7
22#define __HYPERVISOR_set_debugreg 8
23#define __HYPERVISOR_get_debugreg 9
24#define __HYPERVISOR_update_descriptor 10
25#define __HYPERVISOR_memory_op 12
26#define __HYPERVISOR_multicall 13
27#define __HYPERVISOR_update_va_mapping 14
28#define __HYPERVISOR_set_timer_op 15
29#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
30#define __HYPERVISOR_xen_version 17
31#define __HYPERVISOR_console_io 18
32#define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */
33#define __HYPERVISOR_grant_table_op 20
34#define __HYPERVISOR_vm_assist 21
35#define __HYPERVISOR_update_va_mapping_otherdomain 22
36#define __HYPERVISOR_iret 23 /* x86 only */
37#define __HYPERVISOR_vcpu_op 24
38#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
39#define __HYPERVISOR_mmuext_op 26
40#define __HYPERVISOR_xsm_op 27
41#define __HYPERVISOR_nmi_op 28
42#define __HYPERVISOR_sched_op 29
43#define __HYPERVISOR_callback_op 30
44#define __HYPERVISOR_xenoprof_op 31
45#define __HYPERVISOR_event_channel_op 32
46#define __HYPERVISOR_physdev_op 33
47#define __HYPERVISOR_hvm_op 34
48#define __HYPERVISOR_sysctl 35
49#define __HYPERVISOR_domctl 36
50#define __HYPERVISOR_kexec_op 37
51#define __HYPERVISOR_tmem_op 38
52#define __HYPERVISOR_argo_op 39
53#define __HYPERVISOR_xenpmu_op 40
54
55/* Architecture-specific hypercall definitions. */
56#define __HYPERVISOR_arch_0 48
57#define __HYPERVISOR_arch_1 49
58#define __HYPERVISOR_arch_2 50
59#define __HYPERVISOR_arch_3 51
60#define __HYPERVISOR_arch_4 52
61#define __HYPERVISOR_arch_5 53
62#define __HYPERVISOR_arch_6 54
63#define __HYPERVISOR_arch_7 55
64
65#ifndef __ASSEMBLY__
67#endif
68
69#define DOMID_FIRST_RESERVED (0x7ff0U)
70#define DOMID_SELF (0x7ff0U)
71
72/* Commands to HYPERVISOR_console_io */
73#define CONSOLEIO_write 0
74
75/*
76 * Commands to HYPERVISOR_vm_assist().
77 */
78#define VMASST_CMD_enable 0
79#define VMASST_CMD_disable 1
80
81/*
82 * x86 guests: Sane behaviour for virtual iopl
83 * - virtual iopl updated from do_iret() hypercalls.
84 * - virtual iopl reported in bounce frames.
85 * - guest kernels assumed to be level 0 for the purpose of iopl checks.
86 */
87#define VMASST_TYPE_architectural_iopl 4
88
89
90#ifndef __ASSEMBLY__
92 /*
93 * Updates to the following values are preceded and followed by an
94 * increment of 'version'. The guest can therefore detect updates by
95 * looking for changes to 'version'. If the least-significant bit of
96 * the version number is set then an update is in progress and the guest
97 * must wait to read a consistent set of values.
98 * The correct way to interact with the version number is similar to
99 * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
100 */
103 uint64_t tsc_timestamp; /* TSC at last update of time vals. */
104 uint64_t system_time; /* Time, in nanosecs, since boot. */
105 /*
106 * Current system time:
107 * system_time +
108 * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
109 * CPU frequency (Hz):
110 * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
111 */
116}; /* 32 bytes */
118
119struct vcpu_info {
120 /*
121 * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
122 * a pending notification for a particular VCPU. It is then cleared
123 * by the guest OS /before/ checking for pending work, thus avoiding
124 * a set-and-check race. Note that the mask is only accessed by Xen
125 * on the CPU that is currently hosting the VCPU. This means that the
126 * pending and mask flags can be updated by the guest without special
127 * synchronisation (i.e., no need for the x86 LOCK prefix).
128 * This may seem suboptimal because if the pending flag is set by
129 * a different CPU then an IPI may be scheduled even when the mask
130 * is set. However, note:
131 * 1. The task of 'interrupt holdoff' is covered by the per-event-
132 * channel mask bits. A 'noisy' event that is continually being
133 * triggered can be masked at source at this very precise
134 * granularity.
135 * 2. The main purpose of the per-VCPU mask is therefore to restrict
136 * reentrant execution: whether for concurrency control, or to
137 * prevent unbounded stack usage. Whatever the purpose, we expect
138 * that the mask will be asserted only for short periods at a time,
139 * and so the likelihood of a 'spurious' IPI is suitably small.
140 * The mask is read before making an event upcall to the guest: a
141 * non-zero mask therefore guarantees that the VCPU will not receive
142 * an upcall activation. The mask is cleared when the VCPU requests
143 * to block: this avoids wakeup-waiting races.
144 */
147 unsigned long evtchn_pending_sel;
150}; /* 64 bytes (x86) */
151
154
155 /*
156 * A domain can create "event channels" on which it can send and receive
157 * asynchronous event notifications. There are three classes of event that
158 * are delivered by this mechanism:
159 * 1. Bi-directional inter- and intra-domain connections. Domains must
160 * arrange out-of-band to set up a connection (usually by allocating
161 * an unbound 'listener' port and avertising that via a storage service
162 * such as xenstore).
163 * 2. Physical interrupts. A domain with suitable hardware-access
164 * privileges can bind an event-channel port to a physical interrupt
165 * source.
166 * 3. Virtual interrupts ('events'). A domain can bind an event-channel
167 * port to a virtual interrupt source, such as the virtual-timer
168 * device or the emergency console.
169 *
170 * Event channels are addressed by a "port index". Each channel is
171 * associated with two bits of information:
172 * 1. PENDING -- notifies the domain that there is a pending notification
173 * to be processed. This bit is cleared by the guest.
174 * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING
175 * will cause an asynchronous upcall to be scheduled. This bit is only
176 * updated by the guest. It is read-only within Xen. If a channel
177 * becomes pending while the channel is masked then the 'edge' is lost
178 * (i.e., when the channel is unmasked, the guest must manually handle
179 * pending notifications as no upcall will be scheduled by Xen).
180 *
181 * To expedite scanning of pending notifications, any 0->1 pending
182 * transition on an unmasked channel causes a corresponding bit in a
183 * per-vcpu selector word to be set. Each bit in the selector covers a
184 * 'C long' in the PENDING bitfield array.
185 */
186 unsigned long evtchn_pending[sizeof(unsigned long) * 8];
187 unsigned long evtchn_mask[sizeof(unsigned long) * 8];
188
189 /*
190 * Wallclock time: updated only by control software. Guests should base
191 * their gettimeofday() syscall on this wallclock-base value.
192 */
193 uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */
194 uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
195 uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
196#if !defined(__i386__)
198#endif
199
201};
203
205 /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
206 char magic[32]; /* "xen-<version>-<platform>". */
207 unsigned long nr_pages; /* Total pages allocated to this domain. */
208 unsigned long shared_info; /* MACHINE address of shared info struct. */
209 uint32_t flags; /* SIF_xxx flags. */
210 xen_pfn_t store_mfn; /* MACHINE page number of shared page. */
211 uint32_t store_evtchn; /* Event channel for store communication. */
212 union {
213 struct {
214 xen_pfn_t mfn; /* MACHINE page number of console page. */
215 uint32_t evtchn; /* Event channel for console page. */
217 struct {
218 uint32_t info_off; /* Offset of console_info struct. */
219 uint32_t info_size; /* Size of console_info struct from start.*/
222 /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
223 unsigned long pt_base; /* VIRTUAL address of page directory. */
224 unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */
225 unsigned long mfn_list; /* VIRTUAL address of page-frame list. */
226 unsigned long mod_start; /* VIRTUAL address of pre-loaded module */
227 /* (PFN of pre-loaded module if */
228 /* SIF_MOD_START_PFN set in flags). */
229 unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
230#define MAX_GUEST_CMDLINE 1024
232 /* The pfn range here covers both page table and p->m table frames. */
233 unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */
234 unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */
235};
237#endif
238
239/* These flags are passed in the 'flags' field of start_info_t. */
240#define SIF_PRIVILEGED (1u << 0) /* Is the domain privileged? */
241#define SIF_INITDOMAIN (1u << 1) /* Is this the initial control domain? */
242
243/* MMU UPDATE operations */
244#ifndef __ASSEMBLY__
246#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */
247#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */
248#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */
249 uint64_t ptr; /* Machine address of PTE. */
250 uint64_t val; /* New contents of PTE. */
251};
253
254/*
255 * ` enum neg_errnoval
256 * ` HYPERVISOR_multicall(multicall_entry_t call_list[],
257 * ` uint32_t nr_calls);
258 *
259 * NB. The fields are logically the natural register size for this
260 * architecture. In cases where xen_ulong_t is larger than this then
261 * any unused bits in the upper portion must be zero.
262 */
264 unsigned long op, result;
265 unsigned long args[6];
266};
268#endif
269
270/*
271 * MMU EXTENDED OPERATIONS
272 *
273 * HYPERVISOR_mmuext_op(mmuext_op_t uops[],
274 * unsigned int count,
275 * unsigned int *pdone,
276 * unsigned int foreigndom)
277 *
278 * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
279 * A foreigndom (FD) can be specified (or DOMID_SELF for none).
280 * Where the FD has some effect, it is described below.
281 *
282 * cmd: MMUEXT_(UN)PIN_*_TABLE
283 * mfn: Machine frame number to be (un)pinned as a p.t. page.
284 * The frame must belong to the FD, if one is specified.
285 *
286 * cmd: MMUEXT_NEW_BASEPTR
287 * mfn: Machine frame number of new page-table base to install in MMU.
288 *
289 * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
290 * mfn: Machine frame number of new page-table base to install in MMU
291 * when in user space.
292 *
293 * cmd: MMUEXT_TLB_FLUSH_LOCAL
294 * No additional arguments. Flushes local TLB.
295 *
296 * cmd: MMUEXT_INVLPG_LOCAL
297 * linear_addr: Linear address to be flushed from the local TLB.
298 *
299 * cmd: MMUEXT_TLB_FLUSH_MULTI
300 * vcpumask: Pointer to bitmap of VCPUs to be flushed.
301 *
302 * cmd: MMUEXT_INVLPG_MULTI
303 * linear_addr: Linear address to be flushed.
304 * vcpumask: Pointer to bitmap of VCPUs to be flushed.
305 *
306 * cmd: MMUEXT_TLB_FLUSH_ALL
307 * No additional arguments. Flushes all VCPUs' TLBs.
308 *
309 * cmd: MMUEXT_INVLPG_ALL
310 * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
311 *
312 * cmd: MMUEXT_FLUSH_CACHE
313 * No additional arguments. Writes back and flushes cache contents.
314 *
315 * cmd: MMUEXT_FLUSH_CACHE_GLOBAL
316 * No additional arguments. Writes back and flushes cache contents
317 * on all CPUs in the system.
318 *
319 * cmd: MMUEXT_SET_LDT
320 * linear_addr: Linear address of LDT base (NB. must be page-aligned).
321 * nr_ents: Number of entries in LDT.
322 *
323 * cmd: MMUEXT_CLEAR_PAGE
324 * mfn: Machine frame number to be cleared.
325 *
326 * cmd: MMUEXT_COPY_PAGE
327 * mfn: Machine frame number of the destination page.
328 * src_mfn: Machine frame number of the source page.
329 *
330 * cmd: MMUEXT_[UN]MARK_SUPER
331 * mfn: Machine frame number of head of superpage to be [un]marked.
332 */
333#define MMUEXT_PIN_L1_TABLE 0
334#define MMUEXT_PIN_L2_TABLE 1
335#define MMUEXT_PIN_L3_TABLE 2
336#define MMUEXT_PIN_L4_TABLE 3
337#define MMUEXT_UNPIN_TABLE 4
338#define MMUEXT_NEW_BASEPTR 5
339#define MMUEXT_TLB_FLUSH_LOCAL 6
340#define MMUEXT_INVLPG_LOCAL 7
341#define MMUEXT_TLB_FLUSH_MULTI 8
342#define MMUEXT_INVLPG_MULTI 9
343#define MMUEXT_TLB_FLUSH_ALL 10
344#define MMUEXT_INVLPG_ALL 11
345#define MMUEXT_FLUSH_CACHE 12
346#define MMUEXT_SET_LDT 13
347#define MMUEXT_NEW_USER_BASEPTR 15
348#define MMUEXT_CLEAR_PAGE 16
349#define MMUEXT_COPY_PAGE 17
350#define MMUEXT_FLUSH_CACHE_GLOBAL 18
351#define MMUEXT_MARK_SUPER 19
352#define MMUEXT_UNMARK_SUPER 20
353
354#ifndef __ASSEMBLY__
355struct mmuext_op {
356 unsigned int cmd; /* => enum mmuext_cmd */
357 union {
358 /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR
359 * CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */
361 /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
362 unsigned long linear_addr;
364 union {
365 /* SET_LDT */
366 unsigned int nr_ents;
367 /* TLB_FLUSH_MULTI, INVLPG_MULTI */
368 const void *vcpumask;
369 /* COPY_PAGE */
372};
373typedef struct mmuext_op mmuext_op_t;
374#endif
375
376/* These are passed as 'flags' to update_va_mapping. They can be ORed. */
377/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */
378/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */
379#ifndef __ASSEMBLY__
381 UVMF_NONE = 0 << 0, /* No flushing at all. */
382 UVMF_TLB_FLUSH = 1 << 0, /* Flush entire TLB(s). */
383 UVMF_INVLPG = 2 << 0, /* Flush only one entry. */
385 UVMF_MULTI = 0 << 2, /* Flush subset of TLBs. */
386 UVMF_LOCAL = 0 << 2, /* Flush local TLB. */
387 UVMF_ALL = 1 << 2, /* Flush all TLBs. */
388};
389#endif
390
391#ifndef __ASSEMBLY__
392typedef struct {
393 union {
394 void *p;
396 };
398#endif
399
400#endif /* XEN_PUBLIC_XEN_H */
401
402/*
403 * Local variables:
404 * mode: C
405 * c-file-style: "BSD"
406 * c-basic-offset: 4
407 * tab-width: 4
408 * indent-tabs-mode: nil
409 * End:
410 */
unsigned long xen_pfn_t
Definition: xen.h:19
#define __aligned(x)
Definition: compiler.h:9
__UINT32_TYPE__ uint32_t
Definition: stdint.h:16
__UINT64_TYPE__ uint64_t
Definition: stdint.h:17
__UINT8_TYPE__ uint8_t
Definition: stdint.h:14
__UINT16_TYPE__ uint16_t
Definition: stdint.h:15
__INT8_TYPE__ int8_t
Definition: stdint.h:9
void * p
Definition: xen.h:394
uint64_t val
Definition: xen.h:250
uint64_t ptr
Definition: xen.h:249
Definition: xen.h:355
xen_pfn_t src_mfn
Definition: xen.h:370
unsigned long linear_addr
Definition: xen.h:362
unsigned int cmd
Definition: xen.h:356
xen_pfn_t mfn
Definition: xen.h:360
union mmuext_op::@52 arg2
unsigned int nr_ents
Definition: xen.h:366
union mmuext_op::@51 arg1
const void * vcpumask
Definition: xen.h:368
Definition: xen.h:263
unsigned long op
Definition: xen.h:264
unsigned long result
Definition: xen.h:264
unsigned long args[6]
Definition: xen.h:265
uint32_t wc_version
Definition: xen.h:193
uint32_t wc_nsec
Definition: xen.h:195
unsigned long evtchn_mask[sizeof(unsigned long) *8]
Definition: xen.h:187
struct arch_shared_info arch
Definition: xen.h:200
uint32_t wc_sec
Definition: xen.h:194
unsigned long evtchn_pending[sizeof(unsigned long) *8]
Definition: xen.h:186
uint32_t wc_sec_hi
Definition: xen.h:197
Definition: xen.h:119
uint8_t evtchn_upcall_mask
Definition: xen.h:146
struct arch_vcpu_info arch
Definition: xen.h:148
unsigned long evtchn_pending_sel
Definition: xen.h:147
uint8_t evtchn_upcall_pending
Definition: xen.h:145
struct vcpu_time_info time
Definition: xen.h:149
uint64_t system_time
Definition: xen.h:104
uint32_t tsc_to_system_mul
Definition: xen.h:112
uint8_t pad1[2]
Definition: xen.h:115
uint8_t flags
Definition: xen.h:114
uint64_t tsc_timestamp
Definition: xen.h:103
int8_t tsc_shift
Definition: xen.h:113
uint32_t version
Definition: xen.h:101
uint32_t pad0
Definition: xen.h:102
struct xen_pv_start_info::@48::@50 dom0
xen_pfn_t store_mfn
Definition: xen.h:210
struct xen_pv_start_info::@48::@49 domU
unsigned long nr_p2m_frames
Definition: xen.h:234
xen_pfn_t mfn
Definition: xen.h:214
unsigned long nr_pt_frames
Definition: xen.h:224
unsigned long mfn_list
Definition: xen.h:225
uint32_t info_size
Definition: xen.h:219
uint32_t flags
Definition: xen.h:209
unsigned long shared_info
Definition: xen.h:208
union xen_pv_start_info::@48 console
char magic[32]
Definition: xen.h:206
unsigned long first_p2m_pfn
Definition: xen.h:233
unsigned long mod_len
Definition: xen.h:229
uint32_t evtchn
Definition: xen.h:215
int8_t cmd_line[MAX_GUEST_CMDLINE]
Definition: xen.h:231
uint32_t store_evtchn
Definition: xen.h:211
uint32_t info_off
Definition: xen.h:218
unsigned long pt_base
Definition: xen.h:223
unsigned long mod_start
Definition: xen.h:226
unsigned long nr_pages
Definition: xen.h:207
uint16_t domid_t
Definition: xen.h:66
#define MAX_GUEST_CMDLINE
Definition: xen.h:230
XEN_UVMF
Definition: xen.h:380
@ UVMF_LOCAL
Definition: xen.h:386
@ UVMF_NONE
Definition: xen.h:381
@ UVMF_ALL
Definition: xen.h:387
@ UVMF_TLB_FLUSH
Definition: xen.h:382
@ UVMF_FLUSHTYPE_MASK
Definition: xen.h:384
@ UVMF_INVLPG
Definition: xen.h:383
@ UVMF_MULTI
Definition: xen.h:385