xref: /titanic_52/usr/src/uts/common/xen/public/domctl.h (revision 9b241b4ed1cf882400b069ff9853cdd310d469bf)
1 /******************************************************************************
2  * domctl.h
3  *
4  * Domain management operations. For use by node control stack.
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) 2002-2003, B Dragovic
25  * Copyright (c) 2002-2006, K Fraser
26  */
27 
28 #ifndef __XEN_PUBLIC_DOMCTL_H__
29 #define __XEN_PUBLIC_DOMCTL_H__
30 
31 #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
32 #error "domctl operations are intended for use by node control tools only"
33 #endif
34 
35 #include "xen.h"
36 
37 #define XEN_DOMCTL_INTERFACE_VERSION 0x00000005
38 
39 struct xenctl_cpumap {
40     XEN_GUEST_HANDLE_64(uint8) bitmap;
41     uint32_t nr_cpus;
42 };
43 
44 /*
45  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
46  * If it is specified as zero, an id is auto-allocated and returned.
47  */
48 #define XEN_DOMCTL_createdomain       1
49 struct xen_domctl_createdomain {
50     /* IN parameters */
51     uint32_t ssidref;
52     xen_domain_handle_t handle;
53  /* Is this an HVM guest (as opposed to a PV guest)? */
54 #define _XEN_DOMCTL_CDF_hvm_guest     0
55 #define XEN_DOMCTL_CDF_hvm_guest      (1U<<_XEN_DOMCTL_CDF_hvm_guest)
56  /* Use hardware-assisted paging if available? */
57 #define _XEN_DOMCTL_CDF_hap           1
58 #define XEN_DOMCTL_CDF_hap            (1U<<_XEN_DOMCTL_CDF_hap)
59  /* Should domain memory integrity be verifed by tboot during Sx? */
60 #define _XEN_DOMCTL_CDF_s3_integrity  2
61 #define XEN_DOMCTL_CDF_s3_integrity   (1U<<_XEN_DOMCTL_CDF_s3_integrity)
62     uint32_t flags;
63 };
64 typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
65 DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t);
66 
67 #define XEN_DOMCTL_destroydomain      2
68 #define XEN_DOMCTL_pausedomain        3
69 #define XEN_DOMCTL_unpausedomain      4
70 #define XEN_DOMCTL_resumedomain      27
71 
72 #define XEN_DOMCTL_getdomaininfo      5
73 struct xen_domctl_getdomaininfo {
74     /* OUT variables. */
75     domid_t  domain;              /* Also echoed in domctl.domain */
76  /* Domain is scheduled to die. */
77 #define _XEN_DOMINF_dying     0
78 #define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
79  /* Domain is an HVM guest (as opposed to a PV guest). */
80 #define _XEN_DOMINF_hvm_guest 1
81 #define XEN_DOMINF_hvm_guest  (1U<<_XEN_DOMINF_hvm_guest)
82  /* The guest OS has shut down. */
83 #define _XEN_DOMINF_shutdown  2
84 #define XEN_DOMINF_shutdown   (1U<<_XEN_DOMINF_shutdown)
85  /* Currently paused by control software. */
86 #define _XEN_DOMINF_paused    3
87 #define XEN_DOMINF_paused     (1U<<_XEN_DOMINF_paused)
88  /* Currently blocked pending an event.     */
89 #define _XEN_DOMINF_blocked   4
90 #define XEN_DOMINF_blocked    (1U<<_XEN_DOMINF_blocked)
91  /* Domain is currently running.            */
92 #define _XEN_DOMINF_running   5
93 #define XEN_DOMINF_running    (1U<<_XEN_DOMINF_running)
94  /* Being debugged.  */
95 #define _XEN_DOMINF_debugged  6
96 #define XEN_DOMINF_debugged   (1U<<_XEN_DOMINF_debugged)
97  /* XEN_DOMINF_shutdown guest-supplied code.  */
98 #define XEN_DOMINF_shutdownmask 255
99 #define XEN_DOMINF_shutdownshift 16
100     uint32_t flags;              /* XEN_DOMINF_* */
101     uint64_aligned_t tot_pages;
102     uint64_aligned_t max_pages;
103     uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */
104     uint64_aligned_t cpu_time;
105     uint32_t nr_online_vcpus;    /* Number of VCPUs currently online. */
106     uint32_t max_vcpu_id;        /* Maximum VCPUID in use by this domain. */
107     uint32_t ssidref;
108     xen_domain_handle_t handle;
109 };
110 typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
111 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t);
112 
113 
114 #define XEN_DOMCTL_getmemlist         6
115 struct xen_domctl_getmemlist {
116     /* IN variables. */
117     /* Max entries to write to output buffer. */
118     uint64_aligned_t max_pfns;
119     /* Start index in guest's page list. */
120     uint64_aligned_t start_pfn;
121     XEN_GUEST_HANDLE_64(uint64) buffer;
122     /* OUT variables. */
123     uint64_aligned_t num_pfns;
124 };
125 typedef struct xen_domctl_getmemlist xen_domctl_getmemlist_t;
126 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getmemlist_t);
127 
128 
129 #define XEN_DOMCTL_getpageframeinfo   7
130 
131 #define XEN_DOMCTL_PFINFO_LTAB_SHIFT 28
132 #define XEN_DOMCTL_PFINFO_NOTAB   (0x0U<<28)
133 #define XEN_DOMCTL_PFINFO_L1TAB   (0x1U<<28)
134 #define XEN_DOMCTL_PFINFO_L2TAB   (0x2U<<28)
135 #define XEN_DOMCTL_PFINFO_L3TAB   (0x3U<<28)
136 #define XEN_DOMCTL_PFINFO_L4TAB   (0x4U<<28)
137 #define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7U<<28)
138 #define XEN_DOMCTL_PFINFO_LPINTAB (0x1U<<31)
139 #define XEN_DOMCTL_PFINFO_XTAB    (0xfU<<28) /* invalid page */
140 #define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28)
141 
142 struct xen_domctl_getpageframeinfo {
143     /* IN variables. */
144     uint64_aligned_t gmfn; /* GMFN to query */
145     /* OUT variables. */
146     /* Is the page PINNED to a type? */
147     uint32_t type;         /* see above type defs */
148 };
149 typedef struct xen_domctl_getpageframeinfo xen_domctl_getpageframeinfo_t;
150 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo_t);
151 
152 
153 #define XEN_DOMCTL_getpageframeinfo2  8
154 struct xen_domctl_getpageframeinfo2 {
155     /* IN variables. */
156     uint64_aligned_t num;
157     /* IN/OUT variables. */
158     XEN_GUEST_HANDLE_64(uint32) array;
159 };
160 typedef struct xen_domctl_getpageframeinfo2 xen_domctl_getpageframeinfo2_t;
161 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo2_t);
162 
163 
164 /*
165  * Control shadow pagetables operation
166  */
167 #define XEN_DOMCTL_shadow_op         10
168 
169 /* Disable shadow mode. */
170 #define XEN_DOMCTL_SHADOW_OP_OFF         0
171 
172 /* Enable shadow mode (mode contains ORed XEN_DOMCTL_SHADOW_ENABLE_* flags). */
173 #define XEN_DOMCTL_SHADOW_OP_ENABLE      32
174 
175 /* Log-dirty bitmap operations. */
176  /* Return the bitmap and clean internal copy for next round. */
177 #define XEN_DOMCTL_SHADOW_OP_CLEAN       11
178  /* Return the bitmap but do not modify internal copy. */
179 #define XEN_DOMCTL_SHADOW_OP_PEEK        12
180 
181 /* Memory allocation accessors. */
182 #define XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
183 #define XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
184 
185 /* Legacy enable operations. */
186  /* Equiv. to ENABLE with no mode flags. */
187 #define XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
188  /* Equiv. to ENABLE with mode flag ENABLE_LOG_DIRTY. */
189 #define XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
190  /* Equiv. to ENABLE with mode flags ENABLE_REFCOUNT and ENABLE_TRANSLATE. */
191 #define XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
192 
193 /* Mode flags for XEN_DOMCTL_SHADOW_OP_ENABLE. */
194  /*
195   * Shadow pagetables are refcounted: guest does not use explicit mmu
196   * operations nor write-protect its pagetables.
197   */
198 #define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
199  /*
200   * Log pages in a bitmap as they are dirtied.
201   * Used for live relocation to determine which pages must be re-sent.
202   */
203 #define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
204  /*
205   * Automatically translate GPFNs into MFNs.
206   */
207 #define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
208  /*
209   * Xen does not steal virtual address space from the guest.
210   * Requires HVM support.
211   */
212 #define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
213 
214 struct xen_domctl_shadow_op_stats {
215     uint32_t fault_count;
216     uint32_t dirty_count;
217 };
218 typedef struct xen_domctl_shadow_op_stats xen_domctl_shadow_op_stats_t;
219 DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_stats_t);
220 
221 struct xen_domctl_shadow_op {
222     /* IN variables. */
223     uint32_t       op;       /* XEN_DOMCTL_SHADOW_OP_* */
224 
225     /* OP_ENABLE */
226     uint32_t       mode;     /* XEN_DOMCTL_SHADOW_ENABLE_* */
227 
228     /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */
229     uint32_t       mb;       /* Shadow memory allocation in MB */
230 
231     /* OP_PEEK / OP_CLEAN */
232     XEN_GUEST_HANDLE_64(uint8) dirty_bitmap;
233     uint64_aligned_t pages; /* Size of buffer. Updated with actual size. */
234     struct xen_domctl_shadow_op_stats stats;
235 };
236 typedef struct xen_domctl_shadow_op xen_domctl_shadow_op_t;
237 DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_t);
238 
239 
240 #define XEN_DOMCTL_max_mem           11
241 struct xen_domctl_max_mem {
242     /* IN variables. */
243     uint64_aligned_t max_memkb;
244 };
245 typedef struct xen_domctl_max_mem xen_domctl_max_mem_t;
246 DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_mem_t);
247 
248 
249 #define XEN_DOMCTL_setvcpucontext    12
250 #define XEN_DOMCTL_getvcpucontext    13
251 struct xen_domctl_vcpucontext {
252     uint32_t              vcpu;                  /* IN */
253     XEN_GUEST_HANDLE_64(vcpu_guest_context_t) ctxt; /* IN/OUT */
254 };
255 typedef struct xen_domctl_vcpucontext xen_domctl_vcpucontext_t;
256 DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpucontext_t);
257 
258 
259 #define XEN_DOMCTL_getvcpuinfo       14
260 struct xen_domctl_getvcpuinfo {
261     /* IN variables. */
262     uint32_t vcpu;
263     /* OUT variables. */
264     uint8_t  online;                  /* currently online (not hotplugged)? */
265     uint8_t  blocked;                 /* blocked waiting for an event? */
266     uint8_t  running;                 /* currently scheduled on its CPU? */
267     uint64_aligned_t cpu_time;        /* total cpu time consumed (ns) */
268     uint32_t cpu;                     /* current mapping   */
269 };
270 typedef struct xen_domctl_getvcpuinfo xen_domctl_getvcpuinfo_t;
271 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getvcpuinfo_t);
272 
273 
274 /* Get/set which physical cpus a vcpu can execute on. */
275 #define XEN_DOMCTL_setvcpuaffinity    9
276 #define XEN_DOMCTL_getvcpuaffinity   25
277 struct xen_domctl_vcpuaffinity {
278     uint32_t  vcpu;              /* IN */
279     struct xenctl_cpumap cpumap; /* IN/OUT */
280 };
281 typedef struct xen_domctl_vcpuaffinity xen_domctl_vcpuaffinity_t;
282 DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpuaffinity_t);
283 
284 
285 #define XEN_DOMCTL_max_vcpus         15
286 struct xen_domctl_max_vcpus {
287     uint32_t max;           /* maximum number of vcpus */
288 };
289 typedef struct xen_domctl_max_vcpus xen_domctl_max_vcpus_t;
290 DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t);
291 
292 
293 #define XEN_DOMCTL_scheduler_op      16
294 /* Scheduler types. */
295 #define XEN_SCHEDULER_SEDF     4
296 #define XEN_SCHEDULER_CREDIT   5
297 /* Set or get info? */
298 #define XEN_DOMCTL_SCHEDOP_putinfo 0
299 #define XEN_DOMCTL_SCHEDOP_getinfo 1
300 struct xen_domctl_scheduler_op {
301     uint32_t sched_id;  /* XEN_SCHEDULER_* */
302     uint32_t cmd;       /* XEN_DOMCTL_SCHEDOP_* */
303     union {
304         struct xen_domctl_sched_sedf {
305             uint64_aligned_t period;
306             uint64_aligned_t slice;
307             uint64_aligned_t latency;
308             uint32_t extratime;
309             uint32_t weight;
310         } sedf;
311         struct xen_domctl_sched_credit {
312             uint16_t weight;
313             uint16_t cap;
314         } credit;
315     } u;
316 };
317 typedef struct xen_domctl_scheduler_op xen_domctl_scheduler_op_t;
318 DEFINE_XEN_GUEST_HANDLE(xen_domctl_scheduler_op_t);
319 
320 
321 #define XEN_DOMCTL_setdomainhandle   17
322 struct xen_domctl_setdomainhandle {
323     xen_domain_handle_t handle;
324 };
325 typedef struct xen_domctl_setdomainhandle xen_domctl_setdomainhandle_t;
326 DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdomainhandle_t);
327 
328 
329 #define XEN_DOMCTL_setdebugging      18
330 struct xen_domctl_setdebugging {
331     uint8_t enable;
332 };
333 typedef struct xen_domctl_setdebugging xen_domctl_setdebugging_t;
334 DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdebugging_t);
335 
336 
337 #define XEN_DOMCTL_irq_permission    19
338 struct xen_domctl_irq_permission {
339     uint8_t pirq;
340     uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
341 };
342 typedef struct xen_domctl_irq_permission xen_domctl_irq_permission_t;
343 DEFINE_XEN_GUEST_HANDLE(xen_domctl_irq_permission_t);
344 
345 
346 #define XEN_DOMCTL_iomem_permission  20
347 struct xen_domctl_iomem_permission {
348     uint64_aligned_t first_mfn;/* first page (physical page number) in range */
349     uint64_aligned_t nr_mfns;  /* number of pages in range (>0) */
350     uint8_t  allow_access;     /* allow (!0) or deny (0) access to range? */
351 };
352 typedef struct xen_domctl_iomem_permission xen_domctl_iomem_permission_t;
353 DEFINE_XEN_GUEST_HANDLE(xen_domctl_iomem_permission_t);
354 
355 
356 #define XEN_DOMCTL_ioport_permission 21
357 struct xen_domctl_ioport_permission {
358     uint32_t first_port;              /* first port int range */
359     uint32_t nr_ports;                /* size of port range */
360     uint8_t  allow_access;            /* allow or deny access to range? */
361 };
362 typedef struct xen_domctl_ioport_permission xen_domctl_ioport_permission_t;
363 DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_permission_t);
364 
365 
366 #define XEN_DOMCTL_hypercall_init    22
367 struct xen_domctl_hypercall_init {
368     uint64_aligned_t  gmfn;           /* GMFN to be initialised */
369 };
370 typedef struct xen_domctl_hypercall_init xen_domctl_hypercall_init_t;
371 DEFINE_XEN_GUEST_HANDLE(xen_domctl_hypercall_init_t);
372 
373 
374 #define XEN_DOMCTL_arch_setup        23
375 #define _XEN_DOMAINSETUP_hvm_guest 0
376 #define XEN_DOMAINSETUP_hvm_guest  (1UL<<_XEN_DOMAINSETUP_hvm_guest)
377 #define _XEN_DOMAINSETUP_query 1 /* Get parameters (for save)  */
378 #define XEN_DOMAINSETUP_query  (1UL<<_XEN_DOMAINSETUP_query)
379 #define _XEN_DOMAINSETUP_sioemu_guest 2
380 #define XEN_DOMAINSETUP_sioemu_guest  (1UL<<_XEN_DOMAINSETUP_sioemu_guest)
381 typedef struct xen_domctl_arch_setup {
382     uint64_aligned_t flags;  /* XEN_DOMAINSETUP_* */
383 #ifdef __ia64__
384     uint64_aligned_t bp;     /* mpaddr of boot param area */
385     uint64_aligned_t maxmem; /* Highest memory address for MDT.  */
386     uint64_aligned_t xsi_va; /* Xen shared_info area virtual address.  */
387     uint32_t hypercall_imm;  /* Break imm for Xen hypercalls.  */
388     int8_t vhpt_size_log2;   /* Log2 of VHPT size. */
389 #endif
390 } xen_domctl_arch_setup_t;
391 DEFINE_XEN_GUEST_HANDLE(xen_domctl_arch_setup_t);
392 
393 
394 #define XEN_DOMCTL_settimeoffset     24
395 struct xen_domctl_settimeoffset {
396     int32_t  time_offset_seconds; /* applied to domain wallclock time */
397 };
398 typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t;
399 DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t);
400 
401 
402 #define XEN_DOMCTL_gethvmcontext     33
403 #define XEN_DOMCTL_sethvmcontext     34
404 typedef struct xen_domctl_hvmcontext {
405     uint32_t size; /* IN/OUT: size of buffer / bytes filled */
406     XEN_GUEST_HANDLE_64(uint8) buffer; /* IN/OUT: data, or call
407                                         * gethvmcontext with NULL
408                                         * buffer to get size req'd */
409 } xen_domctl_hvmcontext_t;
410 DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t);
411 
412 
413 #define XEN_DOMCTL_set_address_size  35
414 #define XEN_DOMCTL_get_address_size  36
415 typedef struct xen_domctl_address_size {
416     uint32_t size;
417 } xen_domctl_address_size_t;
418 DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
419 
420 
421 #define XEN_DOMCTL_real_mode_area    26
422 struct xen_domctl_real_mode_area {
423     uint32_t log; /* log2 of Real Mode Area size */
424 };
425 typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
426 DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
427 
428 
429 #define XEN_DOMCTL_sendtrigger       28
430 #define XEN_DOMCTL_SENDTRIGGER_NMI    0
431 #define XEN_DOMCTL_SENDTRIGGER_RESET  1
432 #define XEN_DOMCTL_SENDTRIGGER_INIT   2
433 #define XEN_DOMCTL_SENDTRIGGER_POWER  3
434 struct xen_domctl_sendtrigger {
435     uint32_t  trigger;  /* IN */
436     uint32_t  vcpu;     /* IN */
437 };
438 typedef struct xen_domctl_sendtrigger xen_domctl_sendtrigger_t;
439 DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendtrigger_t);
440 
441 
442 /* Assign PCI device to HVM guest. Sets up IOMMU structures. */
443 #define XEN_DOMCTL_assign_device      37
444 #define XEN_DOMCTL_test_assign_device 45
445 #define XEN_DOMCTL_deassign_device 47
446 struct xen_domctl_assign_device {
447     uint32_t  machine_bdf;   /* machine PCI ID of assigned device */
448 };
449 typedef struct xen_domctl_assign_device xen_domctl_assign_device_t;
450 DEFINE_XEN_GUEST_HANDLE(xen_domctl_assign_device_t);
451 
452 /* Retrieve sibling devices infomation of machine_bdf */
453 #define XEN_DOMCTL_get_device_group 50
454 struct xen_domctl_get_device_group {
455     uint32_t  machine_bdf;      /* IN */
456     uint32_t  max_sdevs;        /* IN */
457     uint32_t  num_sdevs;        /* OUT */
458     XEN_GUEST_HANDLE_64(uint32)  sdev_array;   /* OUT */
459 };
460 typedef struct xen_domctl_get_device_group xen_domctl_get_device_group_t;
461 DEFINE_XEN_GUEST_HANDLE(xen_domctl_get_device_group_t);
462 
463 /* Pass-through interrupts: bind real irq -> hvm devfn. */
464 #define XEN_DOMCTL_bind_pt_irq       38
465 #define XEN_DOMCTL_unbind_pt_irq     48
466 typedef enum pt_irq_type_e {
467     PT_IRQ_TYPE_PCI,
468     PT_IRQ_TYPE_ISA,
469     PT_IRQ_TYPE_MSI,
470     PT_IRQ_TYPE_MSI_TRANSLATE,
471 } pt_irq_type_t;
472 struct xen_domctl_bind_pt_irq {
473     uint32_t machine_irq;
474     pt_irq_type_t irq_type;
475     uint32_t hvm_domid;
476 
477     union {
478         struct {
479             uint8_t isa_irq;
480         } isa;
481         struct {
482             uint8_t bus;
483             uint8_t device;
484             uint8_t intx;
485         } pci;
486         struct {
487             uint8_t gvec;
488             uint32_t gflags;
489             uint64_aligned_t gtable;
490         } msi;
491     } u;
492 };
493 typedef struct xen_domctl_bind_pt_irq xen_domctl_bind_pt_irq_t;
494 DEFINE_XEN_GUEST_HANDLE(xen_domctl_bind_pt_irq_t);
495 
496 
497 /* Bind machine I/O address range -> HVM address range. */
498 #define XEN_DOMCTL_memory_mapping    39
499 #define DPCI_ADD_MAPPING         1
500 #define DPCI_REMOVE_MAPPING      0
501 struct xen_domctl_memory_mapping {
502     uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in range */
503     uint64_aligned_t first_mfn; /* first page (machine page) in range */
504     uint64_aligned_t nr_mfns;   /* number of pages in range (>0) */
505     uint32_t add_mapping;       /* add or remove mapping */
506     uint32_t padding;           /* padding for 64-bit aligned structure */
507 };
508 typedef struct xen_domctl_memory_mapping xen_domctl_memory_mapping_t;
509 DEFINE_XEN_GUEST_HANDLE(xen_domctl_memory_mapping_t);
510 
511 
512 /* Bind machine I/O port range -> HVM I/O port range. */
513 #define XEN_DOMCTL_ioport_mapping    40
514 struct xen_domctl_ioport_mapping {
515     uint32_t first_gport;     /* first guest IO port*/
516     uint32_t first_mport;     /* first machine IO port */
517     uint32_t nr_ports;        /* size of port range */
518     uint32_t add_mapping;     /* add or remove mapping */
519 };
520 typedef struct xen_domctl_ioport_mapping xen_domctl_ioport_mapping_t;
521 DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_mapping_t);
522 
523 
524 /*
525  * Pin caching type of RAM space for x86 HVM domU.
526  */
527 #define XEN_DOMCTL_pin_mem_cacheattr 41
528 /* Caching types: these happen to be the same as x86 MTRR/PAT type codes. */
529 #define XEN_DOMCTL_MEM_CACHEATTR_UC  0
530 #define XEN_DOMCTL_MEM_CACHEATTR_WC  1
531 #define XEN_DOMCTL_MEM_CACHEATTR_WT  4
532 #define XEN_DOMCTL_MEM_CACHEATTR_WP  5
533 #define XEN_DOMCTL_MEM_CACHEATTR_WB  6
534 #define XEN_DOMCTL_MEM_CACHEATTR_UCM 7
535 struct xen_domctl_pin_mem_cacheattr {
536     uint64_aligned_t start, end;
537     unsigned int type; /* XEN_DOMCTL_MEM_CACHEATTR_* */
538 };
539 typedef struct xen_domctl_pin_mem_cacheattr xen_domctl_pin_mem_cacheattr_t;
540 DEFINE_XEN_GUEST_HANDLE(xen_domctl_pin_mem_cacheattr_t);
541 
542 
543 #define XEN_DOMCTL_set_ext_vcpucontext 42
544 #define XEN_DOMCTL_get_ext_vcpucontext 43
545 struct xen_domctl_ext_vcpucontext {
546     /* IN: VCPU that this call applies to. */
547     uint32_t         vcpu;
548     /*
549      * SET: Size of struct (IN)
550      * GET: Size of struct (OUT)
551      */
552     uint32_t         size;
553 #if defined(__i386__) || defined(__x86_64__)
554     /* SYSCALL from 32-bit mode and SYSENTER callback information. */
555     /* NB. SYSCALL from 64-bit mode is contained in vcpu_guest_context_t */
556     uint64_aligned_t syscall32_callback_eip;
557     uint64_aligned_t sysenter_callback_eip;
558     uint16_t         syscall32_callback_cs;
559     uint16_t         sysenter_callback_cs;
560     uint8_t          syscall32_disables_events;
561     uint8_t          sysenter_disables_events;
562 #endif
563 };
564 typedef struct xen_domctl_ext_vcpucontext xen_domctl_ext_vcpucontext_t;
565 DEFINE_XEN_GUEST_HANDLE(xen_domctl_ext_vcpucontext_t);
566 
567 /*
568  * Set optimizaton features for a domain
569  */
570 #define XEN_DOMCTL_set_opt_feature    44
571 struct xen_domctl_set_opt_feature {
572 #if defined(__ia64__)
573     struct xen_ia64_opt_feature optf;
574 #else
575     /* Make struct non-empty: do not depend on this field name! */
576     uint64_t dummy;
577 #endif
578 };
579 typedef struct xen_domctl_set_opt_feature xen_domctl_set_opt_feature_t;
580 DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_opt_feature_t);
581 
582 /*
583  * Set the target domain for a domain
584  */
585 #define XEN_DOMCTL_set_target    46
586 struct xen_domctl_set_target {
587     domid_t target;
588 };
589 typedef struct xen_domctl_set_target xen_domctl_set_target_t;
590 DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_target_t);
591 
592 #if defined(__i386__) || defined(__x86_64__)
593 # define XEN_CPUID_INPUT_UNUSED  0xFFFFFFFF
594 # define XEN_DOMCTL_set_cpuid 49
595 struct xen_domctl_cpuid {
596   unsigned int  input[2];
597   unsigned int  eax;
598   unsigned int  ebx;
599   unsigned int  ecx;
600   unsigned int  edx;
601 };
602 typedef struct xen_domctl_cpuid xen_domctl_cpuid_t;
603 DEFINE_XEN_GUEST_HANDLE(xen_domctl_cpuid_t);
604 #endif
605 
606 #define XEN_DOMCTL_subscribe          29
607 struct xen_domctl_subscribe {
608     uint32_t port; /* IN */
609 };
610 typedef struct xen_domctl_subscribe xen_domctl_subscribe_t;
611 DEFINE_XEN_GUEST_HANDLE(xen_domctl_subscribe_t);
612 
613 /*
614  * Define the maximum machine address size which should be allocated
615  * to a guest.
616  */
617 #define XEN_DOMCTL_set_machine_address_size  51
618 #define XEN_DOMCTL_get_machine_address_size  52
619 
620 /*
621  * Do not inject spurious page faults into this domain.
622  */
623 #define XEN_DOMCTL_suppress_spurious_page_faults 53
624 
625 #define XEN_DOMCTL_debug_op    54
626 #define XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF         0
627 #define XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON          1
628 struct xen_domctl_debug_op {
629     uint32_t op;   /* IN */
630     uint32_t vcpu; /* IN */
631 };
632 typedef struct xen_domctl_debug_op xen_domctl_debug_op_t;
633 DEFINE_XEN_GUEST_HANDLE(xen_domctl_debug_op_t);
634 
635 /*
636  * Request a particular record from the HVM context
637  */
638 #define XEN_DOMCTL_gethvmcontext_partial   55
639 typedef struct xen_domctl_hvmcontext_partial {
640     uint32_t type;                      /* IN: Type of record required */
641     uint32_t instance;                  /* IN: Instance of that type */
642     XEN_GUEST_HANDLE_64(uint8) buffer;  /* OUT: buffer to write record into */
643 } xen_domctl_hvmcontext_partial_t;
644 DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_partial_t);
645 
646 
647 struct xen_domctl {
648     uint32_t cmd;
649     uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
650     domid_t  domain;
651     union {
652         struct xen_domctl_createdomain      createdomain;
653         struct xen_domctl_getdomaininfo     getdomaininfo;
654         struct xen_domctl_getmemlist        getmemlist;
655         struct xen_domctl_getpageframeinfo  getpageframeinfo;
656         struct xen_domctl_getpageframeinfo2 getpageframeinfo2;
657         struct xen_domctl_vcpuaffinity      vcpuaffinity;
658         struct xen_domctl_shadow_op         shadow_op;
659         struct xen_domctl_max_mem           max_mem;
660         struct xen_domctl_vcpucontext       vcpucontext;
661         struct xen_domctl_getvcpuinfo       getvcpuinfo;
662         struct xen_domctl_max_vcpus         max_vcpus;
663         struct xen_domctl_scheduler_op      scheduler_op;
664         struct xen_domctl_setdomainhandle   setdomainhandle;
665         struct xen_domctl_setdebugging      setdebugging;
666         struct xen_domctl_irq_permission    irq_permission;
667         struct xen_domctl_iomem_permission  iomem_permission;
668         struct xen_domctl_ioport_permission ioport_permission;
669         struct xen_domctl_hypercall_init    hypercall_init;
670         struct xen_domctl_arch_setup        arch_setup;
671         struct xen_domctl_settimeoffset     settimeoffset;
672         struct xen_domctl_real_mode_area    real_mode_area;
673         struct xen_domctl_hvmcontext        hvmcontext;
674         struct xen_domctl_hvmcontext_partial hvmcontext_partial;
675         struct xen_domctl_address_size      address_size;
676         struct xen_domctl_sendtrigger       sendtrigger;
677         struct xen_domctl_get_device_group  get_device_group;
678         struct xen_domctl_assign_device     assign_device;
679         struct xen_domctl_bind_pt_irq       bind_pt_irq;
680         struct xen_domctl_memory_mapping    memory_mapping;
681         struct xen_domctl_ioport_mapping    ioport_mapping;
682         struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
683         struct xen_domctl_ext_vcpucontext   ext_vcpucontext;
684         struct xen_domctl_set_opt_feature   set_opt_feature;
685         struct xen_domctl_set_target        set_target;
686         struct xen_domctl_subscribe         subscribe;
687         struct xen_domctl_debug_op          debug_op;
688 #if defined(__i386__) || defined(__x86_64__)
689         struct xen_domctl_cpuid             cpuid;
690 #endif
691         uint8_t                             pad[128];
692     } u;
693 };
694 typedef struct xen_domctl xen_domctl_t;
695 DEFINE_XEN_GUEST_HANDLE(xen_domctl_t);
696 
697 #endif /* __XEN_PUBLIC_DOMCTL_H__ */
698 
699 /*
700  * Local variables:
701  * mode: C
702  * c-set-style: "BSD"
703  * c-basic-offset: 4
704  * tab-width: 4
705  * indent-tabs-mode: nil
706  * End:
707  */
708