ftrace: avoid modifying kprobe'd records
[deliverable/linux.git] / include / xen / interface / xen.h
1 /******************************************************************************
2 * xen.h
3 *
4 * Guest OS interface to Xen.
5 *
6 * Copyright (c) 2004, K A Fraser
7 */
8
9 #ifndef __XEN_PUBLIC_XEN_H__
10 #define __XEN_PUBLIC_XEN_H__
11
12 #include <asm/xen/interface.h>
13
14 /*
15 * XEN "SYSTEM CALLS" (a.k.a. HYPERCALLS).
16 */
17
18 /*
19 * x86_32: EAX = vector; EBX, ECX, EDX, ESI, EDI = args 1, 2, 3, 4, 5.
20 * EAX = return value
21 * (argument registers may be clobbered on return)
22 * x86_64: RAX = vector; RDI, RSI, RDX, R10, R8, R9 = args 1, 2, 3, 4, 5, 6.
23 * RAX = return value
24 * (argument registers not clobbered on return; RCX, R11 are)
25 */
26 #define __HYPERVISOR_set_trap_table 0
27 #define __HYPERVISOR_mmu_update 1
28 #define __HYPERVISOR_set_gdt 2
29 #define __HYPERVISOR_stack_switch 3
30 #define __HYPERVISOR_set_callbacks 4
31 #define __HYPERVISOR_fpu_taskswitch 5
32 #define __HYPERVISOR_sched_op 6
33 #define __HYPERVISOR_dom0_op 7
34 #define __HYPERVISOR_set_debugreg 8
35 #define __HYPERVISOR_get_debugreg 9
36 #define __HYPERVISOR_update_descriptor 10
37 #define __HYPERVISOR_memory_op 12
38 #define __HYPERVISOR_multicall 13
39 #define __HYPERVISOR_update_va_mapping 14
40 #define __HYPERVISOR_set_timer_op 15
41 #define __HYPERVISOR_event_channel_op_compat 16
42 #define __HYPERVISOR_xen_version 17
43 #define __HYPERVISOR_console_io 18
44 #define __HYPERVISOR_physdev_op_compat 19
45 #define __HYPERVISOR_grant_table_op 20
46 #define __HYPERVISOR_vm_assist 21
47 #define __HYPERVISOR_update_va_mapping_otherdomain 22
48 #define __HYPERVISOR_iret 23 /* x86 only */
49 #define __HYPERVISOR_vcpu_op 24
50 #define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
51 #define __HYPERVISOR_mmuext_op 26
52 #define __HYPERVISOR_acm_op 27
53 #define __HYPERVISOR_nmi_op 28
54 #define __HYPERVISOR_sched_op_new 29
55 #define __HYPERVISOR_callback_op 30
56 #define __HYPERVISOR_xenoprof_op 31
57 #define __HYPERVISOR_event_channel_op 32
58 #define __HYPERVISOR_physdev_op 33
59 #define __HYPERVISOR_hvm_op 34
60
61 /* Architecture-specific hypercall definitions. */
62 #define __HYPERVISOR_arch_0 48
63 #define __HYPERVISOR_arch_1 49
64 #define __HYPERVISOR_arch_2 50
65 #define __HYPERVISOR_arch_3 51
66 #define __HYPERVISOR_arch_4 52
67 #define __HYPERVISOR_arch_5 53
68 #define __HYPERVISOR_arch_6 54
69 #define __HYPERVISOR_arch_7 55
70
71 /*
72 * VIRTUAL INTERRUPTS
73 *
74 * Virtual interrupts that a guest OS may receive from Xen.
75 */
76 #define VIRQ_TIMER 0 /* Timebase update, and/or requested timeout. */
77 #define VIRQ_DEBUG 1 /* Request guest to dump debug info. */
78 #define VIRQ_CONSOLE 2 /* (DOM0) Bytes received on emergency console. */
79 #define VIRQ_DOM_EXC 3 /* (DOM0) Exceptional event for some domain. */
80 #define VIRQ_DEBUGGER 6 /* (DOM0) A domain has paused for debugging. */
81
82 /* Architecture-specific VIRQ definitions. */
83 #define VIRQ_ARCH_0 16
84 #define VIRQ_ARCH_1 17
85 #define VIRQ_ARCH_2 18
86 #define VIRQ_ARCH_3 19
87 #define VIRQ_ARCH_4 20
88 #define VIRQ_ARCH_5 21
89 #define VIRQ_ARCH_6 22
90 #define VIRQ_ARCH_7 23
91
92 #define NR_VIRQS 24
93 /*
94 * MMU-UPDATE REQUESTS
95 *
96 * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
97 * A foreigndom (FD) can be specified (or DOMID_SELF for none).
98 * Where the FD has some effect, it is described below.
99 * ptr[1:0] specifies the appropriate MMU_* command.
100 *
101 * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
102 * Updates an entry in a page table. If updating an L1 table, and the new
103 * table entry is valid/present, the mapped frame must belong to the FD, if
104 * an FD has been specified. If attempting to map an I/O page then the
105 * caller assumes the privilege of the FD.
106 * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
107 * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
108 * ptr[:2] -- Machine address of the page-table entry to modify.
109 * val -- Value to write.
110 *
111 * ptr[1:0] == MMU_MACHPHYS_UPDATE:
112 * Updates an entry in the machine->pseudo-physical mapping table.
113 * ptr[:2] -- Machine address within the frame whose mapping to modify.
114 * The frame must belong to the FD, if one is specified.
115 * val -- Value to write into the mapping entry.
116 */
117 #define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */
118 #define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */
119
120 /*
121 * MMU EXTENDED OPERATIONS
122 *
123 * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
124 * A foreigndom (FD) can be specified (or DOMID_SELF for none).
125 * Where the FD has some effect, it is described below.
126 *
127 * cmd: MMUEXT_(UN)PIN_*_TABLE
128 * mfn: Machine frame number to be (un)pinned as a p.t. page.
129 * The frame must belong to the FD, if one is specified.
130 *
131 * cmd: MMUEXT_NEW_BASEPTR
132 * mfn: Machine frame number of new page-table base to install in MMU.
133 *
134 * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
135 * mfn: Machine frame number of new page-table base to install in MMU
136 * when in user space.
137 *
138 * cmd: MMUEXT_TLB_FLUSH_LOCAL
139 * No additional arguments. Flushes local TLB.
140 *
141 * cmd: MMUEXT_INVLPG_LOCAL
142 * linear_addr: Linear address to be flushed from the local TLB.
143 *
144 * cmd: MMUEXT_TLB_FLUSH_MULTI
145 * vcpumask: Pointer to bitmap of VCPUs to be flushed.
146 *
147 * cmd: MMUEXT_INVLPG_MULTI
148 * linear_addr: Linear address to be flushed.
149 * vcpumask: Pointer to bitmap of VCPUs to be flushed.
150 *
151 * cmd: MMUEXT_TLB_FLUSH_ALL
152 * No additional arguments. Flushes all VCPUs' TLBs.
153 *
154 * cmd: MMUEXT_INVLPG_ALL
155 * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
156 *
157 * cmd: MMUEXT_FLUSH_CACHE
158 * No additional arguments. Writes back and flushes cache contents.
159 *
160 * cmd: MMUEXT_SET_LDT
161 * linear_addr: Linear address of LDT base (NB. must be page-aligned).
162 * nr_ents: Number of entries in LDT.
163 */
164 #define MMUEXT_PIN_L1_TABLE 0
165 #define MMUEXT_PIN_L2_TABLE 1
166 #define MMUEXT_PIN_L3_TABLE 2
167 #define MMUEXT_PIN_L4_TABLE 3
168 #define MMUEXT_UNPIN_TABLE 4
169 #define MMUEXT_NEW_BASEPTR 5
170 #define MMUEXT_TLB_FLUSH_LOCAL 6
171 #define MMUEXT_INVLPG_LOCAL 7
172 #define MMUEXT_TLB_FLUSH_MULTI 8
173 #define MMUEXT_INVLPG_MULTI 9
174 #define MMUEXT_TLB_FLUSH_ALL 10
175 #define MMUEXT_INVLPG_ALL 11
176 #define MMUEXT_FLUSH_CACHE 12
177 #define MMUEXT_SET_LDT 13
178 #define MMUEXT_NEW_USER_BASEPTR 15
179
180 #ifndef __ASSEMBLY__
181 struct mmuext_op {
182 unsigned int cmd;
183 union {
184 /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
185 unsigned long mfn;
186 /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
187 unsigned long linear_addr;
188 } arg1;
189 union {
190 /* SET_LDT */
191 unsigned int nr_ents;
192 /* TLB_FLUSH_MULTI, INVLPG_MULTI */
193 void *vcpumask;
194 } arg2;
195 };
196 DEFINE_GUEST_HANDLE_STRUCT(mmuext_op);
197 #endif
198
199 /* These are passed as 'flags' to update_va_mapping. They can be ORed. */
200 /* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */
201 /* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */
202 #define UVMF_NONE (0UL<<0) /* No flushing at all. */
203 #define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */
204 #define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */
205 #define UVMF_FLUSHTYPE_MASK (3UL<<0)
206 #define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */
207 #define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */
208 #define UVMF_ALL (1UL<<2) /* Flush all TLBs. */
209
210 /*
211 * Commands to HYPERVISOR_console_io().
212 */
213 #define CONSOLEIO_write 0
214 #define CONSOLEIO_read 1
215
216 /*
217 * Commands to HYPERVISOR_vm_assist().
218 */
219 #define VMASST_CMD_enable 0
220 #define VMASST_CMD_disable 1
221 #define VMASST_TYPE_4gb_segments 0
222 #define VMASST_TYPE_4gb_segments_notify 1
223 #define VMASST_TYPE_writable_pagetables 2
224 #define VMASST_TYPE_pae_extended_cr3 3
225 #define MAX_VMASST_TYPE 3
226
227 #ifndef __ASSEMBLY__
228
229 typedef uint16_t domid_t;
230
231 /* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
232 #define DOMID_FIRST_RESERVED (0x7FF0U)
233
234 /* DOMID_SELF is used in certain contexts to refer to oneself. */
235 #define DOMID_SELF (0x7FF0U)
236
237 /*
238 * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
239 * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
240 * is useful to ensure that no mappings to the OS's own heap are accidentally
241 * installed. (e.g., in Linux this could cause havoc as reference counts
242 * aren't adjusted on the I/O-mapping code path).
243 * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
244 * be specified by any calling domain.
245 */
246 #define DOMID_IO (0x7FF1U)
247
248 /*
249 * DOMID_XEN is used to allow privileged domains to map restricted parts of
250 * Xen's heap space (e.g., the machine_to_phys table).
251 * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
252 * the caller is privileged.
253 */
254 #define DOMID_XEN (0x7FF2U)
255
256 /*
257 * Send an array of these to HYPERVISOR_mmu_update().
258 * NB. The fields are natural pointer/address size for this architecture.
259 */
260 struct mmu_update {
261 uint64_t ptr; /* Machine address of PTE. */
262 uint64_t val; /* New contents of PTE. */
263 };
264 DEFINE_GUEST_HANDLE_STRUCT(mmu_update);
265
266 /*
267 * Send an array of these to HYPERVISOR_multicall().
268 * NB. The fields are natural register size for this architecture.
269 */
270 struct multicall_entry {
271 unsigned long op;
272 long result;
273 unsigned long args[6];
274 };
275 DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);
276
277 /*
278 * Event channel endpoints per domain:
279 * 1024 if a long is 32 bits; 4096 if a long is 64 bits.
280 */
281 #define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64)
282
283 struct vcpu_time_info {
284 /*
285 * Updates to the following values are preceded and followed
286 * by an increment of 'version'. The guest can therefore
287 * detect updates by looking for changes to 'version'. If the
288 * least-significant bit of the version number is set then an
289 * update is in progress and the guest must wait to read a
290 * consistent set of values. The correct way to interact with
291 * the version number is similar to Linux's seqlock: see the
292 * implementations of read_seqbegin/read_seqretry.
293 */
294 uint32_t version;
295 uint32_t pad0;
296 uint64_t tsc_timestamp; /* TSC at last update of time vals. */
297 uint64_t system_time; /* Time, in nanosecs, since boot. */
298 /*
299 * Current system time:
300 * system_time + ((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul
301 * CPU frequency (Hz):
302 * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
303 */
304 uint32_t tsc_to_system_mul;
305 int8_t tsc_shift;
306 int8_t pad1[3];
307 }; /* 32 bytes */
308
309 struct vcpu_info {
310 /*
311 * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
312 * a pending notification for a particular VCPU. It is then cleared
313 * by the guest OS /before/ checking for pending work, thus avoiding
314 * a set-and-check race. Note that the mask is only accessed by Xen
315 * on the CPU that is currently hosting the VCPU. This means that the
316 * pending and mask flags can be updated by the guest without special
317 * synchronisation (i.e., no need for the x86 LOCK prefix).
318 * This may seem suboptimal because if the pending flag is set by
319 * a different CPU then an IPI may be scheduled even when the mask
320 * is set. However, note:
321 * 1. The task of 'interrupt holdoff' is covered by the per-event-
322 * channel mask bits. A 'noisy' event that is continually being
323 * triggered can be masked at source at this very precise
324 * granularity.
325 * 2. The main purpose of the per-VCPU mask is therefore to restrict
326 * reentrant execution: whether for concurrency control, or to
327 * prevent unbounded stack usage. Whatever the purpose, we expect
328 * that the mask will be asserted only for short periods at a time,
329 * and so the likelihood of a 'spurious' IPI is suitably small.
330 * The mask is read before making an event upcall to the guest: a
331 * non-zero mask therefore guarantees that the VCPU will not receive
332 * an upcall activation. The mask is cleared when the VCPU requests
333 * to block: this avoids wakeup-waiting races.
334 */
335 uint8_t evtchn_upcall_pending;
336 uint8_t evtchn_upcall_mask;
337 unsigned long evtchn_pending_sel;
338 struct arch_vcpu_info arch;
339 struct vcpu_time_info time;
340 }; /* 64 bytes (x86) */
341
342 /*
343 * Xen/kernel shared data -- pointer provided in start_info.
344 * NB. We expect that this struct is smaller than a page.
345 */
346 struct shared_info {
347 struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
348
349 /*
350 * A domain can create "event channels" on which it can send and receive
351 * asynchronous event notifications. There are three classes of event that
352 * are delivered by this mechanism:
353 * 1. Bi-directional inter- and intra-domain connections. Domains must
354 * arrange out-of-band to set up a connection (usually by allocating
355 * an unbound 'listener' port and avertising that via a storage service
356 * such as xenstore).
357 * 2. Physical interrupts. A domain with suitable hardware-access
358 * privileges can bind an event-channel port to a physical interrupt
359 * source.
360 * 3. Virtual interrupts ('events'). A domain can bind an event-channel
361 * port to a virtual interrupt source, such as the virtual-timer
362 * device or the emergency console.
363 *
364 * Event channels are addressed by a "port index". Each channel is
365 * associated with two bits of information:
366 * 1. PENDING -- notifies the domain that there is a pending notification
367 * to be processed. This bit is cleared by the guest.
368 * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING
369 * will cause an asynchronous upcall to be scheduled. This bit is only
370 * updated by the guest. It is read-only within Xen. If a channel
371 * becomes pending while the channel is masked then the 'edge' is lost
372 * (i.e., when the channel is unmasked, the guest must manually handle
373 * pending notifications as no upcall will be scheduled by Xen).
374 *
375 * To expedite scanning of pending notifications, any 0->1 pending
376 * transition on an unmasked channel causes a corresponding bit in a
377 * per-vcpu selector word to be set. Each bit in the selector covers a
378 * 'C long' in the PENDING bitfield array.
379 */
380 unsigned long evtchn_pending[sizeof(unsigned long) * 8];
381 unsigned long evtchn_mask[sizeof(unsigned long) * 8];
382
383 /*
384 * Wallclock time: updated only by control software. Guests should base
385 * their gettimeofday() syscall on this wallclock-base value.
386 */
387 uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */
388 uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
389 uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
390
391 struct arch_shared_info arch;
392
393 };
394
395 /*
396 * Start-of-day memory layout for the initial domain (DOM0):
397 * 1. The domain is started within contiguous virtual-memory region.
398 * 2. The contiguous region begins and ends on an aligned 4MB boundary.
399 * 3. The region start corresponds to the load address of the OS image.
400 * If the load address is not 4MB aligned then the address is rounded down.
401 * 4. This the order of bootstrap elements in the initial virtual region:
402 * a. relocated kernel image
403 * b. initial ram disk [mod_start, mod_len]
404 * c. list of allocated page frames [mfn_list, nr_pages]
405 * d. start_info_t structure [register ESI (x86)]
406 * e. bootstrap page tables [pt_base, CR3 (x86)]
407 * f. bootstrap stack [register ESP (x86)]
408 * 5. Bootstrap elements are packed together, but each is 4kB-aligned.
409 * 6. The initial ram disk may be omitted.
410 * 7. The list of page frames forms a contiguous 'pseudo-physical' memory
411 * layout for the domain. In particular, the bootstrap virtual-memory
412 * region is a 1:1 mapping to the first section of the pseudo-physical map.
413 * 8. All bootstrap elements are mapped read-writable for the guest OS. The
414 * only exception is the bootstrap page table, which is mapped read-only.
415 * 9. There is guaranteed to be at least 512kB padding after the final
416 * bootstrap element. If necessary, the bootstrap virtual region is
417 * extended by an extra 4MB to ensure this.
418 */
419
420 #define MAX_GUEST_CMDLINE 1024
421 struct start_info {
422 /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
423 char magic[32]; /* "xen-<version>-<platform>". */
424 unsigned long nr_pages; /* Total pages allocated to this domain. */
425 unsigned long shared_info; /* MACHINE address of shared info struct. */
426 uint32_t flags; /* SIF_xxx flags. */
427 unsigned long store_mfn; /* MACHINE page number of shared page. */
428 uint32_t store_evtchn; /* Event channel for store communication. */
429 union {
430 struct {
431 unsigned long mfn; /* MACHINE page number of console page. */
432 uint32_t evtchn; /* Event channel for console page. */
433 } domU;
434 struct {
435 uint32_t info_off; /* Offset of console_info struct. */
436 uint32_t info_size; /* Size of console_info struct from start.*/
437 } dom0;
438 } console;
439 /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
440 unsigned long pt_base; /* VIRTUAL address of page directory. */
441 unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */
442 unsigned long mfn_list; /* VIRTUAL address of page-frame list. */
443 unsigned long mod_start; /* VIRTUAL address of pre-loaded module. */
444 unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
445 int8_t cmd_line[MAX_GUEST_CMDLINE];
446 };
447
448 /* These flags are passed in the 'flags' field of start_info_t. */
449 #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
450 #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */
451
452 typedef uint64_t cpumap_t;
453
454 typedef uint8_t xen_domain_handle_t[16];
455
456 /* Turn a plain number into a C unsigned long constant. */
457 #define __mk_unsigned_long(x) x ## UL
458 #define mk_unsigned_long(x) __mk_unsigned_long(x)
459
460 #else /* __ASSEMBLY__ */
461
462 /* In assembly code we cannot use C numeric constant suffixes. */
463 #define mk_unsigned_long(x) x
464
465 #endif /* !__ASSEMBLY__ */
466
467 #endif /* __XEN_PUBLIC_XEN_H__ */
This page took 0.040327 seconds and 5 git commands to generate.