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 #include "event_channel.h"
37 #include "grant_table.h"
38 #include "hvm/save.h"
39 #include "memory.h"
40 
41 #define XEN_DOMCTL_INTERFACE_VERSION 0x00000012
42 
43 /*
44  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
45  * If it is specified as an invalid value (0 or >= DOMID_FIRST_RESERVED),
46  * an id is auto-allocated and returned.
47  */
48 /* XEN_DOMCTL_createdomain */
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           0
55 #define XEN_DOMCTL_CDF_hvm            (1U<<_XEN_DOMCTL_CDF_hvm)
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  /* Disable out-of-sync shadow page tables? */
63 #define _XEN_DOMCTL_CDF_oos_off       3
64 #define XEN_DOMCTL_CDF_oos_off        (1U<<_XEN_DOMCTL_CDF_oos_off)
65  /* Is this a xenstore domain? */
66 #define _XEN_DOMCTL_CDF_xs_domain     4
67 #define XEN_DOMCTL_CDF_xs_domain      (1U<<_XEN_DOMCTL_CDF_xs_domain)
68  /* Should this domain be permitted to use the IOMMU? */
69 #define _XEN_DOMCTL_CDF_iommu         5
70 #define XEN_DOMCTL_CDF_iommu          (1U<<_XEN_DOMCTL_CDF_iommu)
71 
72 /* Max XEN_DOMCTL_CDF_* constant.  Used for ABI checking. */
73 #define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_iommu
74 
75     uint32_t flags;
76 
77 #define _XEN_DOMCTL_IOMMU_no_sharept  0
78 #define XEN_DOMCTL_IOMMU_no_sharept   (1U << _XEN_DOMCTL_IOMMU_no_sharept)
79 
80 /* Max XEN_DOMCTL_IOMMU_* constant.  Used for ABI checking. */
81 #define XEN_DOMCTL_IOMMU_MAX XEN_DOMCTL_IOMMU_no_sharept
82 
83     uint32_t iommu_opts;
84 
85     /*
86      * Various domain limits, which impact the quantity of resources
87      * (global mapping space, xenheap, etc) a guest may consume.  For
88      * max_grant_frames and max_maptrack_frames, < 0 means "use the
89      * default maximum value in the hypervisor".
90      */
91     uint32_t max_vcpus;
92     uint32_t max_evtchn_port;
93     int32_t max_grant_frames;
94     int32_t max_maptrack_frames;
95 
96     struct xen_arch_domainconfig arch;
97 };
98 
99 /* XEN_DOMCTL_getdomaininfo */
100 struct xen_domctl_getdomaininfo {
101     /* OUT variables. */
102     domid_t  domain;              /* Also echoed in domctl.domain */
103  /* Domain is scheduled to die. */
104 #define _XEN_DOMINF_dying     0
105 #define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
106  /* Domain is an HVM guest (as opposed to a PV guest). */
107 #define _XEN_DOMINF_hvm_guest 1
108 #define XEN_DOMINF_hvm_guest  (1U<<_XEN_DOMINF_hvm_guest)
109  /* The guest OS has shut down. */
110 #define _XEN_DOMINF_shutdown  2
111 #define XEN_DOMINF_shutdown   (1U<<_XEN_DOMINF_shutdown)
112  /* Currently paused by control software. */
113 #define _XEN_DOMINF_paused    3
114 #define XEN_DOMINF_paused     (1U<<_XEN_DOMINF_paused)
115  /* Currently blocked pending an event.     */
116 #define _XEN_DOMINF_blocked   4
117 #define XEN_DOMINF_blocked    (1U<<_XEN_DOMINF_blocked)
118  /* Domain is currently running.            */
119 #define _XEN_DOMINF_running   5
120 #define XEN_DOMINF_running    (1U<<_XEN_DOMINF_running)
121  /* Being debugged.  */
122 #define _XEN_DOMINF_debugged  6
123 #define XEN_DOMINF_debugged   (1U<<_XEN_DOMINF_debugged)
124 /* domain is a xenstore domain */
125 #define _XEN_DOMINF_xs_domain 7
126 #define XEN_DOMINF_xs_domain  (1U<<_XEN_DOMINF_xs_domain)
127 /* domain has hardware assisted paging */
128 #define _XEN_DOMINF_hap       8
129 #define XEN_DOMINF_hap        (1U<<_XEN_DOMINF_hap)
130  /* XEN_DOMINF_shutdown guest-supplied code.  */
131 #define XEN_DOMINF_shutdownmask 255
132 #define XEN_DOMINF_shutdownshift 16
133     uint32_t flags;              /* XEN_DOMINF_* */
134     uint64_aligned_t tot_pages;
135     uint64_aligned_t max_pages;
136     uint64_aligned_t outstanding_pages;
137     uint64_aligned_t shr_pages;
138     uint64_aligned_t paged_pages;
139     uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */
140     uint64_aligned_t cpu_time;
141     uint32_t nr_online_vcpus;    /* Number of VCPUs currently online. */
142 #define XEN_INVALID_MAX_VCPU_ID (~0U) /* Domain has no vcpus? */
143     uint32_t max_vcpu_id;        /* Maximum VCPUID in use by this domain. */
144     uint32_t ssidref;
145     xen_domain_handle_t handle;
146     uint32_t cpupool;
147     struct xen_arch_domainconfig arch_config;
148 };
149 typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
150 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t);
151 
152 
153 /* XEN_DOMCTL_getpageframeinfo */
154 
155 #define XEN_DOMCTL_PFINFO_LTAB_SHIFT 28
156 #define XEN_DOMCTL_PFINFO_NOTAB   (0x0U<<28)
157 #define XEN_DOMCTL_PFINFO_L1TAB   (0x1U<<28)
158 #define XEN_DOMCTL_PFINFO_L2TAB   (0x2U<<28)
159 #define XEN_DOMCTL_PFINFO_L3TAB   (0x3U<<28)
160 #define XEN_DOMCTL_PFINFO_L4TAB   (0x4U<<28)
161 #define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7U<<28)
162 #define XEN_DOMCTL_PFINFO_LPINTAB (0x1U<<31)
163 #define XEN_DOMCTL_PFINFO_XTAB    (0xfU<<28) /* invalid page */
164 #define XEN_DOMCTL_PFINFO_XALLOC  (0xeU<<28) /* allocate-only page */
165 #define XEN_DOMCTL_PFINFO_BROKEN  (0xdU<<28) /* broken page */
166 #define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28)
167 
168 /* XEN_DOMCTL_getpageframeinfo3 */
169 /*
170  * Both value `num' and `array' may get modified by the hypercall to allow
171  * preemption.
172  */
173 struct xen_domctl_getpageframeinfo3 {
174     /* IN variables. */
175     uint64_aligned_t num;
176     /* IN/OUT variables. */
177     XEN_GUEST_HANDLE_64(xen_pfn_t) array;
178 };
179 
180 
181 /*
182  * Control shadow pagetables operation
183  */
184 /* XEN_DOMCTL_shadow_op */
185 
186 /* Disable shadow mode. */
187 #define XEN_DOMCTL_SHADOW_OP_OFF         0
188 
189 /* Enable shadow mode (mode contains ORed XEN_DOMCTL_SHADOW_ENABLE_* flags). */
190 #define XEN_DOMCTL_SHADOW_OP_ENABLE      32
191 
192 /* Log-dirty bitmap operations. */
193  /* Return the bitmap and clean internal copy for next round. */
194 #define XEN_DOMCTL_SHADOW_OP_CLEAN       11
195  /* Return the bitmap but do not modify internal copy. */
196 #define XEN_DOMCTL_SHADOW_OP_PEEK        12
197 
198 /* Memory allocation accessors. */
199 #define XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
200 #define XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
201 
202 /* Legacy enable operations. */
203  /* Equiv. to ENABLE with no mode flags. */
204 #define XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
205  /* Equiv. to ENABLE with mode flag ENABLE_LOG_DIRTY. */
206 #define XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
207  /*
208   * No longer supported, was equiv. to ENABLE with mode flags
209   * ENABLE_REFCOUNT and ENABLE_TRANSLATE:
210 #define XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
211   */
212 
213 /* Mode flags for XEN_DOMCTL_SHADOW_OP_ENABLE. */
214  /*
215   * Shadow pagetables are refcounted: guest does not use explicit mmu
216   * operations nor write-protect its pagetables.
217   */
218 #define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
219  /*
220   * Log pages in a bitmap as they are dirtied.
221   * Used for live relocation to determine which pages must be re-sent.
222   */
223 #define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
224  /*
225   * Automatically translate GPFNs into MFNs.
226   */
227 #define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
228  /*
229   * Xen does not steal virtual address space from the guest.
230   * Requires HVM support.
231   */
232 #define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
233 
234 /* Mode flags for XEN_DOMCTL_SHADOW_OP_{CLEAN,PEEK}. */
235  /*
236   * This is the final iteration: Requesting to include pages mapped
237   * writably by the hypervisor in the dirty bitmap.
238   */
239 #define XEN_DOMCTL_SHADOW_LOGDIRTY_FINAL   (1 << 0)
240 
241 struct xen_domctl_shadow_op_stats {
242     uint32_t fault_count;
243     uint32_t dirty_count;
244 };
245 
246 struct xen_domctl_shadow_op {
247     /* IN variables. */
248     uint32_t       op;       /* XEN_DOMCTL_SHADOW_OP_* */
249 
250     /* OP_ENABLE: XEN_DOMCTL_SHADOW_ENABLE_* */
251     /* OP_PEAK / OP_CLEAN: XEN_DOMCTL_SHADOW_LOGDIRTY_* */
252     uint32_t       mode;
253 
254     /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */
255     uint32_t       mb;       /* Shadow memory allocation in MB */
256 
257     /* OP_PEEK / OP_CLEAN */
258     XEN_GUEST_HANDLE_64(uint8) dirty_bitmap;
259     uint64_aligned_t pages; /* Size of buffer. Updated with actual size. */
260     struct xen_domctl_shadow_op_stats stats;
261 };
262 
263 
264 /* XEN_DOMCTL_max_mem */
265 struct xen_domctl_max_mem {
266     /* IN variables. */
267     uint64_aligned_t max_memkb;
268 };
269 
270 
271 /* XEN_DOMCTL_setvcpucontext */
272 /* XEN_DOMCTL_getvcpucontext */
273 struct xen_domctl_vcpucontext {
274     uint32_t              vcpu;                  /* IN */
275     XEN_GUEST_HANDLE_64(vcpu_guest_context_t) ctxt; /* IN/OUT */
276 };
277 
278 
279 /* XEN_DOMCTL_getvcpuinfo */
280 struct xen_domctl_getvcpuinfo {
281     /* IN variables. */
282     uint32_t vcpu;
283     /* OUT variables. */
284     uint8_t  online;                  /* currently online (not hotplugged)? */
285     uint8_t  blocked;                 /* blocked waiting for an event? */
286     uint8_t  running;                 /* currently scheduled on its CPU? */
287     uint64_aligned_t cpu_time;        /* total cpu time consumed (ns) */
288     uint32_t cpu;                     /* current mapping   */
289 };
290 
291 
292 /* Get/set the NUMA node(s) with which the guest has affinity with. */
293 /* XEN_DOMCTL_setnodeaffinity */
294 /* XEN_DOMCTL_getnodeaffinity */
295 struct xen_domctl_nodeaffinity {
296     struct xenctl_bitmap nodemap;/* IN */
297 };
298 
299 
300 /* Get/set which physical cpus a vcpu can execute on. */
301 /* XEN_DOMCTL_setvcpuaffinity */
302 /* XEN_DOMCTL_getvcpuaffinity */
303 struct xen_domctl_vcpuaffinity {
304     /* IN variables. */
305     uint32_t  vcpu;
306  /* Set/get the hard affinity for vcpu */
307 #define _XEN_VCPUAFFINITY_HARD  0
308 #define XEN_VCPUAFFINITY_HARD   (1U<<_XEN_VCPUAFFINITY_HARD)
309  /* Set/get the soft affinity for vcpu */
310 #define _XEN_VCPUAFFINITY_SOFT  1
311 #define XEN_VCPUAFFINITY_SOFT   (1U<<_XEN_VCPUAFFINITY_SOFT)
312  /* Undo SCHEDOP_pin_override */
313 #define _XEN_VCPUAFFINITY_FORCE 2
314 #define XEN_VCPUAFFINITY_FORCE  (1U<<_XEN_VCPUAFFINITY_FORCE)
315     uint32_t flags;
316     /*
317      * IN/OUT variables.
318      *
319      * Both are IN/OUT for XEN_DOMCTL_setvcpuaffinity, in which case they
320      * contain effective hard or/and soft affinity. That is, upon successful
321      * return, cpumap_soft, contains the intersection of the soft affinity,
322      * hard affinity and the cpupool's online CPUs for the domain (if
323      * XEN_VCPUAFFINITY_SOFT was set in flags). cpumap_hard contains the
324      * intersection between hard affinity and the cpupool's online CPUs (if
325      * XEN_VCPUAFFINITY_HARD was set in flags).
326      *
327      * Both are OUT-only for XEN_DOMCTL_getvcpuaffinity, in which case they
328      * contain the plain hard and/or soft affinity masks that were set during
329      * previous successful calls to XEN_DOMCTL_setvcpuaffinity (or the
330      * default values), without intersecting or altering them in any way.
331      */
332     struct xenctl_bitmap cpumap_hard;
333     struct xenctl_bitmap cpumap_soft;
334 };
335 
336 
337 /*
338  * XEN_DOMCTL_max_vcpus:
339  *
340  * The parameter passed to XEN_DOMCTL_max_vcpus must match the value passed to
341  * XEN_DOMCTL_createdomain.  This hypercall is in the process of being removed
342  * (once the failure paths in domain_create() have been improved), but is
343  * still required in the short term to allocate the vcpus themselves.
344  */
345 struct xen_domctl_max_vcpus {
346     uint32_t max;           /* maximum number of vcpus */
347 };
348 
349 
350 /* XEN_DOMCTL_scheduler_op */
351 /* Scheduler types. */
352 /* #define XEN_SCHEDULER_SEDF  4 (Removed) */
353 #define XEN_SCHEDULER_CREDIT   5
354 #define XEN_SCHEDULER_CREDIT2  6
355 #define XEN_SCHEDULER_ARINC653 7
356 #define XEN_SCHEDULER_RTDS     8
357 #define XEN_SCHEDULER_NULL     9
358 
359 struct xen_domctl_sched_credit {
360     uint16_t weight;
361     uint16_t cap;
362 };
363 
364 struct xen_domctl_sched_credit2 {
365     uint16_t weight;
366     uint16_t cap;
367 };
368 
369 struct xen_domctl_sched_rtds {
370     uint32_t period;
371     uint32_t budget;
372 /* Can this vCPU execute beyond its reserved amount of time? */
373 #define _XEN_DOMCTL_SCHEDRT_extra   0
374 #define XEN_DOMCTL_SCHEDRT_extra    (1U<<_XEN_DOMCTL_SCHEDRT_extra)
375     uint32_t flags;
376 };
377 
378 typedef struct xen_domctl_schedparam_vcpu {
379     union {
380         struct xen_domctl_sched_credit credit;
381         struct xen_domctl_sched_credit2 credit2;
382         struct xen_domctl_sched_rtds rtds;
383     } u;
384     uint32_t vcpuid;
385 } xen_domctl_schedparam_vcpu_t;
386 DEFINE_XEN_GUEST_HANDLE(xen_domctl_schedparam_vcpu_t);
387 
388 /*
389  * Set or get info?
390  * For schedulers supporting per-vcpu settings (e.g., RTDS):
391  *  XEN_DOMCTL_SCHEDOP_putinfo sets params for all vcpus;
392  *  XEN_DOMCTL_SCHEDOP_getinfo gets default params;
393  *  XEN_DOMCTL_SCHEDOP_put(get)vcpuinfo sets (gets) params of vcpus;
394  *
395  * For schedulers not supporting per-vcpu settings:
396  *  XEN_DOMCTL_SCHEDOP_putinfo sets params for all vcpus;
397  *  XEN_DOMCTL_SCHEDOP_getinfo gets domain-wise params;
398  *  XEN_DOMCTL_SCHEDOP_put(get)vcpuinfo returns error;
399  */
400 #define XEN_DOMCTL_SCHEDOP_putinfo 0
401 #define XEN_DOMCTL_SCHEDOP_getinfo 1
402 #define XEN_DOMCTL_SCHEDOP_putvcpuinfo 2
403 #define XEN_DOMCTL_SCHEDOP_getvcpuinfo 3
404 struct xen_domctl_scheduler_op {
405     uint32_t sched_id;  /* XEN_SCHEDULER_* */
406     uint32_t cmd;       /* XEN_DOMCTL_SCHEDOP_* */
407     /* IN/OUT */
408     union {
409         struct xen_domctl_sched_credit credit;
410         struct xen_domctl_sched_credit2 credit2;
411         struct xen_domctl_sched_rtds rtds;
412         struct {
413             XEN_GUEST_HANDLE_64(xen_domctl_schedparam_vcpu_t) vcpus;
414             /*
415              * IN: Number of elements in vcpus array.
416              * OUT: Number of processed elements of vcpus array.
417              */
418             uint32_t nr_vcpus;
419             uint32_t padding;
420         } v;
421     } u;
422 };
423 
424 
425 /* XEN_DOMCTL_setdomainhandle */
426 struct xen_domctl_setdomainhandle {
427     xen_domain_handle_t handle;
428 };
429 
430 
431 /* XEN_DOMCTL_setdebugging */
432 struct xen_domctl_setdebugging {
433     uint8_t enable;
434 };
435 
436 
437 /* XEN_DOMCTL_irq_permission */
438 struct xen_domctl_irq_permission {
439     uint8_t pirq;
440     uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
441 };
442 
443 
444 /* XEN_DOMCTL_iomem_permission */
445 struct xen_domctl_iomem_permission {
446     uint64_aligned_t first_mfn;/* first page (physical page number) in range */
447     uint64_aligned_t nr_mfns;  /* number of pages in range (>0) */
448     uint8_t  allow_access;     /* allow (!0) or deny (0) access to range? */
449 };
450 
451 
452 /* XEN_DOMCTL_ioport_permission */
453 struct xen_domctl_ioport_permission {
454     uint32_t first_port;              /* first port int range */
455     uint32_t nr_ports;                /* size of port range */
456     uint8_t  allow_access;            /* allow or deny access to range? */
457 };
458 
459 
460 /* XEN_DOMCTL_hypercall_init */
461 struct xen_domctl_hypercall_init {
462     uint64_aligned_t  gmfn;           /* GMFN to be initialised */
463 };
464 
465 
466 /* XEN_DOMCTL_settimeoffset */
467 struct xen_domctl_settimeoffset {
468     int64_aligned_t time_offset_seconds; /* applied to domain wallclock time */
469 };
470 
471 /* XEN_DOMCTL_gethvmcontext */
472 /* XEN_DOMCTL_sethvmcontext */
473 struct xen_domctl_hvmcontext {
474     uint32_t size; /* IN/OUT: size of buffer / bytes filled */
475     XEN_GUEST_HANDLE_64(uint8) buffer; /* IN/OUT: data, or call
476                                         * gethvmcontext with NULL
477                                         * buffer to get size req'd */
478 };
479 
480 
481 /* XEN_DOMCTL_set_address_size */
482 /* XEN_DOMCTL_get_address_size */
483 struct xen_domctl_address_size {
484     uint32_t size;
485 };
486 
487 
488 /* XEN_DOMCTL_sendtrigger */
489 #define XEN_DOMCTL_SENDTRIGGER_NMI    0
490 #define XEN_DOMCTL_SENDTRIGGER_RESET  1
491 #define XEN_DOMCTL_SENDTRIGGER_INIT   2
492 #define XEN_DOMCTL_SENDTRIGGER_POWER  3
493 #define XEN_DOMCTL_SENDTRIGGER_SLEEP  4
494 struct xen_domctl_sendtrigger {
495     uint32_t  trigger;  /* IN */
496     uint32_t  vcpu;     /* IN */
497 };
498 
499 
500 /* Assign a device to a guest. Sets up IOMMU structures. */
501 /* XEN_DOMCTL_assign_device */
502 /*
503  * XEN_DOMCTL_test_assign_device: Pass DOMID_INVALID to find out whether the
504  * given device is assigned to any DomU at all. Pass a specific domain ID to
505  * find out whether the given device can be assigned to that domain.
506  */
507 /*
508  * XEN_DOMCTL_deassign_device: The behavior of this DOMCTL differs
509  * between the different type of device:
510  *  - PCI device (XEN_DOMCTL_DEV_PCI) will be reassigned to DOM0
511  *  - DT device (XEN_DOMCTL_DEV_DT) will left unassigned. DOM0
512  *  will have to call XEN_DOMCTL_assign_device in order to use the
513  *  device.
514  */
515 #define XEN_DOMCTL_DEV_PCI      0
516 #define XEN_DOMCTL_DEV_DT       1
517 struct xen_domctl_assign_device {
518     /* IN */
519     uint32_t dev;   /* XEN_DOMCTL_DEV_* */
520     uint32_t flags;
521 #define XEN_DOMCTL_DEV_RDM_RELAXED      1 /* assign only */
522     union {
523         struct {
524             uint32_t machine_sbdf;   /* machine PCI ID of assigned device */
525         } pci;
526         struct {
527             uint32_t size; /* Length of the path */
528             XEN_GUEST_HANDLE_64(char) path; /* path to the device tree node */
529         } dt;
530     } u;
531 };
532 
533 /* Retrieve sibling devices information of machine_sbdf */
534 /* XEN_DOMCTL_get_device_group */
535 struct xen_domctl_get_device_group {
536     uint32_t  machine_sbdf;     /* IN */
537     uint32_t  max_sdevs;        /* IN */
538     uint32_t  num_sdevs;        /* OUT */
539     XEN_GUEST_HANDLE_64(uint32)  sdev_array;   /* OUT */
540 };
541 
542 /* Pass-through interrupts: bind real irq -> hvm devfn. */
543 /* XEN_DOMCTL_bind_pt_irq */
544 /* XEN_DOMCTL_unbind_pt_irq */
545 enum pt_irq_type {
546     PT_IRQ_TYPE_PCI,
547     PT_IRQ_TYPE_ISA,
548     PT_IRQ_TYPE_MSI,
549     PT_IRQ_TYPE_MSI_TRANSLATE,
550     PT_IRQ_TYPE_SPI,    /* ARM: valid range 32-1019 */
551 };
552 struct xen_domctl_bind_pt_irq {
553     uint32_t machine_irq;
554     uint32_t irq_type; /* enum pt_irq_type */
555 
556     union {
557         struct {
558             uint8_t isa_irq;
559         } isa;
560         struct {
561             uint8_t bus;
562             uint8_t device;
563             uint8_t intx;
564         } pci;
565         struct {
566             uint8_t gvec;
567             uint32_t gflags;
568 #define XEN_DOMCTL_VMSI_X86_DEST_ID_MASK 0x0000ff
569 #define XEN_DOMCTL_VMSI_X86_RH_MASK      0x000100
570 #define XEN_DOMCTL_VMSI_X86_DM_MASK      0x000200
571 #define XEN_DOMCTL_VMSI_X86_DELIV_MASK   0x007000
572 #define XEN_DOMCTL_VMSI_X86_TRIG_MASK    0x008000
573 #define XEN_DOMCTL_VMSI_X86_UNMASKED     0x010000
574 
575             uint64_aligned_t gtable;
576         } msi;
577         struct {
578             uint16_t spi;
579         } spi;
580     } u;
581 };
582 
583 
584 /* Bind machine I/O address range -> HVM address range. */
585 /* XEN_DOMCTL_memory_mapping */
586 /* Returns
587    - zero     success, everything done
588    - -E2BIG   passed in nr_mfns value too large for the implementation
589    - positive partial success for the first <result> page frames (with
590               <result> less than nr_mfns), requiring re-invocation by the
591               caller after updating inputs
592    - negative error; other than -E2BIG
593 */
594 #define DPCI_ADD_MAPPING         1
595 #define DPCI_REMOVE_MAPPING      0
596 struct xen_domctl_memory_mapping {
597     uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in range */
598     uint64_aligned_t first_mfn; /* first page (machine page) in range */
599     uint64_aligned_t nr_mfns;   /* number of pages in range (>0) */
600     uint32_t add_mapping;       /* add or remove mapping */
601     uint32_t padding;           /* padding for 64-bit aligned structure */
602 };
603 
604 
605 /* Bind machine I/O port range -> HVM I/O port range. */
606 /* XEN_DOMCTL_ioport_mapping */
607 struct xen_domctl_ioport_mapping {
608     uint32_t first_gport;     /* first guest IO port*/
609     uint32_t first_mport;     /* first machine IO port */
610     uint32_t nr_ports;        /* size of port range */
611     uint32_t add_mapping;     /* add or remove mapping */
612 };
613 
614 
615 /*
616  * Pin caching type of RAM space for x86 HVM domU.
617  */
618 /* XEN_DOMCTL_pin_mem_cacheattr */
619 /* Caching types: these happen to be the same as x86 MTRR/PAT type codes. */
620 #define XEN_DOMCTL_MEM_CACHEATTR_UC  0
621 #define XEN_DOMCTL_MEM_CACHEATTR_WC  1
622 #define XEN_DOMCTL_MEM_CACHEATTR_WT  4
623 #define XEN_DOMCTL_MEM_CACHEATTR_WP  5
624 #define XEN_DOMCTL_MEM_CACHEATTR_WB  6
625 #define XEN_DOMCTL_MEM_CACHEATTR_UCM 7
626 #define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)
627 
628 
629 /* XEN_DOMCTL_set_ext_vcpucontext */
630 /* XEN_DOMCTL_get_ext_vcpucontext */
631 struct xen_domctl_ext_vcpucontext {
632     /* IN: VCPU that this call applies to. */
633     uint32_t         vcpu;
634     /*
635      * SET: Size of struct (IN)
636      * GET: Size of struct (OUT, up to 128 bytes)
637      */
638     uint32_t         size;
639 #if defined(__i386__) || defined(__x86_64__)
640     /* SYSCALL from 32-bit mode and SYSENTER callback information. */
641     /* NB. SYSCALL from 64-bit mode is contained in vcpu_guest_context_t */
642     uint64_aligned_t syscall32_callback_eip;
643     uint64_aligned_t sysenter_callback_eip;
644     uint16_t         syscall32_callback_cs;
645     uint16_t         sysenter_callback_cs;
646     uint8_t          syscall32_disables_events;
647     uint8_t          sysenter_disables_events;
648 #if defined(__GNUC__)
649     union {
650         uint64_aligned_t mcg_cap;
651         struct hvm_vmce_vcpu vmce;
652     };
653 #else
654     struct hvm_vmce_vcpu vmce;
655 #endif
656 #endif
657 };
658 
659 /*
660  * Set the target domain for a domain
661  */
662 /* XEN_DOMCTL_set_target */
663 struct xen_domctl_set_target {
664     domid_t target;
665 };
666 
667 #if defined(__i386__) || defined(__x86_64__)
668 # define XEN_CPUID_INPUT_UNUSED  0xFFFFFFFF
669 
670 /*
671  * XEN_DOMCTL_{get,set}_cpu_policy (x86 specific)
672  *
673  * Query or set the CPUID and MSR policies for a specific domain.
674  */
675 struct xen_domctl_cpu_policy {
676     uint32_t nr_leaves; /* IN/OUT: Number of leaves in/written to
677                          * 'cpuid_policy'. */
678     uint32_t nr_msrs;   /* IN/OUT: Number of MSRs in/written to
679                          * 'msr_policy' */
680     XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_policy; /* IN/OUT */
681     XEN_GUEST_HANDLE_64(xen_msr_entry_t) msr_policy;    /* IN/OUT */
682 
683     /*
684      * OUT, set_policy only.  Written in some (but not all) error cases to
685      * identify the CPUID leaf/subleaf and/or MSR which auditing objects to.
686      */
687     uint32_t err_leaf, err_subleaf, err_msr;
688 };
689 typedef struct xen_domctl_cpu_policy xen_domctl_cpu_policy_t;
690 DEFINE_XEN_GUEST_HANDLE(xen_domctl_cpu_policy_t);
691 #endif
692 
693 /*
694  * Arranges that if the domain suspends (specifically, if it shuts
695  * down with code SHUTDOWN_suspend), this event channel will be
696  * notified.
697  *
698  * This is _instead of_ the usual notification to the global
699  * VIRQ_DOM_EXC.  (In most systems that pirq is owned by xenstored.)
700  *
701  * Only one subscription per domain is possible.  Last subscriber
702  * wins; others are silently displaced.
703  *
704  * NB that contrary to the rather general name, it only applies to
705  * domain shutdown with code suspend.  Shutdown for other reasons
706  * (including crash), and domain death, are notified to VIRQ_DOM_EXC
707  * regardless.
708  */
709 /* XEN_DOMCTL_subscribe */
710 struct xen_domctl_subscribe {
711     uint32_t port; /* IN */
712 };
713 
714 /* XEN_DOMCTL_debug_op */
715 #define XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF         0
716 #define XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON          1
717 struct xen_domctl_debug_op {
718     uint32_t op;   /* IN */
719     uint32_t vcpu; /* IN */
720 };
721 
722 /*
723  * Request a particular record from the HVM context
724  */
725 /* XEN_DOMCTL_gethvmcontext_partial */
726 struct xen_domctl_hvmcontext_partial {
727     uint32_t type;                      /* IN: Type of record required */
728     uint32_t instance;                  /* IN: Instance of that type */
729     uint64_aligned_t bufsz;             /* IN: size of buffer */
730     XEN_GUEST_HANDLE_64(uint8) buffer;  /* OUT: buffer to write record into */
731 };
732 
733 /* XEN_DOMCTL_disable_migrate */
734 struct xen_domctl_disable_migrate {
735     uint32_t disable; /* IN: 1: disable migration and restore */
736 };
737 
738 
739 /* XEN_DOMCTL_gettscinfo */
740 /* XEN_DOMCTL_settscinfo */
741 struct xen_domctl_tsc_info {
742     /* IN/OUT */
743     uint32_t tsc_mode;
744     uint32_t gtsc_khz;
745     uint32_t incarnation;
746     uint32_t pad;
747     uint64_aligned_t elapsed_nsec;
748 };
749 
750 /* XEN_DOMCTL_gdbsx_guestmemio      guest mem io */
751 struct xen_domctl_gdbsx_memio {
752     /* IN */
753     uint64_aligned_t pgd3val;/* optional: init_mm.pgd[3] value */
754     uint64_aligned_t gva;    /* guest virtual address */
755     uint64_aligned_t uva;    /* user buffer virtual address */
756     uint32_t         len;    /* number of bytes to read/write */
757     uint8_t          gwr;    /* 0 = read from guest. 1 = write to guest */
758     /* OUT */
759     uint32_t         remain; /* bytes remaining to be copied */
760 };
761 
762 /* XEN_DOMCTL_gdbsx_pausevcpu */
763 /* XEN_DOMCTL_gdbsx_unpausevcpu */
764 struct xen_domctl_gdbsx_pauseunp_vcpu { /* pause/unpause a vcpu */
765     uint32_t         vcpu;         /* which vcpu */
766 };
767 
768 /* XEN_DOMCTL_gdbsx_domstatus */
769 struct xen_domctl_gdbsx_domstatus {
770     /* OUT */
771     uint8_t          paused;     /* is the domain paused */
772     uint32_t         vcpu_id;    /* any vcpu in an event? */
773     uint32_t         vcpu_ev;    /* if yes, what event? */
774 };
775 
776 /*
777  * VM event operations
778  */
779 
780 /* XEN_DOMCTL_vm_event_op */
781 
782 /*
783  * There are currently three rings available for VM events:
784  * sharing, monitor and paging. This hypercall allows one to
785  * control these rings (enable/disable), as well as to signal
786  * to the hypervisor to pull responses (resume) from the given
787  * ring.
788  */
789 #define XEN_VM_EVENT_ENABLE               0
790 #define XEN_VM_EVENT_DISABLE              1
791 #define XEN_VM_EVENT_RESUME               2
792 #define XEN_VM_EVENT_GET_VERSION          3
793 
794 /*
795  * Domain memory paging
796  * Page memory in and out.
797  * Domctl interface to set up and tear down the
798  * pager<->hypervisor interface. Use XENMEM_paging_op*
799  * to perform per-page operations.
800  *
801  * The XEN_VM_EVENT_PAGING_ENABLE domctl returns several
802  * non-standard error codes to indicate why paging could not be enabled:
803  * ENODEV - host lacks HAP support (EPT/NPT) or HAP is disabled in guest
804  * EMLINK - guest has iommu passthrough enabled
805  * EXDEV  - guest has PoD enabled
806  * EBUSY  - guest has or had paging enabled, ring buffer still active
807  */
808 #define XEN_DOMCTL_VM_EVENT_OP_PAGING            1
809 
810 /*
811  * Monitor helper.
812  *
813  * As with paging, use the domctl for teardown/setup of the
814  * helper<->hypervisor interface.
815  *
816  * The monitor interface can be used to register for various VM events. For
817  * example, there are HVM hypercalls to set the per-page access permissions
818  * of every page in a domain.  When one of these permissions--independent,
819  * read, write, and execute--is violated, the VCPU is paused and a memory event
820  * is sent with what happened. The memory event handler can then resume the
821  * VCPU and redo the access with a XEN_VM_EVENT_RESUME option.
822  *
823  * See public/vm_event.h for the list of available events that can be
824  * subscribed to via the monitor interface.
825  *
826  * The XEN_VM_EVENT_MONITOR_* domctls returns
827  * non-standard error codes to indicate why access could not be enabled:
828  * ENODEV - host lacks HAP support (EPT/NPT) or HAP is disabled in guest
829  * EBUSY  - guest has or had access enabled, ring buffer still active
830  *
831  */
832 #define XEN_DOMCTL_VM_EVENT_OP_MONITOR           2
833 
834 /*
835  * Sharing ENOMEM helper.
836  *
837  * As with paging, use the domctl for teardown/setup of the
838  * helper<->hypervisor interface.
839  *
840  * If setup, this ring is used to communicate failed allocations
841  * in the unshare path. XENMEM_sharing_op_resume is used to wake up
842  * vcpus that could not unshare.
843  *
844  * Note that sharing can be turned on (as per the domctl below)
845  * *without* this ring being setup.
846  */
847 #define XEN_DOMCTL_VM_EVENT_OP_SHARING           3
848 
849 /* Use for teardown/setup of helper<->hypervisor interface for paging,
850  * access and sharing.*/
851 struct xen_domctl_vm_event_op {
852     uint32_t       op;           /* XEN_VM_EVENT_* */
853     uint32_t       mode;         /* XEN_DOMCTL_VM_EVENT_OP_* */
854 
855     union {
856         struct {
857             uint32_t port;       /* OUT: event channel for ring */
858         } enable;
859 
860         uint32_t version;
861     } u;
862 };
863 
864 /*
865  * Memory sharing operations
866  */
867 /* XEN_DOMCTL_mem_sharing_op.
868  * The CONTROL sub-domctl is used for bringup/teardown. */
869 #define XEN_DOMCTL_MEM_SHARING_CONTROL          0
870 
871 struct xen_domctl_mem_sharing_op {
872     uint8_t op; /* XEN_DOMCTL_MEM_SHARING_* */
873 
874     union {
875         uint8_t enable;                   /* CONTROL */
876     } u;
877 };
878 
879 struct xen_domctl_audit_p2m {
880     /* OUT error counts */
881     uint64_t orphans;
882     uint64_t m2p_bad;
883     uint64_t p2m_bad;
884 };
885 
886 struct xen_domctl_set_virq_handler {
887     uint32_t virq; /* IN */
888 };
889 
890 #if defined(__i386__) || defined(__x86_64__)
891 /* XEN_DOMCTL_setvcpuextstate */
892 /* XEN_DOMCTL_getvcpuextstate */
893 struct xen_domctl_vcpuextstate {
894     /* IN: VCPU that this call applies to. */
895     uint32_t         vcpu;
896     /*
897      * SET: Ignored.
898      * GET: xfeature support mask of struct (IN/OUT)
899      * xfeature mask is served as identifications of the saving format
900      * so that compatible CPUs can have a check on format to decide
901      * whether it can restore.
902      */
903     uint64_aligned_t         xfeature_mask;
904     /*
905      * SET: Size of struct (IN)
906      * GET: Size of struct (IN/OUT)
907      */
908     uint64_aligned_t         size;
909     XEN_GUEST_HANDLE_64(uint64) buffer;
910 };
911 #endif
912 
913 /* XEN_DOMCTL_set_access_required: sets whether a memory event listener
914  * must be present to handle page access events: if false, the page
915  * access will revert to full permissions if no one is listening;
916  *  */
917 struct xen_domctl_set_access_required {
918     uint8_t access_required;
919 };
920 
921 struct xen_domctl_set_broken_page_p2m {
922     uint64_aligned_t pfn;
923 };
924 
925 /*
926  * ARM: Clean and invalidate caches associated with given region of
927  * guest memory.
928  */
929 struct xen_domctl_cacheflush {
930     /* IN: page range to flush. */
931     xen_pfn_t start_pfn, nr_pfns;
932 };
933 
934 #if defined(__i386__) || defined(__x86_64__)
935 struct xen_domctl_vcpu_msr {
936     uint32_t         index;
937     uint32_t         reserved;
938     uint64_aligned_t value;
939 };
940 typedef struct xen_domctl_vcpu_msr xen_domctl_vcpu_msr_t;
941 DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpu_msr_t);
942 
943 /*
944  * XEN_DOMCTL_set_vcpu_msrs / XEN_DOMCTL_get_vcpu_msrs.
945  *
946  * Input:
947  * - A NULL 'msrs' guest handle is a request for the maximum 'msr_count'.
948  * - Otherwise, 'msr_count' is the number of entries in 'msrs'.
949  *
950  * Output for get:
951  * - If 'msr_count' is less than the number Xen needs to write, -ENOBUFS shall
952  *   be returned and 'msr_count' updated to reflect the intended number.
953  * - On success, 'msr_count' shall indicate the number of MSRs written, which
954  *   may be less than the maximum if some are not currently used by the vcpu.
955  *
956  * Output for set:
957  * - If Xen encounters an error with a specific MSR, -EINVAL shall be returned
958  *   and 'msr_count' shall be set to the offending index, to aid debugging.
959  */
960 struct xen_domctl_vcpu_msrs {
961     uint32_t vcpu;                                   /* IN     */
962     uint32_t msr_count;                              /* IN/OUT */
963     XEN_GUEST_HANDLE_64(xen_domctl_vcpu_msr_t) msrs; /* IN/OUT */
964 };
965 #endif
966 
967 /* XEN_DOMCTL_setvnumainfo: specifies a virtual NUMA topology for the guest */
968 struct xen_domctl_vnuma {
969     /* IN: number of vNUMA nodes to setup. Shall be greater than 0 */
970     uint32_t nr_vnodes;
971     /* IN: number of memory ranges to setup */
972     uint32_t nr_vmemranges;
973     /*
974      * IN: number of vCPUs of the domain (used as size of the vcpu_to_vnode
975      * array declared below). Shall be equal to the domain's max_vcpus.
976      */
977     uint32_t nr_vcpus;
978     uint32_t pad;                                  /* must be zero */
979 
980     /*
981      * IN: array for specifying the distances of the vNUMA nodes
982      * between each others. Shall have nr_vnodes*nr_vnodes elements.
983      */
984     XEN_GUEST_HANDLE_64(uint) vdistance;
985     /*
986      * IN: array for specifying to what vNUMA node each vCPU belongs.
987      * Shall have nr_vcpus elements.
988      */
989     XEN_GUEST_HANDLE_64(uint) vcpu_to_vnode;
990     /*
991      * IN: array for specifying on what physical NUMA node each vNUMA
992      * node is placed. Shall have nr_vnodes elements.
993      */
994     XEN_GUEST_HANDLE_64(uint) vnode_to_pnode;
995     /*
996      * IN: array for specifying the memory ranges. Shall have
997      * nr_vmemranges elements.
998      */
999     XEN_GUEST_HANDLE_64(xen_vmemrange_t) vmemrange;
1000 };
1001 
1002 struct xen_domctl_psr_cmt_op {
1003 #define XEN_DOMCTL_PSR_CMT_OP_DETACH         0
1004 #define XEN_DOMCTL_PSR_CMT_OP_ATTACH         1
1005 #define XEN_DOMCTL_PSR_CMT_OP_QUERY_RMID     2
1006     uint32_t cmd;
1007     uint32_t data;
1008 };
1009 
1010 /*  XEN_DOMCTL_MONITOR_*
1011  *
1012  * Enable/disable monitoring various VM events.
1013  * This domctl configures what events will be reported to helper apps
1014  * via the ring buffer "MONITOR". The ring has to be first enabled
1015  * with the domctl XEN_DOMCTL_VM_EVENT_OP_MONITOR.
1016  *
1017  * GET_CAPABILITIES can be used to determine which of these features is
1018  * available on a given platform.
1019  *
1020  * NOTICE: mem_access events are also delivered via the "MONITOR" ring buffer;
1021  * however, enabling/disabling those events is performed with the use of
1022  * memory_op hypercalls!
1023  */
1024 #define XEN_DOMCTL_MONITOR_OP_ENABLE            0
1025 #define XEN_DOMCTL_MONITOR_OP_DISABLE           1
1026 #define XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES  2
1027 #define XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP  3
1028 /*
1029  * Control register feature can result in guest-crashes when the monitor
1030  * subsystem is being turned off. User has to take special precautions
1031  * to ensure all vCPUs have resumed before it is safe to turn it off.
1032  */
1033 #define XEN_DOMCTL_MONITOR_OP_CONTROL_REGISTERS 4
1034 
1035 #define XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG         0
1036 #define XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR            1
1037 #define XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP            2
1038 #define XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT   3
1039 #define XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST         4
1040 #define XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION       5
1041 #define XEN_DOMCTL_MONITOR_EVENT_CPUID                 6
1042 #define XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL       7
1043 #define XEN_DOMCTL_MONITOR_EVENT_INTERRUPT             8
1044 #define XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS           9
1045 #define XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED    10
1046 /* Enabled by default */
1047 #define XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT     11
1048 
1049 struct xen_domctl_monitor_op {
1050     uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */
1051 
1052     /*
1053      * When used with ENABLE/DISABLE this has to be set to
1054      * the requested XEN_DOMCTL_MONITOR_EVENT_* value.
1055      * With GET_CAPABILITIES this field returns a bitmap of
1056      * events supported by the platform, in the format
1057      * (1 << XEN_DOMCTL_MONITOR_EVENT_*).
1058      */
1059     uint32_t event;
1060 
1061     /*
1062      * Further options when issuing XEN_DOMCTL_MONITOR_OP_ENABLE.
1063      */
1064     union {
1065         struct {
1066             /* Which control register */
1067             uint8_t index;
1068             /* Pause vCPU until response */
1069             uint8_t sync;
1070             /* Send event only on a change of value */
1071             uint8_t onchangeonly;
1072             /* Allignment padding */
1073             uint8_t pad1;
1074             uint32_t pad2;
1075             /*
1076              * Send event only if the changed bit in the control register
1077              * is not masked.
1078              */
1079             uint64_aligned_t bitmask;
1080         } mov_to_cr;
1081 
1082         struct {
1083             uint32_t msr;
1084             /* Send event only on a change of value */
1085             uint8_t onchangeonly;
1086         } mov_to_msr;
1087 
1088         struct {
1089             /* Pause vCPU until response */
1090             uint8_t sync;
1091             uint8_t allow_userspace;
1092         } guest_request;
1093 
1094         struct {
1095             /* Pause vCPU until response */
1096             uint8_t sync;
1097         } debug_exception;
1098     } u;
1099 };
1100 
1101 struct xen_domctl_psr_alloc {
1102 #define XEN_DOMCTL_PSR_SET_L3_CBM     0
1103 #define XEN_DOMCTL_PSR_GET_L3_CBM     1
1104 #define XEN_DOMCTL_PSR_SET_L3_CODE    2
1105 #define XEN_DOMCTL_PSR_SET_L3_DATA    3
1106 #define XEN_DOMCTL_PSR_GET_L3_CODE    4
1107 #define XEN_DOMCTL_PSR_GET_L3_DATA    5
1108 #define XEN_DOMCTL_PSR_SET_L2_CBM     6
1109 #define XEN_DOMCTL_PSR_GET_L2_CBM     7
1110 #define XEN_DOMCTL_PSR_SET_MBA_THRTL  8
1111 #define XEN_DOMCTL_PSR_GET_MBA_THRTL  9
1112     uint32_t cmd;       /* IN: XEN_DOMCTL_PSR_* */
1113     uint32_t target;    /* IN */
1114     uint64_t data;      /* IN/OUT */
1115 };
1116 
1117 /* XEN_DOMCTL_vuart_op */
1118 struct xen_domctl_vuart_op {
1119 #define XEN_DOMCTL_VUART_OP_INIT  0
1120         uint32_t cmd;           /* XEN_DOMCTL_VUART_OP_* */
1121 #define XEN_DOMCTL_VUART_TYPE_VPL011 0
1122         uint32_t type;          /* IN - type of vuart.
1123                                  *      Currently only vpl011 supported.
1124                                  */
1125         uint64_aligned_t  gfn;  /* IN - guest gfn to be used as a
1126                                  *      ring buffer.
1127                                  */
1128         domid_t console_domid;  /* IN - domid of domain running the
1129                                  *      backend console.
1130                                  */
1131         uint8_t pad[2];
1132         evtchn_port_t evtchn;   /* OUT - remote port of the event
1133                                  *       channel used for sending
1134                                  *       ring buffer events.
1135                                  */
1136 };
1137 
1138 struct xen_domctl {
1139     uint32_t cmd;
1140 #define XEN_DOMCTL_createdomain                   1
1141 #define XEN_DOMCTL_destroydomain                  2
1142 #define XEN_DOMCTL_pausedomain                    3
1143 #define XEN_DOMCTL_unpausedomain                  4
1144 #define XEN_DOMCTL_getdomaininfo                  5
1145 /* #define XEN_DOMCTL_getmemlist                  6 Removed */
1146 /* #define XEN_DOMCTL_getpageframeinfo            7 Obsolete - use getpageframeinfo3 */
1147 /* #define XEN_DOMCTL_getpageframeinfo2           8 Obsolete - use getpageframeinfo3 */
1148 #define XEN_DOMCTL_setvcpuaffinity                9
1149 #define XEN_DOMCTL_shadow_op                     10
1150 #define XEN_DOMCTL_max_mem                       11
1151 #define XEN_DOMCTL_setvcpucontext                12
1152 #define XEN_DOMCTL_getvcpucontext                13
1153 #define XEN_DOMCTL_getvcpuinfo                   14
1154 #define XEN_DOMCTL_max_vcpus                     15
1155 #define XEN_DOMCTL_scheduler_op                  16
1156 #define XEN_DOMCTL_setdomainhandle               17
1157 #define XEN_DOMCTL_setdebugging                  18
1158 #define XEN_DOMCTL_irq_permission                19
1159 #define XEN_DOMCTL_iomem_permission              20
1160 #define XEN_DOMCTL_ioport_permission             21
1161 #define XEN_DOMCTL_hypercall_init                22
1162 #ifdef __XEN__
1163 /* #define XEN_DOMCTL_arch_setup                 23 Obsolete IA64 only */
1164 #define XEN_DOMCTL_soft_reset_cont               23
1165 #endif
1166 #define XEN_DOMCTL_settimeoffset                 24
1167 #define XEN_DOMCTL_getvcpuaffinity               25
1168 #define XEN_DOMCTL_real_mode_area                26 /* Obsolete PPC only */
1169 #define XEN_DOMCTL_resumedomain                  27
1170 #define XEN_DOMCTL_sendtrigger                   28
1171 #define XEN_DOMCTL_subscribe                     29
1172 #define XEN_DOMCTL_gethvmcontext                 33
1173 #define XEN_DOMCTL_sethvmcontext                 34
1174 #define XEN_DOMCTL_set_address_size              35
1175 #define XEN_DOMCTL_get_address_size              36
1176 #define XEN_DOMCTL_assign_device                 37
1177 #define XEN_DOMCTL_bind_pt_irq                   38
1178 #define XEN_DOMCTL_memory_mapping                39
1179 #define XEN_DOMCTL_ioport_mapping                40
1180 /* #define XEN_DOMCTL_pin_mem_cacheattr          41 Removed - use dmop */
1181 #define XEN_DOMCTL_set_ext_vcpucontext           42
1182 #define XEN_DOMCTL_get_ext_vcpucontext           43
1183 #define XEN_DOMCTL_set_opt_feature               44 /* Obsolete IA64 only */
1184 #define XEN_DOMCTL_test_assign_device            45
1185 #define XEN_DOMCTL_set_target                    46
1186 #define XEN_DOMCTL_deassign_device               47
1187 #define XEN_DOMCTL_unbind_pt_irq                 48
1188 /* #define XEN_DOMCTL_set_cpuid                  49 - Obsolete - use set_cpu_policy */
1189 #define XEN_DOMCTL_get_device_group              50
1190 /* #define XEN_DOMCTL_set_machine_address_size   51 - Obsolete */
1191 /* #define XEN_DOMCTL_get_machine_address_size   52 - Obsolete */
1192 /* #define XEN_DOMCTL_suppress_spurious_page_faults 53 - Obsolete */
1193 #define XEN_DOMCTL_debug_op                      54
1194 #define XEN_DOMCTL_gethvmcontext_partial         55
1195 #define XEN_DOMCTL_vm_event_op                   56
1196 #define XEN_DOMCTL_mem_sharing_op                57
1197 #define XEN_DOMCTL_disable_migrate               58
1198 #define XEN_DOMCTL_gettscinfo                    59
1199 #define XEN_DOMCTL_settscinfo                    60
1200 #define XEN_DOMCTL_getpageframeinfo3             61
1201 #define XEN_DOMCTL_setvcpuextstate               62
1202 #define XEN_DOMCTL_getvcpuextstate               63
1203 #define XEN_DOMCTL_set_access_required           64
1204 #define XEN_DOMCTL_audit_p2m                     65
1205 #define XEN_DOMCTL_set_virq_handler              66
1206 #define XEN_DOMCTL_set_broken_page_p2m           67
1207 #define XEN_DOMCTL_setnodeaffinity               68
1208 #define XEN_DOMCTL_getnodeaffinity               69
1209 /* #define XEN_DOMCTL_set_max_evtchn             70 - Moved into XEN_DOMCTL_createdomain */
1210 #define XEN_DOMCTL_cacheflush                    71
1211 #define XEN_DOMCTL_get_vcpu_msrs                 72
1212 #define XEN_DOMCTL_set_vcpu_msrs                 73
1213 #define XEN_DOMCTL_setvnumainfo                  74
1214 #define XEN_DOMCTL_psr_cmt_op                    75
1215 #define XEN_DOMCTL_monitor_op                    77
1216 #define XEN_DOMCTL_psr_alloc                     78
1217 #define XEN_DOMCTL_soft_reset                    79
1218 /* #define XEN_DOMCTL_set_gnttab_limits          80 - Moved into XEN_DOMCTL_createdomain */
1219 #define XEN_DOMCTL_vuart_op                      81
1220 #define XEN_DOMCTL_get_cpu_policy                82
1221 #define XEN_DOMCTL_set_cpu_policy                83
1222 #define XEN_DOMCTL_gdbsx_guestmemio            1000
1223 #define XEN_DOMCTL_gdbsx_pausevcpu             1001
1224 #define XEN_DOMCTL_gdbsx_unpausevcpu           1002
1225 #define XEN_DOMCTL_gdbsx_domstatus             1003
1226     uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
1227     domid_t  domain;
1228     union {
1229         struct xen_domctl_createdomain      createdomain;
1230         struct xen_domctl_getdomaininfo     getdomaininfo;
1231         struct xen_domctl_getpageframeinfo3 getpageframeinfo3;
1232         struct xen_domctl_nodeaffinity      nodeaffinity;
1233         struct xen_domctl_vcpuaffinity      vcpuaffinity;
1234         struct xen_domctl_shadow_op         shadow_op;
1235         struct xen_domctl_max_mem           max_mem;
1236         struct xen_domctl_vcpucontext       vcpucontext;
1237         struct xen_domctl_getvcpuinfo       getvcpuinfo;
1238         struct xen_domctl_max_vcpus         max_vcpus;
1239         struct xen_domctl_scheduler_op      scheduler_op;
1240         struct xen_domctl_setdomainhandle   setdomainhandle;
1241         struct xen_domctl_setdebugging      setdebugging;
1242         struct xen_domctl_irq_permission    irq_permission;
1243         struct xen_domctl_iomem_permission  iomem_permission;
1244         struct xen_domctl_ioport_permission ioport_permission;
1245         struct xen_domctl_hypercall_init    hypercall_init;
1246         struct xen_domctl_settimeoffset     settimeoffset;
1247         struct xen_domctl_disable_migrate   disable_migrate;
1248         struct xen_domctl_tsc_info          tsc_info;
1249         struct xen_domctl_hvmcontext        hvmcontext;
1250         struct xen_domctl_hvmcontext_partial hvmcontext_partial;
1251         struct xen_domctl_address_size      address_size;
1252         struct xen_domctl_sendtrigger       sendtrigger;
1253         struct xen_domctl_get_device_group  get_device_group;
1254         struct xen_domctl_assign_device     assign_device;
1255         struct xen_domctl_bind_pt_irq       bind_pt_irq;
1256         struct xen_domctl_memory_mapping    memory_mapping;
1257         struct xen_domctl_ioport_mapping    ioport_mapping;
1258         struct xen_domctl_ext_vcpucontext   ext_vcpucontext;
1259         struct xen_domctl_set_target        set_target;
1260         struct xen_domctl_subscribe         subscribe;
1261         struct xen_domctl_debug_op          debug_op;
1262         struct xen_domctl_vm_event_op       vm_event_op;
1263         struct xen_domctl_mem_sharing_op    mem_sharing_op;
1264 #if defined(__i386__) || defined(__x86_64__)
1265         struct xen_domctl_cpu_policy        cpu_policy;
1266         struct xen_domctl_vcpuextstate      vcpuextstate;
1267         struct xen_domctl_vcpu_msrs         vcpu_msrs;
1268 #endif
1269         struct xen_domctl_set_access_required access_required;
1270         struct xen_domctl_audit_p2m         audit_p2m;
1271         struct xen_domctl_set_virq_handler  set_virq_handler;
1272         struct xen_domctl_gdbsx_memio       gdbsx_guest_memio;
1273         struct xen_domctl_set_broken_page_p2m set_broken_page_p2m;
1274         struct xen_domctl_cacheflush        cacheflush;
1275         struct xen_domctl_gdbsx_pauseunp_vcpu gdbsx_pauseunp_vcpu;
1276         struct xen_domctl_gdbsx_domstatus   gdbsx_domstatus;
1277         struct xen_domctl_vnuma             vnuma;
1278         struct xen_domctl_psr_cmt_op        psr_cmt_op;
1279         struct xen_domctl_monitor_op        monitor_op;
1280         struct xen_domctl_psr_alloc         psr_alloc;
1281         struct xen_domctl_vuart_op          vuart_op;
1282         uint8_t                             pad[128];
1283     } u;
1284 };
1285 typedef struct xen_domctl xen_domctl_t;
1286 DEFINE_XEN_GUEST_HANDLE(xen_domctl_t);
1287 
1288 #endif /* __XEN_PUBLIC_DOMCTL_H__ */
1289 
1290 /*
1291  * Local variables:
1292  * mode: C
1293  * c-file-style: "BSD"
1294  * c-basic-offset: 4
1295  * tab-width: 4
1296  * indent-tabs-mode: nil
1297  * End:
1298  */
1299