1 | /****************************************************************************** |
---|
2 | * xenctrl.h |
---|
3 | * |
---|
4 | * A library for low-level access to the Xen control interfaces. |
---|
5 | * |
---|
6 | * Copyright (c) 2003-2004, K A Fraser. |
---|
7 | * |
---|
8 | * xc_gnttab functions: |
---|
9 | * Copyright (c) 2007, D G Murray <Derek.Murray@cl.cam.ac.uk> |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef XENCTRL_H |
---|
13 | #define XENCTRL_H |
---|
14 | |
---|
15 | /* Tell the Xen public headers we are a user-space tools build. */ |
---|
16 | #ifndef __XEN_TOOLS__ |
---|
17 | #define __XEN_TOOLS__ 1 |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <stddef.h> |
---|
21 | #include <stdint.h> |
---|
22 | #include <xen/xen.h> |
---|
23 | #include <xen/domctl.h> |
---|
24 | #include <xen/sysctl.h> |
---|
25 | #include <xen/version.h> |
---|
26 | #include <xen/event_channel.h> |
---|
27 | #include <xen/sched.h> |
---|
28 | #include <xen/memory.h> |
---|
29 | #include <xen/acm.h> |
---|
30 | #include <xen/acm_ops.h> |
---|
31 | |
---|
32 | #ifdef __ia64__ |
---|
33 | #define XC_PAGE_SHIFT 14 |
---|
34 | #else |
---|
35 | #define XC_PAGE_SHIFT 12 |
---|
36 | #endif |
---|
37 | #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT) |
---|
38 | #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1)) |
---|
39 | |
---|
40 | /* |
---|
41 | * DEFINITIONS FOR CPU BARRIERS |
---|
42 | */ |
---|
43 | |
---|
44 | #if defined(__i386__) |
---|
45 | #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" ) |
---|
46 | #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" ) |
---|
47 | #define wmb() __asm__ __volatile__ ( "" : : : "memory") |
---|
48 | #elif defined(__x86_64__) |
---|
49 | #define mb() __asm__ __volatile__ ( "mfence" : : : "memory") |
---|
50 | #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory") |
---|
51 | #define wmb() __asm__ __volatile__ ( "" : : : "memory") |
---|
52 | #elif defined(__ia64__) |
---|
53 | #define mb() __asm__ __volatile__ ("mf" ::: "memory") |
---|
54 | #define rmb() __asm__ __volatile__ ("mf" ::: "memory") |
---|
55 | #define wmb() __asm__ __volatile__ ("mf" ::: "memory") |
---|
56 | #elif defined(__powerpc__) |
---|
57 | /* XXX loosen these up later */ |
---|
58 | #define mb() __asm__ __volatile__ ("sync" : : : "memory") |
---|
59 | #define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */ |
---|
60 | #define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */ |
---|
61 | #else |
---|
62 | #error "Define barriers" |
---|
63 | #endif |
---|
64 | |
---|
65 | /* |
---|
66 | * INITIALIZATION FUNCTIONS |
---|
67 | */ |
---|
68 | |
---|
69 | /** |
---|
70 | * This function opens a handle to the hypervisor interface. This function can |
---|
71 | * be called multiple times within a single process. Multiple processes can |
---|
72 | * have an open hypervisor interface at the same time. |
---|
73 | * |
---|
74 | * Each call to this function should have a corresponding call to |
---|
75 | * xc_interface_close(). |
---|
76 | * |
---|
77 | * This function can fail if the caller does not have superuser permission or |
---|
78 | * if a Xen-enabled kernel is not currently running. |
---|
79 | * |
---|
80 | * @return a handle to the hypervisor interface or -1 on failure |
---|
81 | */ |
---|
82 | int xc_interface_open(void); |
---|
83 | |
---|
84 | /** |
---|
85 | * This function closes an open hypervisor interface. |
---|
86 | * |
---|
87 | * This function can fail if the handle does not represent an open interface or |
---|
88 | * if there were problems closing the interface. |
---|
89 | * |
---|
90 | * @parm xc_handle a handle to an open hypervisor interface |
---|
91 | * @return 0 on success, -1 otherwise. |
---|
92 | */ |
---|
93 | int xc_interface_close(int xc_handle); |
---|
94 | |
---|
95 | /* |
---|
96 | * KERNEL INTERFACES |
---|
97 | */ |
---|
98 | |
---|
99 | /* |
---|
100 | * Resolve a kernel device name (e.g., "evtchn", "blktap0") into a kernel |
---|
101 | * device number. Returns -1 on error (and sets errno). |
---|
102 | */ |
---|
103 | int xc_find_device_number(const char *name); |
---|
104 | |
---|
105 | /* |
---|
106 | * DOMAIN DEBUGGING FUNCTIONS |
---|
107 | */ |
---|
108 | |
---|
109 | typedef struct xc_core_header { |
---|
110 | unsigned int xch_magic; |
---|
111 | unsigned int xch_nr_vcpus; |
---|
112 | unsigned int xch_nr_pages; |
---|
113 | unsigned int xch_ctxt_offset; |
---|
114 | unsigned int xch_index_offset; |
---|
115 | unsigned int xch_pages_offset; |
---|
116 | } xc_core_header_t; |
---|
117 | |
---|
118 | #define XC_CORE_MAGIC 0xF00FEBED |
---|
119 | #define XC_CORE_MAGIC_HVM 0xF00FEBEE |
---|
120 | |
---|
121 | #ifdef __linux__ |
---|
122 | |
---|
123 | #include <sys/ptrace.h> |
---|
124 | #include <thread_db.h> |
---|
125 | |
---|
126 | typedef void (*thr_ev_handler_t)(long); |
---|
127 | |
---|
128 | void xc_register_event_handler( |
---|
129 | thr_ev_handler_t h, |
---|
130 | td_event_e e); |
---|
131 | |
---|
132 | long xc_ptrace( |
---|
133 | int xc_handle, |
---|
134 | enum __ptrace_request request, |
---|
135 | uint32_t domid, |
---|
136 | long addr, |
---|
137 | long data); |
---|
138 | |
---|
139 | int xc_waitdomain( |
---|
140 | int xc_handle, |
---|
141 | int domain, |
---|
142 | int *status, |
---|
143 | int options); |
---|
144 | |
---|
145 | #endif /* __linux__ */ |
---|
146 | |
---|
147 | /* |
---|
148 | * DOMAIN MANAGEMENT FUNCTIONS |
---|
149 | */ |
---|
150 | |
---|
151 | typedef struct xc_dominfo { |
---|
152 | uint32_t domid; |
---|
153 | uint32_t ssidref; |
---|
154 | unsigned int dying:1, crashed:1, shutdown:1, |
---|
155 | paused:1, blocked:1, running:1, |
---|
156 | hvm:1; |
---|
157 | unsigned int shutdown_reason; /* only meaningful if shutdown==1 */ |
---|
158 | unsigned long nr_pages; |
---|
159 | unsigned long shared_info_frame; |
---|
160 | uint64_t cpu_time; |
---|
161 | unsigned long max_memkb; |
---|
162 | unsigned int nr_online_vcpus; |
---|
163 | unsigned int max_vcpu_id; |
---|
164 | xen_domain_handle_t handle; |
---|
165 | } xc_dominfo_t; |
---|
166 | |
---|
167 | typedef xen_domctl_getdomaininfo_t xc_domaininfo_t; |
---|
168 | int xc_domain_create(int xc_handle, |
---|
169 | uint32_t ssidref, |
---|
170 | xen_domain_handle_t handle, |
---|
171 | uint32_t flags, |
---|
172 | uint32_t *pdomid); |
---|
173 | |
---|
174 | |
---|
175 | /* Functions to produce a dump of a given domain |
---|
176 | * xc_domain_dumpcore - produces a dump to a specified file |
---|
177 | * xc_domain_dumpcore_via_callback - produces a dump, using a specified |
---|
178 | * callback function |
---|
179 | */ |
---|
180 | int xc_domain_dumpcore(int xc_handle, |
---|
181 | uint32_t domid, |
---|
182 | const char *corename); |
---|
183 | |
---|
184 | /* Define the callback function type for xc_domain_dumpcore_via_callback. |
---|
185 | * |
---|
186 | * This function is called by the coredump code for every "write", |
---|
187 | * and passes an opaque object for the use of the function and |
---|
188 | * created by the caller of xc_domain_dumpcore_via_callback. |
---|
189 | */ |
---|
190 | typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length); |
---|
191 | |
---|
192 | int xc_domain_dumpcore_via_callback(int xc_handle, |
---|
193 | uint32_t domid, |
---|
194 | void *arg, |
---|
195 | dumpcore_rtn_t dump_rtn); |
---|
196 | |
---|
197 | /* |
---|
198 | * This function sets the maximum number of vcpus that a domain may create. |
---|
199 | * |
---|
200 | * @parm xc_handle a handle to an open hypervisor interface. |
---|
201 | * @parm domid the domain id in which vcpus are to be created. |
---|
202 | * @parm max the maximum number of vcpus that the domain may create. |
---|
203 | * @return 0 on success, -1 on failure. |
---|
204 | */ |
---|
205 | int xc_domain_max_vcpus(int xc_handle, |
---|
206 | uint32_t domid, |
---|
207 | unsigned int max); |
---|
208 | |
---|
209 | /** |
---|
210 | * This function pauses a domain. A paused domain still exists in memory |
---|
211 | * however it does not receive any timeslices from the hypervisor. |
---|
212 | * |
---|
213 | * @parm xc_handle a handle to an open hypervisor interface |
---|
214 | * @parm domid the domain id to pause |
---|
215 | * @return 0 on success, -1 on failure. |
---|
216 | */ |
---|
217 | int xc_domain_pause(int xc_handle, |
---|
218 | uint32_t domid); |
---|
219 | /** |
---|
220 | * This function unpauses a domain. The domain should have been previously |
---|
221 | * paused. |
---|
222 | * |
---|
223 | * @parm xc_handle a handle to an open hypervisor interface |
---|
224 | * @parm domid the domain id to unpause |
---|
225 | * return 0 on success, -1 on failure |
---|
226 | */ |
---|
227 | int xc_domain_unpause(int xc_handle, |
---|
228 | uint32_t domid); |
---|
229 | |
---|
230 | /** |
---|
231 | * This function will destroy a domain. Destroying a domain removes the domain |
---|
232 | * completely from memory. This function should be called after sending the |
---|
233 | * domain a SHUTDOWN control message to free up the domain resources. |
---|
234 | * |
---|
235 | * @parm xc_handle a handle to an open hypervisor interface |
---|
236 | * @parm domid the domain id to destroy |
---|
237 | * @return 0 on success, -1 on failure |
---|
238 | */ |
---|
239 | int xc_domain_destroy(int xc_handle, |
---|
240 | uint32_t domid); |
---|
241 | |
---|
242 | |
---|
243 | /** |
---|
244 | * This function resumes a suspended domain. The domain should have |
---|
245 | * been previously suspended. |
---|
246 | * |
---|
247 | * @parm xc_handle a handle to an open hypervisor interface |
---|
248 | * @parm domid the domain id to resume |
---|
249 | * @parm fast use cooperative resume (guest must support this) |
---|
250 | * return 0 on success, -1 on failure |
---|
251 | */ |
---|
252 | int xc_domain_resume(int xc_handle, |
---|
253 | uint32_t domid, |
---|
254 | int fast); |
---|
255 | |
---|
256 | /** |
---|
257 | * This function will shutdown a domain. This is intended for use in |
---|
258 | * fully-virtualized domains where this operation is analogous to the |
---|
259 | * sched_op operations in a paravirtualized domain. The caller is |
---|
260 | * expected to give the reason for the shutdown. |
---|
261 | * |
---|
262 | * @parm xc_handle a handle to an open hypervisor interface |
---|
263 | * @parm domid the domain id to destroy |
---|
264 | * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown |
---|
265 | * @return 0 on success, -1 on failure |
---|
266 | */ |
---|
267 | int xc_domain_shutdown(int xc_handle, |
---|
268 | uint32_t domid, |
---|
269 | int reason); |
---|
270 | |
---|
271 | int xc_vcpu_setaffinity(int xc_handle, |
---|
272 | uint32_t domid, |
---|
273 | int vcpu, |
---|
274 | uint64_t cpumap); |
---|
275 | int xc_vcpu_getaffinity(int xc_handle, |
---|
276 | uint32_t domid, |
---|
277 | int vcpu, |
---|
278 | uint64_t *cpumap); |
---|
279 | |
---|
280 | /** |
---|
281 | * This function will return information about one or more domains. It is |
---|
282 | * designed to iterate over the list of domains. If a single domain is |
---|
283 | * requested, this function will return the next domain in the list - if |
---|
284 | * one exists. It is, therefore, important in this case to make sure the |
---|
285 | * domain requested was the one returned. |
---|
286 | * |
---|
287 | * @parm xc_handle a handle to an open hypervisor interface |
---|
288 | * @parm first_domid the first domain to enumerate information from. Domains |
---|
289 | * are currently enumerate in order of creation. |
---|
290 | * @parm max_doms the number of elements in info |
---|
291 | * @parm info an array of max_doms size that will contain the information for |
---|
292 | * the enumerated domains. |
---|
293 | * @return the number of domains enumerated or -1 on error |
---|
294 | */ |
---|
295 | int xc_domain_getinfo(int xc_handle, |
---|
296 | uint32_t first_domid, |
---|
297 | unsigned int max_doms, |
---|
298 | xc_dominfo_t *info); |
---|
299 | |
---|
300 | |
---|
301 | /** |
---|
302 | * This function will set the execution context for the specified vcpu. |
---|
303 | * |
---|
304 | * @parm xc_handle a handle to an open hypervisor interface |
---|
305 | * @parm domid the domain to set the vcpu context for |
---|
306 | * @parm vcpu the vcpu number for the context |
---|
307 | * @parm ctxt pointer to the the cpu context with the values to set |
---|
308 | * @return the number of domains enumerated or -1 on error |
---|
309 | */ |
---|
310 | int xc_vcpu_setcontext(int xc_handle, |
---|
311 | uint32_t domid, |
---|
312 | uint32_t vcpu, |
---|
313 | vcpu_guest_context_t *ctxt); |
---|
314 | /** |
---|
315 | * This function will return information about one or more domains, using a |
---|
316 | * single hypercall. The domain information will be stored into the supplied |
---|
317 | * array of xc_domaininfo_t structures. |
---|
318 | * |
---|
319 | * @parm xc_handle a handle to an open hypervisor interface |
---|
320 | * @parm first_domain the first domain to enumerate information from. |
---|
321 | * Domains are currently enumerate in order of creation. |
---|
322 | * @parm max_domains the number of elements in info |
---|
323 | * @parm info an array of max_doms size that will contain the information for |
---|
324 | * the enumerated domains. |
---|
325 | * @return the number of domains enumerated or -1 on error |
---|
326 | */ |
---|
327 | int xc_domain_getinfolist(int xc_handle, |
---|
328 | uint32_t first_domain, |
---|
329 | unsigned int max_domains, |
---|
330 | xc_domaininfo_t *info); |
---|
331 | |
---|
332 | /** |
---|
333 | * This function returns information about the context of a hvm domain |
---|
334 | * @parm xc_handle a handle to an open hypervisor interface |
---|
335 | * @parm domid the domain to get information from |
---|
336 | * @parm ctxt_buf a pointer to a structure to store the execution context of |
---|
337 | * the hvm domain |
---|
338 | * @parm size the size of ctxt_buf in bytes |
---|
339 | * @return 0 on success, -1 on failure |
---|
340 | */ |
---|
341 | int xc_domain_hvm_getcontext(int xc_handle, |
---|
342 | uint32_t domid, |
---|
343 | uint8_t *ctxt_buf, |
---|
344 | uint32_t size); |
---|
345 | |
---|
346 | /** |
---|
347 | * This function will set the context for hvm domain |
---|
348 | * |
---|
349 | * @parm xc_handle a handle to an open hypervisor interface |
---|
350 | * @parm domid the domain to set the hvm domain context for |
---|
351 | * @parm hvm_ctxt pointer to the the hvm context with the values to set |
---|
352 | * @parm size the size of hvm_ctxt in bytes |
---|
353 | * @return 0 on success, -1 on failure |
---|
354 | */ |
---|
355 | int xc_domain_hvm_setcontext(int xc_handle, |
---|
356 | uint32_t domid, |
---|
357 | uint8_t *hvm_ctxt, |
---|
358 | uint32_t size); |
---|
359 | |
---|
360 | /** |
---|
361 | * This function returns information about the execution context of a |
---|
362 | * particular vcpu of a domain. |
---|
363 | * |
---|
364 | * @parm xc_handle a handle to an open hypervisor interface |
---|
365 | * @parm domid the domain to get information from |
---|
366 | * @parm vcpu the vcpu number |
---|
367 | * @parm ctxt a pointer to a structure to store the execution context of the |
---|
368 | * domain |
---|
369 | * @return 0 on success, -1 on failure |
---|
370 | */ |
---|
371 | int xc_vcpu_getcontext(int xc_handle, |
---|
372 | uint32_t domid, |
---|
373 | uint32_t vcpu, |
---|
374 | vcpu_guest_context_t *ctxt); |
---|
375 | |
---|
376 | typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t; |
---|
377 | int xc_vcpu_getinfo(int xc_handle, |
---|
378 | uint32_t domid, |
---|
379 | uint32_t vcpu, |
---|
380 | xc_vcpuinfo_t *info); |
---|
381 | |
---|
382 | int xc_domain_setcpuweight(int xc_handle, |
---|
383 | uint32_t domid, |
---|
384 | float weight); |
---|
385 | long long xc_domain_get_cpu_usage(int xc_handle, |
---|
386 | domid_t domid, |
---|
387 | int vcpu); |
---|
388 | |
---|
389 | int xc_domain_sethandle(int xc_handle, uint32_t domid, |
---|
390 | xen_domain_handle_t handle); |
---|
391 | |
---|
392 | typedef xen_domctl_shadow_op_stats_t xc_shadow_op_stats_t; |
---|
393 | int xc_shadow_control(int xc_handle, |
---|
394 | uint32_t domid, |
---|
395 | unsigned int sop, |
---|
396 | unsigned long *dirty_bitmap, |
---|
397 | unsigned long pages, |
---|
398 | unsigned long *mb, |
---|
399 | uint32_t mode, |
---|
400 | xc_shadow_op_stats_t *stats); |
---|
401 | |
---|
402 | int xc_sedf_domain_set(int xc_handle, |
---|
403 | uint32_t domid, |
---|
404 | uint64_t period, uint64_t slice, |
---|
405 | uint64_t latency, uint16_t extratime, |
---|
406 | uint16_t weight); |
---|
407 | |
---|
408 | int xc_sedf_domain_get(int xc_handle, |
---|
409 | uint32_t domid, |
---|
410 | uint64_t* period, uint64_t *slice, |
---|
411 | uint64_t *latency, uint16_t *extratime, |
---|
412 | uint16_t *weight); |
---|
413 | |
---|
414 | int xc_sched_credit_domain_set(int xc_handle, |
---|
415 | uint32_t domid, |
---|
416 | struct xen_domctl_sched_credit *sdom); |
---|
417 | |
---|
418 | int xc_sched_credit_domain_get(int xc_handle, |
---|
419 | uint32_t domid, |
---|
420 | struct xen_domctl_sched_credit *sdom); |
---|
421 | |
---|
422 | /** |
---|
423 | * This function sends a trigger to a domain. |
---|
424 | * |
---|
425 | * @parm xc_handle a handle to an open hypervisor interface |
---|
426 | * @parm domid the domain id to send trigger |
---|
427 | * @parm trigger the trigger type |
---|
428 | * @parm vcpu the vcpu number to send trigger |
---|
429 | * return 0 on success, -1 on failure |
---|
430 | */ |
---|
431 | int xc_domain_send_trigger(int xc_handle, |
---|
432 | uint32_t domid, |
---|
433 | uint32_t trigger, |
---|
434 | uint32_t vcpu); |
---|
435 | |
---|
436 | /* |
---|
437 | * EVENT CHANNEL FUNCTIONS |
---|
438 | */ |
---|
439 | |
---|
440 | /** |
---|
441 | * This function allocates an unbound port. Ports are named endpoints used for |
---|
442 | * interdomain communication. This function is most useful in opening a |
---|
443 | * well-known port within a domain to receive events on. |
---|
444 | * |
---|
445 | * NOTE: If you are allocating a *local* unbound port, you probably want to |
---|
446 | * use xc_evtchn_bind_unbound_port(). This function is intended for allocating |
---|
447 | * ports *only* during domain creation. |
---|
448 | * |
---|
449 | * @parm xc_handle a handle to an open hypervisor interface |
---|
450 | * @parm dom the ID of the local domain (the 'allocatee') |
---|
451 | * @parm remote_dom the ID of the domain who will later bind |
---|
452 | * @return allocated port (in @dom) on success, -1 on failure |
---|
453 | */ |
---|
454 | int xc_evtchn_alloc_unbound(int xc_handle, |
---|
455 | uint32_t dom, |
---|
456 | uint32_t remote_dom); |
---|
457 | |
---|
458 | int xc_evtchn_reset(int xc_handle, |
---|
459 | uint32_t dom); |
---|
460 | |
---|
461 | int xc_physdev_pci_access_modify(int xc_handle, |
---|
462 | uint32_t domid, |
---|
463 | int bus, |
---|
464 | int dev, |
---|
465 | int func, |
---|
466 | int enable); |
---|
467 | |
---|
468 | int xc_readconsolering(int xc_handle, |
---|
469 | char **pbuffer, |
---|
470 | unsigned int *pnr_chars, |
---|
471 | int clear); |
---|
472 | |
---|
473 | int xc_send_debug_keys(int xc_handle, char *keys); |
---|
474 | |
---|
475 | typedef xen_sysctl_physinfo_t xc_physinfo_t; |
---|
476 | int xc_physinfo(int xc_handle, |
---|
477 | xc_physinfo_t *info); |
---|
478 | |
---|
479 | int xc_sched_id(int xc_handle, |
---|
480 | int *sched_id); |
---|
481 | |
---|
482 | int xc_domain_setmaxmem(int xc_handle, |
---|
483 | uint32_t domid, |
---|
484 | unsigned int max_memkb); |
---|
485 | |
---|
486 | int xc_domain_set_memmap_limit(int xc_handle, |
---|
487 | uint32_t domid, |
---|
488 | unsigned long map_limitkb); |
---|
489 | |
---|
490 | int xc_domain_set_time_offset(int xc_handle, |
---|
491 | uint32_t domid, |
---|
492 | int32_t time_offset_seconds); |
---|
493 | |
---|
494 | int xc_domain_memory_increase_reservation(int xc_handle, |
---|
495 | uint32_t domid, |
---|
496 | unsigned long nr_extents, |
---|
497 | unsigned int extent_order, |
---|
498 | unsigned int address_bits, |
---|
499 | xen_pfn_t *extent_start); |
---|
500 | |
---|
501 | int xc_domain_memory_decrease_reservation(int xc_handle, |
---|
502 | uint32_t domid, |
---|
503 | unsigned long nr_extents, |
---|
504 | unsigned int extent_order, |
---|
505 | xen_pfn_t *extent_start); |
---|
506 | |
---|
507 | int xc_domain_memory_populate_physmap(int xc_handle, |
---|
508 | uint32_t domid, |
---|
509 | unsigned long nr_extents, |
---|
510 | unsigned int extent_order, |
---|
511 | unsigned int address_bits, |
---|
512 | xen_pfn_t *extent_start); |
---|
513 | |
---|
514 | int xc_domain_ioport_permission(int xc_handle, |
---|
515 | uint32_t domid, |
---|
516 | uint32_t first_port, |
---|
517 | uint32_t nr_ports, |
---|
518 | uint32_t allow_access); |
---|
519 | |
---|
520 | int xc_domain_irq_permission(int xc_handle, |
---|
521 | uint32_t domid, |
---|
522 | uint8_t pirq, |
---|
523 | uint8_t allow_access); |
---|
524 | |
---|
525 | int xc_domain_iomem_permission(int xc_handle, |
---|
526 | uint32_t domid, |
---|
527 | unsigned long first_mfn, |
---|
528 | unsigned long nr_mfns, |
---|
529 | uint8_t allow_access); |
---|
530 | |
---|
531 | unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid, |
---|
532 | unsigned long mfn); |
---|
533 | |
---|
534 | typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t; |
---|
535 | typedef xen_sysctl_perfc_val_t xc_perfc_val_t; |
---|
536 | /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val |
---|
537 | arrays. */ |
---|
538 | int xc_perfc_control(int xc_handle, |
---|
539 | uint32_t op, |
---|
540 | xc_perfc_desc_t *desc, |
---|
541 | xc_perfc_val_t *val, |
---|
542 | int *nbr_desc, |
---|
543 | int *nbr_val); |
---|
544 | |
---|
545 | /** |
---|
546 | * Memory maps a range within one domain to a local address range. Mappings |
---|
547 | * should be unmapped with munmap and should follow the same rules as mmap |
---|
548 | * regarding page alignment. Returns NULL on failure. |
---|
549 | * |
---|
550 | * In Linux, the ring queue for the control channel is accessible by mapping |
---|
551 | * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure |
---|
552 | * stored there is of type control_if_t. |
---|
553 | * |
---|
554 | * @parm xc_handle a handle on an open hypervisor interface |
---|
555 | * @parm dom the domain to map memory from |
---|
556 | * @parm size the amount of memory to map (in multiples of page size) |
---|
557 | * @parm prot same flag as in mmap(). |
---|
558 | * @parm mfn the frame address to map. |
---|
559 | */ |
---|
560 | void *xc_map_foreign_range(int xc_handle, uint32_t dom, |
---|
561 | int size, int prot, |
---|
562 | unsigned long mfn ); |
---|
563 | |
---|
564 | void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, |
---|
565 | xen_pfn_t *arr, int num ); |
---|
566 | |
---|
567 | /** |
---|
568 | * Translates a virtual address in the context of a given domain and |
---|
569 | * vcpu returning the machine page frame number of the associated |
---|
570 | * page. |
---|
571 | * |
---|
572 | * @parm xc_handle a handle on an open hypervisor interface |
---|
573 | * @parm dom the domain to perform the translation in |
---|
574 | * @parm vcpu the vcpu to perform the translation on |
---|
575 | * @parm virt the virtual address to translate |
---|
576 | */ |
---|
577 | unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom, |
---|
578 | int vcpu, unsigned long long virt); |
---|
579 | |
---|
580 | |
---|
581 | /** |
---|
582 | * DEPRECATED. Avoid using this, as it does not correctly account for PFNs |
---|
583 | * without a backing MFN. |
---|
584 | */ |
---|
585 | int xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf, |
---|
586 | unsigned long max_pfns); |
---|
587 | |
---|
588 | unsigned long xc_ia64_fpsr_default(void); |
---|
589 | |
---|
590 | int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid, |
---|
591 | xen_pfn_t *pfn_buf, |
---|
592 | unsigned int start_page, unsigned int nr_pages); |
---|
593 | |
---|
594 | int xc_copy_to_domain_page(int xc_handle, uint32_t domid, |
---|
595 | unsigned long dst_pfn, const char *src_page); |
---|
596 | |
---|
597 | int xc_clear_domain_page(int xc_handle, uint32_t domid, |
---|
598 | unsigned long dst_pfn); |
---|
599 | |
---|
600 | long xc_get_max_pages(int xc_handle, uint32_t domid); |
---|
601 | |
---|
602 | int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops, |
---|
603 | domid_t dom); |
---|
604 | |
---|
605 | int xc_memory_op(int xc_handle, int cmd, void *arg); |
---|
606 | |
---|
607 | int xc_get_pfn_type_batch(int xc_handle, uint32_t dom, |
---|
608 | int num, uint32_t *arr); |
---|
609 | |
---|
610 | |
---|
611 | /* Get current total pages allocated to a domain. */ |
---|
612 | long xc_get_tot_pages(int xc_handle, uint32_t domid); |
---|
613 | |
---|
614 | |
---|
615 | /* |
---|
616 | * Trace Buffer Operations |
---|
617 | */ |
---|
618 | |
---|
619 | /** |
---|
620 | * xc_tbuf_enable - enable tracing buffers |
---|
621 | * |
---|
622 | * @parm xc_handle a handle to an open hypervisor interface |
---|
623 | * @parm cnt size of tracing buffers to create (in pages) |
---|
624 | * @parm mfn location to store mfn of the trace buffers to |
---|
625 | * @parm size location to store the size (in bytes) of a trace buffer to |
---|
626 | * |
---|
627 | * Gets the machine address of the trace pointer area and the size of the |
---|
628 | * per CPU buffers. |
---|
629 | */ |
---|
630 | int xc_tbuf_enable(int xc_handle, unsigned long pages, |
---|
631 | unsigned long *mfn, unsigned long *size); |
---|
632 | |
---|
633 | /* |
---|
634 | * Disable tracing buffers. |
---|
635 | */ |
---|
636 | int xc_tbuf_disable(int xc_handle); |
---|
637 | |
---|
638 | /** |
---|
639 | * This function sets the size of the trace buffers. Setting the size |
---|
640 | * is currently a one-shot operation that may be performed either at boot |
---|
641 | * time or via this interface, not both. The buffer size must be set before |
---|
642 | * enabling tracing. |
---|
643 | * |
---|
644 | * @parm xc_handle a handle to an open hypervisor interface |
---|
645 | * @parm size the size in pages per cpu for the trace buffers |
---|
646 | * @return 0 on success, -1 on failure. |
---|
647 | */ |
---|
648 | int xc_tbuf_set_size(int xc_handle, unsigned long size); |
---|
649 | |
---|
650 | /** |
---|
651 | * This function retrieves the current size of the trace buffers. |
---|
652 | * Note that the size returned is in terms of bytes, not pages. |
---|
653 | |
---|
654 | * @parm xc_handle a handle to an open hypervisor interface |
---|
655 | * @parm size will contain the size in bytes for the trace buffers |
---|
656 | * @return 0 on success, -1 on failure. |
---|
657 | */ |
---|
658 | int xc_tbuf_get_size(int xc_handle, unsigned long *size); |
---|
659 | |
---|
660 | int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask); |
---|
661 | |
---|
662 | int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask); |
---|
663 | |
---|
664 | int xc_domctl(int xc_handle, struct xen_domctl *domctl); |
---|
665 | int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl); |
---|
666 | |
---|
667 | int xc_version(int xc_handle, int cmd, void *arg); |
---|
668 | |
---|
669 | int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size); |
---|
670 | |
---|
671 | /* |
---|
672 | * Return a handle to the event channel driver, or -1 on failure, in which case |
---|
673 | * errno will be set appropriately. |
---|
674 | */ |
---|
675 | int xc_evtchn_open(void); |
---|
676 | |
---|
677 | /* |
---|
678 | * Close a handle previously allocated with xc_evtchn_open(). |
---|
679 | */ |
---|
680 | int xc_evtchn_close(int xce_handle); |
---|
681 | |
---|
682 | /* |
---|
683 | * Return an fd that can be select()ed on for further calls to |
---|
684 | * xc_evtchn_pending(). |
---|
685 | */ |
---|
686 | int xc_evtchn_fd(int xce_handle); |
---|
687 | |
---|
688 | /* |
---|
689 | * Notify the given event channel. Returns -1 on failure, in which case |
---|
690 | * errno will be set appropriately. |
---|
691 | */ |
---|
692 | int xc_evtchn_notify(int xce_handle, evtchn_port_t port); |
---|
693 | |
---|
694 | /* |
---|
695 | * Returns a new event port awaiting interdomain connection from the given |
---|
696 | * domain ID, or -1 on failure, in which case errno will be set appropriately. |
---|
697 | */ |
---|
698 | evtchn_port_t xc_evtchn_bind_unbound_port(int xce_handle, int domid); |
---|
699 | |
---|
700 | /* |
---|
701 | * Returns a new event port bound to the remote port for the given domain ID, |
---|
702 | * or -1 on failure, in which case errno will be set appropriately. |
---|
703 | */ |
---|
704 | evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid, |
---|
705 | evtchn_port_t remote_port); |
---|
706 | |
---|
707 | /* |
---|
708 | * Unbind the given event channel. Returns -1 on failure, in which case errno |
---|
709 | * will be set appropriately. |
---|
710 | */ |
---|
711 | int xc_evtchn_unbind(int xce_handle, evtchn_port_t port); |
---|
712 | |
---|
713 | /* |
---|
714 | * Bind an event channel to the given VIRQ. Returns the event channel bound to |
---|
715 | * the VIRQ, or -1 on failure, in which case errno will be set appropriately. |
---|
716 | */ |
---|
717 | evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq); |
---|
718 | |
---|
719 | /* |
---|
720 | * Return the next event channel to become pending, or -1 on failure, in which |
---|
721 | * case errno will be set appropriately. |
---|
722 | */ |
---|
723 | evtchn_port_t xc_evtchn_pending(int xce_handle); |
---|
724 | |
---|
725 | /* |
---|
726 | * Unmask the given event channel. Returns -1 on failure, in which case errno |
---|
727 | * will be set appropriately. |
---|
728 | */ |
---|
729 | int xc_evtchn_unmask(int xce_handle, evtchn_port_t port); |
---|
730 | |
---|
731 | /************************** |
---|
732 | * GRANT TABLE OPERATIONS * |
---|
733 | **************************/ |
---|
734 | |
---|
735 | /* |
---|
736 | * Return a handle to the grant table driver, or -1 on failure, in which case |
---|
737 | * errno will be set appropriately. |
---|
738 | */ |
---|
739 | int xc_gnttab_open(void); |
---|
740 | |
---|
741 | /* |
---|
742 | * Close a handle previously allocated with xc_gnttab_open(). |
---|
743 | */ |
---|
744 | int xc_gnttab_close(int xcg_handle); |
---|
745 | |
---|
746 | /* |
---|
747 | * Memory maps a grant reference from one domain to a local address range. |
---|
748 | * Mappings should be unmapped with xc_gnttab_munmap. Returns NULL on failure. |
---|
749 | * |
---|
750 | * @parm xcg_handle a handle on an open grant table interface |
---|
751 | * @parm domid the domain to map memory from |
---|
752 | * @parm ref the grant reference ID to map |
---|
753 | * @parm prot same flag as in mmap() |
---|
754 | */ |
---|
755 | void *xc_gnttab_map_grant_ref(int xcg_handle, |
---|
756 | uint32_t domid, |
---|
757 | uint32_t ref, |
---|
758 | int prot); |
---|
759 | |
---|
760 | /** |
---|
761 | * Memory maps one or more grant references from one or more domains to a |
---|
762 | * contiguous local address range. Mappings should be unmapped with |
---|
763 | * xc_gnttab_munmap. Returns NULL on failure. |
---|
764 | * |
---|
765 | * @parm xcg_handle a handle on an open grant table interface |
---|
766 | * @parm count the number of grant references to be mapped |
---|
767 | * @parm domids an array of @count domain IDs by which the corresponding @refs |
---|
768 | * were granted |
---|
769 | * @parm refs an array of @count grant references to be mapped |
---|
770 | * @parm prot same flag as in mmap() |
---|
771 | */ |
---|
772 | void *xc_gnttab_map_grant_refs(int xcg_handle, |
---|
773 | uint32_t count, |
---|
774 | uint32_t *domids, |
---|
775 | uint32_t *refs, |
---|
776 | int prot); |
---|
777 | |
---|
778 | /* |
---|
779 | * Unmaps the @count pages starting at @start_address, which were mapped by a |
---|
780 | * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns zero |
---|
781 | * on success, otherwise sets errno and returns non-zero. |
---|
782 | */ |
---|
783 | int xc_gnttab_munmap(int xcg_handle, |
---|
784 | void *start_address, |
---|
785 | uint32_t count); |
---|
786 | |
---|
787 | int xc_hvm_set_pci_intx_level( |
---|
788 | int xc_handle, domid_t dom, |
---|
789 | uint8_t domain, uint8_t bus, uint8_t device, uint8_t intx, |
---|
790 | unsigned int level); |
---|
791 | int xc_hvm_set_isa_irq_level( |
---|
792 | int xc_handle, domid_t dom, |
---|
793 | uint8_t isa_irq, |
---|
794 | unsigned int level); |
---|
795 | |
---|
796 | int xc_hvm_set_pci_link_route( |
---|
797 | int xc_handle, domid_t dom, uint8_t link, uint8_t isa_irq); |
---|
798 | |
---|
799 | |
---|
800 | typedef enum { |
---|
801 | XC_ERROR_NONE = 0, |
---|
802 | XC_INTERNAL_ERROR = 1, |
---|
803 | XC_INVALID_KERNEL = 2, |
---|
804 | XC_INVALID_PARAM = 3, |
---|
805 | XC_OUT_OF_MEMORY = 4, |
---|
806 | } xc_error_code; |
---|
807 | |
---|
808 | #define XC_MAX_ERROR_MSG_LEN 1024 |
---|
809 | typedef struct { |
---|
810 | int code; |
---|
811 | char message[XC_MAX_ERROR_MSG_LEN]; |
---|
812 | } xc_error; |
---|
813 | |
---|
814 | /* |
---|
815 | * Return a pointer to the last error. This pointer and the |
---|
816 | * data pointed to are only valid until the next call to |
---|
817 | * libxc. |
---|
818 | */ |
---|
819 | const xc_error *xc_get_last_error(void); |
---|
820 | |
---|
821 | /* |
---|
822 | * Clear the last error |
---|
823 | */ |
---|
824 | void xc_clear_last_error(void); |
---|
825 | |
---|
826 | typedef void (*xc_error_handler)(const xc_error * const err); |
---|
827 | |
---|
828 | /* |
---|
829 | * The default error handler which prints to stderr |
---|
830 | */ |
---|
831 | void xc_default_error_handler(const xc_error * const err); |
---|
832 | |
---|
833 | /* |
---|
834 | * Convert an error code into a text description |
---|
835 | */ |
---|
836 | const char *xc_error_code_to_desc(int code); |
---|
837 | |
---|
838 | /* |
---|
839 | * Registers a callback to handle errors |
---|
840 | */ |
---|
841 | xc_error_handler xc_set_error_handler(xc_error_handler handler); |
---|
842 | |
---|
843 | int xc_set_hvm_param(int handle, domid_t dom, int param, unsigned long value); |
---|
844 | int xc_get_hvm_param(int handle, domid_t dom, int param, unsigned long *value); |
---|
845 | |
---|
846 | /* PowerPC specific. */ |
---|
847 | int xc_alloc_real_mode_area(int xc_handle, |
---|
848 | uint32_t domid, |
---|
849 | unsigned int log); |
---|
850 | #endif |
---|