xref: /titanic_52/usr/src/uts/common/xen/public/domctl.h (revision a93a1f58a8763fa69172980b98e3d24720c1136e)
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 /*
32  * XXPV - We need sysctl (physinfo) in the solaris kernel, which includes
33  * this file
34  */
35 #if 0
36 
37 #if !defined(__XEN__) && !defined(__XEN_TOOLS__)
38 #error "domctl operations are intended for use by node control tools only"
39 #endif
40 
41 #endif /* XXPV */
42 
43 #include "xen.h"
44 
45 #define XEN_DOMCTL_INTERFACE_VERSION 0x00000004
46 
47 struct xenctl_cpumap {
48     XEN_GUEST_HANDLE(uint8_t) bitmap;
49     uint32_t nr_cpus;
50 };
51 
52 /*
53  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
54  * If it is specified as zero, an id is auto-allocated and returned.
55  */
56 #define XEN_DOMCTL_createdomain       1
57 struct xen_domctl_createdomain {
58     /* IN parameters */
59     uint32_t ssidref;
60     xen_domain_handle_t handle;
61  /* Is this an HVM guest (as opposed to a PV guest)? */
62 #define _XEN_DOMCTL_CDF_hvm_guest 0
63 #define XEN_DOMCTL_CDF_hvm_guest  (1U<<_XEN_DOMCTL_CDF_hvm_guest)
64     uint32_t flags;
65 };
66 typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
67 DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t);
68 
69 #define XEN_DOMCTL_destroydomain      2
70 #define XEN_DOMCTL_pausedomain        3
71 #define XEN_DOMCTL_unpausedomain      4
72 
73 #define XEN_DOMCTL_getdomaininfo      5
74 struct xen_domctl_getdomaininfo {
75     /* OUT variables. */
76     domid_t  domain;              /* Also echoed in domctl.domain */
77  /* Domain is scheduled to die. */
78 #define _XEN_DOMINF_dying     0
79 #define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
80  /* Domain is an HVM guest (as opposed to a PV guest). */
81 #define _XEN_DOMINF_hvm_guest 1
82 #define XEN_DOMINF_hvm_guest  (1U<<_XEN_DOMINF_hvm_guest)
83  /* The guest OS has shut down. */
84 #define _XEN_DOMINF_shutdown  2
85 #define XEN_DOMINF_shutdown   (1U<<_XEN_DOMINF_shutdown)
86  /* Currently paused by control software. */
87 #define _XEN_DOMINF_paused    3
88 #define XEN_DOMINF_paused     (1U<<_XEN_DOMINF_paused)
89  /* Currently blocked pending an event.     */
90 #define _XEN_DOMINF_blocked   4
91 #define XEN_DOMINF_blocked    (1U<<_XEN_DOMINF_blocked)
92  /* Domain is currently running.            */
93 #define _XEN_DOMINF_running   5
94 #define XEN_DOMINF_running    (1U<<_XEN_DOMINF_running)
95  /* CPU to which this domain is bound.      */
96 #define XEN_DOMINF_cpumask      255
97 #define XEN_DOMINF_cpushift       8
98  /* XEN_DOMINF_shutdown guest-supplied code.  */
99 #define XEN_DOMINF_shutdownmask 255
100 #define XEN_DOMINF_shutdownshift 16
101     uint32_t flags;              /* XEN_DOMINF_* */
102     uint64_t tot_pages;
103     uint64_t max_pages;
104     uint64_t shared_info_frame;  /* GMFN of shared_info struct */
105     uint64_t cpu_time;
106     uint32_t nr_online_vcpus;    /* Number of VCPUs currently online. */
107     uint32_t max_vcpu_id;        /* Maximum VCPUID in use by this domain. */
108     uint32_t ssidref;
109     xen_domain_handle_t handle;
110 };
111 typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
112 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t);
113 
114 
115 #define XEN_DOMCTL_getmemlist         6
116 struct xen_domctl_getmemlist {
117     /* IN variables. */
118     /* Max entries to write to output buffer. */
119     uint64_t max_pfns;
120     /* Start index in guest's page list. */
121     uint64_t start_pfn;
122     XEN_GUEST_HANDLE(xen_pfn_t) buffer;
123     /* OUT variables. */
124     uint64_t num_pfns;
125 };
126 typedef struct xen_domctl_getmemlist xen_domctl_getmemlist_t;
127 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getmemlist_t);
128 
129 
130 #define XEN_DOMCTL_getpageframeinfo   7
131 
132 #define XEN_DOMCTL_PFINFO_LTAB_SHIFT 28
133 #define XEN_DOMCTL_PFINFO_NOTAB   (0x0<<28)
134 #define XEN_DOMCTL_PFINFO_L1TAB   (0x1<<28)
135 #define XEN_DOMCTL_PFINFO_L2TAB   (0x2<<28)
136 #define XEN_DOMCTL_PFINFO_L3TAB   (0x3<<28)
137 #define XEN_DOMCTL_PFINFO_L4TAB   (0x4<<28)
138 #define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7<<28)
139 #define XEN_DOMCTL_PFINFO_LPINTAB (0x1<<31)
140 #define XEN_DOMCTL_PFINFO_XTAB    (0xf<<28) /* invalid page */
141 #define XEN_DOMCTL_PFINFO_LTAB_MASK (0xf<<28)
142 
143 struct xen_domctl_getpageframeinfo {
144     /* IN variables. */
145     uint64_t gmfn;        /* GMFN to query */
146     /* OUT variables. */
147     /* Is the page PINNED to a type? */
148     uint32_t type;         /* see above type defs */
149 };
150 typedef struct xen_domctl_getpageframeinfo xen_domctl_getpageframeinfo_t;
151 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo_t);
152 
153 
154 #define XEN_DOMCTL_getpageframeinfo2  8
155 struct xen_domctl_getpageframeinfo2 {
156     /* IN variables. */
157     uint64_t num;
158     /* IN/OUT variables. */
159     XEN_GUEST_HANDLE(ulong) array;
160 };
161 typedef struct xen_domctl_getpageframeinfo2 xen_domctl_getpageframeinfo2_t;
162 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo2_t);
163 
164 
165 /*
166  * Control shadow pagetables operation
167  */
168 #define XEN_DOMCTL_shadow_op         10
169 
170 /* Disable shadow mode. */
171 #define XEN_DOMCTL_SHADOW_OP_OFF         0
172 
173 /* Enable shadow mode (mode contains ORed XEN_DOMCTL_SHADOW_ENABLE_* flags). */
174 #define XEN_DOMCTL_SHADOW_OP_ENABLE      32
175 
176 /* Log-dirty bitmap operations. */
177  /* Return the bitmap and clean internal copy for next round. */
178 #define XEN_DOMCTL_SHADOW_OP_CLEAN       11
179  /* Return the bitmap but do not modify internal copy. */
180 #define XEN_DOMCTL_SHADOW_OP_PEEK        12
181 
182 /* Memory allocation accessors. */
183 #define XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
184 #define XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
185 
186 /* Legacy enable operations. */
187  /* Equiv. to ENABLE with no mode flags. */
188 #define XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
189  /* Equiv. to ENABLE with mode flag ENABLE_LOG_DIRTY. */
190 #define XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
191  /* Equiv. to ENABLE with mode flags ENABLE_REFCOUNT and ENABLE_TRANSLATE. */
192 #define XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
193 
194 /* Mode flags for XEN_DOMCTL_SHADOW_OP_ENABLE. */
195  /*
196   * Shadow pagetables are refcounted: guest does not use explicit mmu
197   * operations nor write-protect its pagetables.
198   */
199 #define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
200  /*
201   * Log pages in a bitmap as they are dirtied.
202   * Used for live relocation to determine which pages must be re-sent.
203   */
204 #define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
205  /*
206   * Automatically translate GPFNs into MFNs.
207   */
208 #define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
209  /*
210   * Xen does not steal virtual address space from the guest.
211   * Requires HVM support.
212   */
213 #define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
214 
215 struct xen_domctl_shadow_op_stats {
216     uint32_t fault_count;
217     uint32_t dirty_count;
218 };
219 typedef struct xen_domctl_shadow_op_stats xen_domctl_shadow_op_stats_t;
220 DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_stats_t);
221 
222 struct xen_domctl_shadow_op {
223     /* IN variables. */
224     uint32_t       op;       /* XEN_DOMCTL_SHADOW_OP_* */
225 
226     /* OP_ENABLE */
227     uint32_t       mode;     /* XEN_DOMCTL_SHADOW_ENABLE_* */
228 
229     /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */
230     uint32_t       mb;       /* Shadow memory allocation in MB */
231 
232     /* OP_PEEK / OP_CLEAN */
233     XEN_GUEST_HANDLE(ulong) dirty_bitmap;
234     uint64_t       pages;    /* Size of buffer. Updated with actual size. */
235     struct xen_domctl_shadow_op_stats stats;
236 };
237 typedef struct xen_domctl_shadow_op xen_domctl_shadow_op_t;
238 DEFINE_XEN_GUEST_HANDLE(xen_domctl_shadow_op_t);
239 
240 
241 #define XEN_DOMCTL_max_mem           11
242 struct xen_domctl_max_mem {
243     /* IN variables. */
244     uint64_t max_memkb;
245 };
246 typedef struct xen_domctl_max_mem xen_domctl_max_mem_t;
247 DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_mem_t);
248 
249 
250 #define XEN_DOMCTL_setvcpucontext    12
251 #define XEN_DOMCTL_getvcpucontext    13
252 struct xen_domctl_vcpucontext {
253     uint32_t              vcpu;                  /* IN */
254     XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt; /* IN/OUT */
255 };
256 typedef struct xen_domctl_vcpucontext xen_domctl_vcpucontext_t;
257 DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpucontext_t);
258 
259 
260 #define XEN_DOMCTL_getvcpuinfo       14
261 struct xen_domctl_getvcpuinfo {
262     /* IN variables. */
263     uint32_t vcpu;
264     /* OUT variables. */
265     uint8_t  online;                  /* currently online (not hotplugged)? */
266     uint8_t  blocked;                 /* blocked waiting for an event? */
267     uint8_t  running;                 /* currently scheduled on its CPU? */
268     uint64_t cpu_time;                /* total cpu time consumed (ns) */
269     uint32_t cpu;                     /* current mapping   */
270 };
271 typedef struct xen_domctl_getvcpuinfo xen_domctl_getvcpuinfo_t;
272 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getvcpuinfo_t);
273 
274 
275 /* Get/set which physical cpus a vcpu can execute on. */
276 #define XEN_DOMCTL_setvcpuaffinity    9
277 #define XEN_DOMCTL_getvcpuaffinity   25
278 struct xen_domctl_vcpuaffinity {
279     uint32_t  vcpu;              /* IN */
280     struct xenctl_cpumap cpumap; /* IN/OUT */
281 };
282 typedef struct xen_domctl_vcpuaffinity xen_domctl_vcpuaffinity_t;
283 DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpuaffinity_t);
284 
285 
286 #define XEN_DOMCTL_max_vcpus         15
287 struct xen_domctl_max_vcpus {
288     uint32_t max;           /* maximum number of vcpus */
289 };
290 typedef struct xen_domctl_max_vcpus xen_domctl_max_vcpus_t;
291 DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t);
292 
293 
294 #define XEN_DOMCTL_scheduler_op      16
295 /* Scheduler types. */
296 #define XEN_SCHEDULER_SEDF     4
297 #define XEN_SCHEDULER_CREDIT   5
298 /* Set or get info? */
299 #define XEN_DOMCTL_SCHEDOP_putinfo 0
300 #define XEN_DOMCTL_SCHEDOP_getinfo 1
301 struct xen_domctl_scheduler_op {
302     uint32_t sched_id;  /* XEN_SCHEDULER_* */
303     uint32_t cmd;       /* XEN_DOMCTL_SCHEDOP_* */
304     union {
305         struct xen_domctl_sched_sedf {
306             uint64_t period;
307             uint64_t slice;
308             uint64_t latency;
309             uint32_t extratime;
310             uint32_t weight;
311         } sedf;
312         struct xen_domctl_sched_credit {
313             uint16_t weight;
314             uint16_t cap;
315         } credit;
316     } u;
317 };
318 typedef struct xen_domctl_scheduler_op xen_domctl_scheduler_op_t;
319 DEFINE_XEN_GUEST_HANDLE(xen_domctl_scheduler_op_t);
320 
321 
322 #define XEN_DOMCTL_setdomainhandle   17
323 struct xen_domctl_setdomainhandle {
324     xen_domain_handle_t handle;
325 };
326 typedef struct xen_domctl_setdomainhandle xen_domctl_setdomainhandle_t;
327 DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdomainhandle_t);
328 
329 
330 #define XEN_DOMCTL_setdebugging      18
331 struct xen_domctl_setdebugging {
332     uint8_t enable;
333 };
334 typedef struct xen_domctl_setdebugging xen_domctl_setdebugging_t;
335 DEFINE_XEN_GUEST_HANDLE(xen_domctl_setdebugging_t);
336 
337 
338 #define XEN_DOMCTL_irq_permission    19
339 struct xen_domctl_irq_permission {
340     uint8_t pirq;
341     uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
342 };
343 typedef struct xen_domctl_irq_permission xen_domctl_irq_permission_t;
344 DEFINE_XEN_GUEST_HANDLE(xen_domctl_irq_permission_t);
345 
346 
347 #define XEN_DOMCTL_iomem_permission  20
348 struct xen_domctl_iomem_permission {
349     uint64_t first_mfn;       /* first page (physical page number) in range */
350     uint64_t nr_mfns;         /* number of pages in range (>0) */
351     uint8_t  allow_access;    /* allow (!0) or deny (0) access to range? */
352 };
353 typedef struct xen_domctl_iomem_permission xen_domctl_iomem_permission_t;
354 DEFINE_XEN_GUEST_HANDLE(xen_domctl_iomem_permission_t);
355 
356 
357 #define XEN_DOMCTL_ioport_permission 21
358 struct xen_domctl_ioport_permission {
359     uint32_t first_port;              /* first port int range */
360     uint32_t nr_ports;                /* size of port range */
361     uint8_t  allow_access;            /* allow or deny access to range? */
362 };
363 typedef struct xen_domctl_ioport_permission xen_domctl_ioport_permission_t;
364 DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_permission_t);
365 
366 #define XEN_DOMCTL_hypercall_init    22
367 struct xen_domctl_hypercall_init {
368     uint64_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 #define XEN_DOMCTL_arch_setup        23
374 #define _XEN_DOMAINSETUP_hvm_guest 0
375 #define XEN_DOMAINSETUP_hvm_guest  (1UL<<_XEN_DOMAINSETUP_hvm_guest)
376 #define _XEN_DOMAINSETUP_query 1 /* Get parameters (for save)  */
377 #define XEN_DOMAINSETUP_query  (1UL<<_XEN_DOMAINSETUP_query)
378 typedef struct xen_domctl_arch_setup {
379     uint64_t flags;      /* XEN_DOMAINSETUP_* */
380 #ifdef __ia64__
381     uint64_t bp;            /* mpaddr of boot param area */
382     uint64_t maxmem;        /* Highest memory address for MDT.  */
383     uint64_t xsi_va;        /* Xen shared_info area virtual address.  */
384     uint32_t hypercall_imm; /* Break imm for Xen hypercalls.  */
385 #endif
386 } xen_domctl_arch_setup_t;
387 DEFINE_XEN_GUEST_HANDLE(xen_domctl_arch_setup_t);
388 
389 #define XEN_DOMCTL_settimeoffset     24
390 struct xen_domctl_settimeoffset {
391     int32_t  time_offset_seconds; /* applied to domain wallclock time */
392 };
393 typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t;
394 DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t);
395 
396 #define XEN_DOMCTL_real_mode_area     26
397 struct xen_domctl_real_mode_area {
398     uint32_t log; /* log2 of Real Mode Area size */
399 };
400 typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
401 DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
402 
403 struct xen_domctl {
404     uint32_t cmd;
405     uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
406     domid_t  domain;
407     union {
408         struct xen_domctl_createdomain      createdomain;
409         struct xen_domctl_getdomaininfo     getdomaininfo;
410         struct xen_domctl_getmemlist        getmemlist;
411         struct xen_domctl_getpageframeinfo  getpageframeinfo;
412         struct xen_domctl_getpageframeinfo2 getpageframeinfo2;
413         struct xen_domctl_vcpuaffinity      vcpuaffinity;
414         struct xen_domctl_shadow_op         shadow_op;
415         struct xen_domctl_max_mem           max_mem;
416         struct xen_domctl_vcpucontext       vcpucontext;
417         struct xen_domctl_getvcpuinfo       getvcpuinfo;
418         struct xen_domctl_max_vcpus         max_vcpus;
419         struct xen_domctl_scheduler_op      scheduler_op;
420         struct xen_domctl_setdomainhandle   setdomainhandle;
421         struct xen_domctl_setdebugging      setdebugging;
422         struct xen_domctl_irq_permission    irq_permission;
423         struct xen_domctl_iomem_permission  iomem_permission;
424         struct xen_domctl_ioport_permission ioport_permission;
425         struct xen_domctl_hypercall_init    hypercall_init;
426         struct xen_domctl_arch_setup        arch_setup;
427         struct xen_domctl_settimeoffset     settimeoffset;
428         struct xen_domctl_real_mode_area    real_mode_area;
429         uint8_t                             pad[128];
430     } u;
431 };
432 typedef struct xen_domctl xen_domctl_t;
433 DEFINE_XEN_GUEST_HANDLE(xen_domctl_t);
434 
435 #endif /* __XEN_PUBLIC_DOMCTL_H__ */
436 
437 /*
438  * Local variables:
439  * mode: C
440  * c-set-style: "BSD"
441  * c-basic-offset: 4
442  * tab-width: 4
443  * indent-tabs-mode: nil
444  * End:
445  */
446