1 #ifndef __VKI_XEN_DOMCTL_H
2 #define __VKI_XEN_DOMCTL_H
3 
4 /*
5  * The domctl interface is versioned via the interface_version
6  * field. This structures in this header supports domctl interfaces:
7  *
8  * - 00000007: Xen 4.1
9  * - 00000008: Xen 4.2
10  * - 00000009: Xen 4.3
11  *
12  * When adding a new subop be sure to include the variants used by all
13  * of the above, both here and in syswrap-xen.c
14  *
15  * Structs which are identical in all supported versions have no
16  * version suffix. Structs which do differ are defined multiple times
17  * and use the suffix of the latest version to contain that particular
18  * variant.
19  */
20 
21 #define VKI_XEN_DOMCTL_createdomain                   1
22 #define VKI_XEN_DOMCTL_destroydomain                  2
23 #define VKI_XEN_DOMCTL_pausedomain                    3
24 #define VKI_XEN_DOMCTL_unpausedomain                  4
25 #define VKI_XEN_DOMCTL_getdomaininfo                  5
26 #define VKI_XEN_DOMCTL_getmemlist                     6
27 #define VKI_XEN_DOMCTL_getpageframeinfo               7
28 #define VKI_XEN_DOMCTL_getpageframeinfo2              8
29 #define VKI_XEN_DOMCTL_setvcpuaffinity                9
30 #define VKI_XEN_DOMCTL_shadow_op                     10
31 #define VKI_XEN_DOMCTL_max_mem                       11
32 #define VKI_XEN_DOMCTL_setvcpucontext                12
33 #define VKI_XEN_DOMCTL_getvcpucontext                13
34 #define VKI_XEN_DOMCTL_getvcpuinfo                   14
35 #define VKI_XEN_DOMCTL_max_vcpus                     15
36 #define VKI_XEN_DOMCTL_scheduler_op                  16
37 #define VKI_XEN_DOMCTL_setdomainhandle               17
38 #define VKI_XEN_DOMCTL_setdebugging                  18
39 #define VKI_XEN_DOMCTL_irq_permission                19
40 #define VKI_XEN_DOMCTL_iomem_permission              20
41 #define VKI_XEN_DOMCTL_ioport_permission             21
42 #define VKI_XEN_DOMCTL_hypercall_init                22
43 #define VKI_XEN_DOMCTL_arch_setup                    23
44 #define VKI_XEN_DOMCTL_settimeoffset                 24
45 #define VKI_XEN_DOMCTL_getvcpuaffinity               25
46 #define VKI_XEN_DOMCTL_real_mode_area                26
47 #define VKI_XEN_DOMCTL_resumedomain                  27
48 #define VKI_XEN_DOMCTL_sendtrigger                   28
49 #define VKI_XEN_DOMCTL_subscribe                     29
50 #define VKI_XEN_DOMCTL_gethvmcontext                 33
51 #define VKI_XEN_DOMCTL_sethvmcontext                 34
52 #define VKI_XEN_DOMCTL_set_address_size              35
53 #define VKI_XEN_DOMCTL_get_address_size              36
54 #define VKI_XEN_DOMCTL_assign_device                 37
55 #define VKI_XEN_DOMCTL_bind_pt_irq                   38
56 #define VKI_XEN_DOMCTL_memory_mapping                39
57 #define VKI_XEN_DOMCTL_ioport_mapping                40
58 #define VKI_XEN_DOMCTL_pin_mem_cacheattr             41
59 #define VKI_XEN_DOMCTL_set_ext_vcpucontext           42
60 #define VKI_XEN_DOMCTL_get_ext_vcpucontext           43
61 #define VKI_XEN_DOMCTL_set_opt_feature               44 /*Obsolete IA64 only */
62 #define VKI_XEN_DOMCTL_test_assign_device            45
63 #define VKI_XEN_DOMCTL_set_target                    46
64 #define VKI_XEN_DOMCTL_deassign_device               47
65 #define VKI_XEN_DOMCTL_unbind_pt_irq                 48
66 #define VKI_XEN_DOMCTL_set_cpuid                     49
67 #define VKI_XEN_DOMCTL_get_device_group              50
68 #define VKI_XEN_DOMCTL_set_machine_address_size      51
69 #define VKI_XEN_DOMCTL_get_machine_address_size      52
70 #define VKI_XEN_DOMCTL_suppress_spurious_page_faults 53
71 #define VKI_XEN_DOMCTL_debug_op                      54
72 #define VKI_XEN_DOMCTL_gethvmcontext_partial         55
73 #define VKI_XEN_DOMCTL_mem_event_op                  56
74 #define VKI_XEN_DOMCTL_mem_sharing_op                57
75 #define VKI_XEN_DOMCTL_disable_migrate               58
76 #define VKI_XEN_DOMCTL_gettscinfo                    59
77 #define VKI_XEN_DOMCTL_settscinfo                    60
78 #define VKI_XEN_DOMCTL_getpageframeinfo3             61
79 #define VKI_XEN_DOMCTL_setvcpuextstate               62
80 #define VKI_XEN_DOMCTL_getvcpuextstate               63
81 #define VKI_XEN_DOMCTL_set_access_required           64
82 #define VKI_XEN_DOMCTL_audit_p2m                     65
83 #define VKI_XEN_DOMCTL_set_virq_handler              66
84 #define VKI_XEN_DOMCTL_set_broken_page_p2m           67
85 #define VKI_XEN_DOMCTL_setnodeaffinity               68
86 #define VKI_XEN_DOMCTL_getnodeaffinity               69
87 #define VKI_XEN_DOMCTL_set_max_evtchn                70
88 #define VKI_XEN_DOMCTL_cacheflush                    71
89 #define VKI_XEN_DOMCTL_gdbsx_guestmemio            1000
90 #define VKI_XEN_DOMCTL_gdbsx_pausevcpu             1001
91 #define VKI_XEN_DOMCTL_gdbsx_unpausevcpu           1002
92 #define VKI_XEN_DOMCTL_gdbsx_domstatus             1003
93 
94 struct vki_xen_domctl_createdomain {
95     /* IN parameters */
96     vki_uint32_t ssidref;
97     vki_xen_domain_handle_t handle;
98     vki_uint32_t flags;
99 };
100 
101 struct vki_xen_domctl_getdomaininfo_00000007 {
102     /* OUT variables. */
103     vki_xen_domid_t  domain;
104     vki_uint32_t flags;
105     vki_xen_uint64_aligned_t tot_pages;
106     vki_xen_uint64_aligned_t max_pages;
107     vki_xen_uint64_aligned_t shr_pages;
108     vki_xen_uint64_aligned_t paged_pages;
109     vki_xen_uint64_aligned_t shared_info_frame;
110     vki_xen_uint64_aligned_t cpu_time;
111     vki_uint32_t nr_online_vcpus;
112     vki_uint32_t max_vcpu_id;
113     vki_uint32_t ssidref;
114     vki_xen_domain_handle_t handle;
115     vki_uint32_t cpupool;
116 };
117 typedef struct vki_xen_domctl_getdomaininfo_00000007 vki_xen_domctl_getdomaininfo_00000007_t;
118 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_getdomaininfo_00000007_t);
119 
120 struct vki_xen_domctl_getdomaininfo_00000008 {
121     /* OUT variables. */
122     vki_xen_domid_t  domain;
123     vki_uint32_t flags;
124     vki_xen_uint64_aligned_t tot_pages;
125     vki_xen_uint64_aligned_t max_pages;
126     vki_xen_uint64_aligned_t shr_pages;
127     vki_xen_uint64_aligned_t paged_pages;
128     vki_xen_uint64_aligned_t shared_info_frame;
129     vki_xen_uint64_aligned_t cpu_time;
130     vki_uint32_t nr_online_vcpus;
131     vki_uint32_t max_vcpu_id;
132     vki_uint32_t ssidref;
133     vki_xen_domain_handle_t handle;
134     vki_uint32_t cpupool;
135 };
136 typedef struct vki_xen_domctl_getdomaininfo_00000008 vki_xen_domctl_getdomaininfo_00000008_t;
137 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_getdomaininfo_00000008_t);
138 
139 struct vki_xen_domctl_getdomaininfo_00000009 {
140     /* OUT variables. */
141     vki_xen_domid_t  domain;
142     vki_uint32_t flags;
143     vki_xen_uint64_aligned_t tot_pages;
144     vki_xen_uint64_aligned_t max_pages;
145     vki_xen_uint64_aligned_t outstanding_pages;
146     vki_xen_uint64_aligned_t shr_pages;
147     vki_xen_uint64_aligned_t paged_pages;
148     vki_xen_uint64_aligned_t shared_info_frame;
149     vki_xen_uint64_aligned_t cpu_time;
150     vki_uint32_t nr_online_vcpus;
151     vki_uint32_t max_vcpu_id;
152     vki_uint32_t ssidref;
153     vki_xen_domain_handle_t handle;
154     vki_uint32_t cpupool;
155 };
156 typedef struct vki_xen_domctl_getdomaininfo_00000009 vki_xen_domctl_getdomaininfo_00000009_t;
157 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_getdomaininfo_00000009_t);
158 
159 /* Get/set the NUMA node(s) with which the guest has affinity with. */
160 /* XEN_DOMCTL_setnodeaffinity */
161 /* XEN_DOMCTL_getnodeaffinity */
162 struct vki_xen_domctl_nodeaffinity {
163     struct vki_xenctl_bitmap nodemap;/* IN */
164 };
165 typedef struct vki_xen_domctl_nodeaffinity vki_xen_domctl_nodeaffinity_t;
166 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_nodeaffinity_t);
167 
168 struct vki_xen_domctl_getpageframeinfo3 {
169     vki_xen_uint64_aligned_t num; /* IN */
170     VKI_XEN_GUEST_HANDLE_64(vki_xen_pfn_t) array; /* IN/OUT */
171 };
172 
173 struct vki_xen_domctl_vcpuaffinity {
174     vki_uint32_t  vcpu;              /* IN */
175     struct vki_xenctl_bitmap cpumap; /* IN/OUT */
176 };
177 
178 struct vki_xen_domctl_shadow_op_stats {
179     vki_uint32_t fault_count;
180     vki_uint32_t dirty_count;
181 };
182 
183 /* vki_xen_domctl_shadow_op.op is an utter mess for compatibily reasons. */
184 
185 struct vki_xen_domctl_shadow_op {
186     vki_uint32_t op; /* IN */
187 
188 #define VKI_XEN_DOMCTL_SHADOW_OP_OFF               0
189 #define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE           32
190 #define VKI_XEN_DOMCTL_SHADOW_OP_CLEAN            11
191 #define VKI_XEN_DOMCTL_SHADOW_OP_PEEK             12
192 #define VKI_XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
193 #define VKI_XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
194 
195 #define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
196 #define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
197 #define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
198 
199     vki_uint32_t mode;
200 
201 #define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
202 #define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
203 #define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
204 #define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
205 
206     vki_uint32_t mb;
207     VKI_XEN_GUEST_HANDLE_64(vki_uint8) dirty_bitmap;
208     vki_xen_uint64_aligned_t pages;
209     struct vki_xen_domctl_shadow_op_stats stats;
210 };
211 
212 struct vki_xen_domctl_max_mem {
213     /* IN variables. */
214     vki_xen_uint64_aligned_t max_memkb;
215 };
216 
217 struct vki_xen_domctl_vcpucontext {
218     vki_uint32_t              vcpu;                  /* IN */
219     VKI_XEN_GUEST_HANDLE_64(vki_xen_vcpu_guest_context_t) ctxt; /* IN/OUT */
220 };
221 
222 struct vki_xen_domctl_getvcpuinfo {
223     /* IN variables. */
224     vki_uint32_t vcpu;
225     /* OUT variables. */
226     vki_uint8_t  online;              /* currently online (not hotplugged)? */
227     vki_uint8_t  blocked;             /* blocked waiting for an event? */
228     vki_uint8_t  running;             /* currently scheduled on its CPU? */
229     vki_xen_uint64_aligned_t cpu_time;/* total cpu time consumed (ns) */
230     vki_uint32_t cpu;                 /* current mapping   */
231 };
232 
233 struct vki_xen_domctl_scheduler_op {
234     vki_uint32_t sched_id;  /* VKI_XEN_SCHEDULER_* */
235 #define VKI_XEN_SCHEDULER_SEDF     4
236 #define VKI_XEN_SCHEDULER_CREDIT   5
237 #define VKI_XEN_SCHEDULER_CREDIT2  6
238 #define VKI_XEN_SCHEDULER_ARINC653 7
239     vki_uint32_t cmd;       /* VKI_XEN_DOMCTL_SCHEDOP_* */
240 #define VKI_XEN_DOMCTL_SCHEDOP_putinfo 0
241 #define VKI_XEN_DOMCTL_SCHEDOP_getinfo 1
242     union {
243         struct xen_domctl_sched_sedf {
244             vki_xen_uint64_aligned_t period;
245             vki_xen_uint64_aligned_t slice;
246             vki_xen_uint64_aligned_t latency;
247             vki_uint32_t extratime;
248             vki_uint32_t weight;
249         } sedf;
250         struct xen_domctl_sched_credit {
251             vki_uint16_t weight;
252             vki_uint16_t cap;
253         } credit;
254         struct xen_domctl_sched_credit2 {
255             vki_uint16_t weight;
256         } credit2;
257     } u;
258 };
259 
260 struct vki_xen_domctl_max_vcpus {
261     vki_uint32_t max;           /* maximum number of vcpus */
262 };
263 
264 struct vki_xen_domctl_ioport_permission {
265     vki_uint32_t first_port;              /* IN */
266     vki_uint32_t nr_ports;                /* IN */
267     vki_uint8_t  allow_access;            /* IN */
268 };
269 
270 struct vki_xen_domctl_hypercall_init {
271     vki_xen_uint64_aligned_t  gmfn;           /* GMFN to be initialised */
272 };
273 
274 struct vki_xen_domctl_settimeoffset {
275     vki_int32_t time_offset_seconds;
276 };
277 
278 struct vki_xen_domctl_cpuid {
279   vki_uint32_t input[2];
280   vki_uint32_t eax;
281   vki_uint32_t ebx;
282   vki_uint32_t ecx;
283   vki_uint32_t edx;
284 };
285 
286 struct vki_xen_guest_tsc_info {
287     vki_uint32_t tsc_mode;
288     vki_uint32_t gtsc_khz;
289     vki_uint32_t incarnation;
290     vki_uint32_t pad;
291     vki_xen_uint64_aligned_t elapsed_nsec;
292 };
293 typedef struct vki_xen_guest_tsc_info vki_xen_guest_tsc_info_t;
294 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_guest_tsc_info_t);
295 
296 struct vki_xen_domctl_hvmcontext {
297     vki_uint32_t size; /* IN/OUT size of buffer */
298     VKI_XEN_GUEST_HANDLE_64(vki_uint8) buffer; /* IN/OUT */
299 };
300 typedef struct vki_xen_domctl_hvmcontext vki_xen_domctl_hvmcontext_t;
301 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_t);
302 
303 struct vki_xen_domctl_hvmcontext_partial {
304     vki_uint32_t type; /* IN */
305     vki_uint32_t instance; /* IN */
306     VKI_XEN_GUEST_HANDLE_64(vki_uint8) buffer; /* IN/OUT buffer */
307 };
308 typedef struct vki_xen_domctl_hvmcontext_partial vki_xen_domctl_hvmcontext_partial_t;
309 DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_partial_t);
310 
311 struct vki_xen_domctl_tsc_info {
312     VKI_XEN_GUEST_HANDLE_64(vki_xen_guest_tsc_info_t) out_info; /* OUT */
313     vki_xen_guest_tsc_info_t info; /* IN */
314 };
315 
316 struct vki_xen_domctl_vcpuextstate {
317     vki_uint32_t         vcpu;
318     vki_xen_uint64_aligned_t         xfeature_mask;
319     vki_xen_uint64_aligned_t         size;
320     VKI_XEN_GUEST_HANDLE_64(vki_uint64) buffer;
321 };
322 
323 struct vki_xen_domctl_address_size {
324     vki_uint32_t size;
325 };
326 
327 struct vki_xen_domctl_debug_op {
328     vki_uint32_t op;   /* IN */
329     vki_uint32_t vcpu; /* IN */
330 };
331 typedef struct vki_xen_domctl_debug_op vki_xen_domctl_debug_op_t;
332 
333 struct vki_xen_domctl_mem_event_op {
334     vki_uint32_t op; /* IN */
335     vki_uint32_t mode; /* IN */
336     vki_uint32_t port; /* OUT */
337 };
338 
339 struct vki_xen_domctl_set_access_required {
340     vki_uint8_t access_required; /* IN */
341 };
342 
343 struct vki_xen_domctl_set_max_evtchn {
344     vki_uint32_t max_port;
345 };
346 
347 struct vki_xen_domctl_cacheflush {
348     /* IN: page range to flush. */
349     vki_xen_pfn_t start_pfn, nr_pfns;
350 };
351 
352 struct vki_xen_domctl {
353     vki_uint32_t cmd;
354     vki_uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
355     vki_xen_domid_t  domain;
356     union {
357         struct vki_xen_domctl_createdomain      createdomain;
358         struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007;
359         struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008;
360         struct vki_xen_domctl_getdomaininfo_00000009 getdomaininfo_00000009;
361         //struct vki_xen_domctl_getmemlist        getmemlist;
362         //struct vki_xen_domctl_getpageframeinfo  getpageframeinfo;
363         //struct vki_xen_domctl_getpageframeinfo2 getpageframeinfo2;
364         struct vki_xen_domctl_getpageframeinfo3 getpageframeinfo3;
365         struct vki_xen_domctl_nodeaffinity      nodeaffinity;
366         struct vki_xen_domctl_vcpuaffinity      vcpuaffinity;
367         struct vki_xen_domctl_shadow_op         shadow_op;
368         struct vki_xen_domctl_max_mem           max_mem;
369         struct vki_xen_domctl_vcpucontext       vcpucontext;
370         struct vki_xen_domctl_getvcpuinfo       getvcpuinfo;
371         struct vki_xen_domctl_max_vcpus         max_vcpus;
372         struct vki_xen_domctl_scheduler_op      scheduler_op;
373         //struct vki_xen_domctl_setdomainhandle   setdomainhandle;
374         //struct vki_xen_domctl_setdebugging      setdebugging;
375         //struct vki_xen_domctl_irq_permission    irq_permission;
376         //struct vki_xen_domctl_iomem_permission  iomem_permission;
377         struct vki_xen_domctl_ioport_permission ioport_permission;
378         struct vki_xen_domctl_hypercall_init    hypercall_init;
379         //struct vki_xen_domctl_arch_setup        arch_setup;
380         struct vki_xen_domctl_settimeoffset     settimeoffset;
381         //struct vki_xen_domctl_disable_migrate   disable_migrate;
382         struct vki_xen_domctl_tsc_info          tsc_info;
383         //struct vki_xen_domctl_real_mode_area    real_mode_area;
384         struct vki_xen_domctl_hvmcontext        hvmcontext;
385         struct vki_xen_domctl_hvmcontext_partial hvmcontext_partial;
386         struct vki_xen_domctl_address_size      address_size;
387         //struct vki_xen_domctl_sendtrigger       sendtrigger;
388         //struct vki_xen_domctl_get_device_group  get_device_group;
389         //struct vki_xen_domctl_assign_device     assign_device;
390         //struct vki_xen_domctl_bind_pt_irq       bind_pt_irq;
391         //struct vki_xen_domctl_memory_mapping    memory_mapping;
392         //struct vki_xen_domctl_ioport_mapping    ioport_mapping;
393         //struct vki_xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
394         //struct vki_xen_domctl_ext_vcpucontext   ext_vcpucontext;
395         //struct vki_xen_domctl_set_target        set_target;
396         //struct vki_xen_domctl_subscribe         subscribe;
397         struct vki_xen_domctl_debug_op          debug_op;
398         struct vki_xen_domctl_mem_event_op      mem_event_op;
399         //struct vki_xen_domctl_mem_sharing_op    mem_sharing_op;
400 #if defined(__i386__) || defined(__x86_64__)
401         struct vki_xen_domctl_cpuid             cpuid;
402         struct vki_xen_domctl_vcpuextstate      vcpuextstate;
403 #endif
404         struct vki_xen_domctl_set_access_required access_required;
405         //struct vki_xen_domctl_audit_p2m         audit_p2m;
406         //struct vki_xen_domctl_set_virq_handler  set_virq_handler;
407         struct vki_xen_domctl_set_max_evtchn    set_max_evtchn;
408         //struct vki_xen_domctl_gdbsx_memio       gdbsx_guest_memio;
409         //struct vki_xen_domctl_set_broken_page_p2m set_broken_page_p2m;
410         struct vki_xen_domctl_cacheflush        cacheflush;
411         //struct vki_xen_domctl_gdbsx_pauseunp_vcpu gdbsx_pauseunp_vcpu;
412         //struct vki_xen_domctl_gdbsx_domstatus   gdbsx_domstatus;
413         vki_uint8_t                         pad[128];
414     } u;
415 };
416 
417 #endif // __VKI_XEN_DOMCTL_H
418 
419 /*--------------------------------------------------------------------*/
420 /*--- end                                                          ---*/
421 /*--------------------------------------------------------------------*/
422