ia64/xen-unstable

view tools/libxc/xenctrl.h @ 9488:0a6f5527ca4b

[IA64] set itv handoff as masked and enable reading irr[0-3]

Set initial vcpu itv handoff state to mask the timer vector.
This seems to match hardware and makes logical sense from a
spurious interrupt perspective. Enable vcpu_get_irr[0-3]
functions as they seem to work and have the proper backing.
This enables the check_sal_cache_flush() in arch/ia64/kernel.sal.c
to work unmodified, allowing us to remove the Xen changes from
the file (and thus the file from the sparse tree).

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild.aw
date Tue Apr 04 09:39:45 2006 -0600 (2006-04-04)
parents 1439cfa5ee8c
children b128f55ca05c
line source
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 */
9 #ifndef XENCTRL_H
10 #define XENCTRL_H
12 #include <stdint.h>
13 #include <sys/ptrace.h>
14 #include <xen/xen.h>
15 #include <xen/dom0_ops.h>
16 #include <xen/version.h>
17 #include <xen/event_channel.h>
18 #include <xen/sched.h>
19 #include <xen/sched_ctl.h>
20 #include <xen/memory.h>
21 #include <xen/acm.h>
23 #ifdef __ia64__
24 #define XC_PAGE_SHIFT 14
25 #else
26 #define XC_PAGE_SHIFT 12
27 #endif
28 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
29 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
31 /*
32 * DEFINITIONS FOR CPU BARRIERS
33 */
35 #if defined(__i386__)
36 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
37 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
38 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
39 #elif defined(__x86_64__)
40 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
41 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
42 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
43 #elif defined(__ia64__)
44 /* FIXME */
45 #define mb()
46 #define rmb()
47 #define wmb()
48 #else
49 #error "Define barriers"
50 #endif
52 /*
53 * INITIALIZATION FUNCTIONS
54 */
56 /**
57 * This function opens a handle to the hypervisor interface. This function can
58 * be called multiple times within a single process. Multiple processes can
59 * have an open hypervisor interface at the same time.
60 *
61 * Each call to this function should have a corresponding call to
62 * xc_interface_close().
63 *
64 * This function can fail if the caller does not have superuser permission or
65 * if a Xen-enabled kernel is not currently running.
66 *
67 * @return a handle to the hypervisor interface or -1 on failure
68 */
69 int xc_interface_open(void);
71 /**
72 * This function closes an open hypervisor interface.
73 *
74 * This function can fail if the handle does not represent an open interface or
75 * if there were problems closing the interface.
76 *
77 * @parm xc_handle a handle to an open hypervisor interface
78 * @return 0 on success, -1 otherwise.
79 */
80 int xc_interface_close(int xc_handle);
82 /*
83 * DOMAIN DEBUGGING FUNCTIONS
84 */
86 typedef struct xc_core_header {
87 unsigned int xch_magic;
88 unsigned int xch_nr_vcpus;
89 unsigned int xch_nr_pages;
90 unsigned int xch_ctxt_offset;
91 unsigned int xch_index_offset;
92 unsigned int xch_pages_offset;
93 } xc_core_header_t;
95 #define XC_CORE_MAGIC 0xF00FEBED
97 long xc_ptrace_core(
98 int xc_handle,
99 enum __ptrace_request request,
100 uint32_t domid,
101 long addr,
102 long data,
103 vcpu_guest_context_t *ctxt);
104 void * map_domain_va_core(
105 unsigned long domfd,
106 int cpu,
107 void *guest_va,
108 vcpu_guest_context_t *ctxt);
109 int xc_waitdomain_core(
110 int xc_handle,
111 int domain,
112 int *status,
113 int options,
114 vcpu_guest_context_t *ctxt);
116 /*
117 * DOMAIN MANAGEMENT FUNCTIONS
118 */
120 typedef struct {
121 uint32_t domid;
122 uint32_t ssidref;
123 unsigned int dying:1, crashed:1, shutdown:1,
124 paused:1, blocked:1, running:1;
125 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
126 unsigned long nr_pages;
127 unsigned long shared_info_frame;
128 uint64_t cpu_time;
129 unsigned long max_memkb;
130 unsigned int nr_online_vcpus;
131 unsigned int max_vcpu_id;
132 xen_domain_handle_t handle;
133 } xc_dominfo_t;
135 typedef dom0_getdomaininfo_t xc_domaininfo_t;
136 int xc_domain_create(int xc_handle,
137 uint32_t ssidref,
138 xen_domain_handle_t handle,
139 uint32_t *pdomid);
142 /* Functions to produce a dump of a given domain
143 * xc_domain_dumpcore - produces a dump to a specified file
144 * xc_domain_dumpcore_via_callback - produces a dump, using a specified
145 * callback function
146 */
147 int xc_domain_dumpcore(int xc_handle,
148 uint32_t domid,
149 const char *corename);
151 /* Define the callback function type for xc_domain_dumpcore_via_callback.
152 *
153 * This function is called by the coredump code for every "write",
154 * and passes an opaque object for the use of the function and
155 * created by the caller of xc_domain_dumpcore_via_callback.
156 */
157 typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length);
159 int xc_domain_dumpcore_via_callback(int xc_handle,
160 uint32_t domid,
161 void *arg,
162 dumpcore_rtn_t dump_rtn);
164 /*
165 * This function sets the maximum number of vcpus that a domain may create.
166 *
167 * @parm xc_handle a handle to an open hypervisor interface.
168 * @parm domid the domain id in which vcpus are to be created.
169 * @parm max the maximum number of vcpus that the domain may create.
170 * @return 0 on success, -1 on failure.
171 */
172 int xc_domain_max_vcpus(int xc_handle,
173 uint32_t domid,
174 unsigned int max);
176 /**
177 * This function pauses a domain. A paused domain still exists in memory
178 * however it does not receive any timeslices from the hypervisor.
179 *
180 * @parm xc_handle a handle to an open hypervisor interface
181 * @parm domid the domain id to pause
182 * @return 0 on success, -1 on failure.
183 */
184 int xc_domain_pause(int xc_handle,
185 uint32_t domid);
186 /**
187 * This function unpauses a domain. The domain should have been previously
188 * paused.
189 *
190 * @parm xc_handle a handle to an open hypervisor interface
191 * @parm domid the domain id to unpause
192 * return 0 on success, -1 on failure
193 */
194 int xc_domain_unpause(int xc_handle,
195 uint32_t domid);
197 /**
198 * This function will destroy a domain. Destroying a domain removes the domain
199 * completely from memory. This function should be called after sending the
200 * domain a SHUTDOWN control message to free up the domain resources.
201 *
202 * @parm xc_handle a handle to an open hypervisor interface
203 * @parm domid the domain id to destroy
204 * @return 0 on success, -1 on failure
205 */
206 int xc_domain_destroy(int xc_handle,
207 uint32_t domid);
209 int xc_vcpu_setaffinity(int xc_handle,
210 uint32_t domid,
211 int vcpu,
212 cpumap_t cpumap);
214 /**
215 * This function will return information about one or more domains. It is
216 * designed to iterate over the list of domains. If a single domain is
217 * requested, this function will return the next domain in the list - if
218 * one exists. It is, therefore, important in this case to make sure the
219 * domain requested was the one returned.
220 *
221 * @parm xc_handle a handle to an open hypervisor interface
222 * @parm first_domid the first domain to enumerate information from. Domains
223 * are currently enumerate in order of creation.
224 * @parm max_doms the number of elements in info
225 * @parm info an array of max_doms size that will contain the information for
226 * the enumerated domains.
227 * @return the number of domains enumerated or -1 on error
228 */
229 int xc_domain_getinfo(int xc_handle,
230 uint32_t first_domid,
231 unsigned int max_doms,
232 xc_dominfo_t *info);
235 /**
236 * This function will set the execution context for the specified vcpu.
237 *
238 * @parm xc_handle a handle to an open hypervisor interface
239 * @parm domid the domain to set the vcpu context for
240 * @parm vcpu the vcpu number for the context
241 * @parm ctxt pointer to the the cpu context with the values to set
242 * @return the number of domains enumerated or -1 on error
243 */
244 int xc_vcpu_setcontext(int xc_handle,
245 uint32_t domid,
246 uint32_t vcpu,
247 vcpu_guest_context_t *ctxt);
248 /**
249 * This function will return information about one or more domains, using a
250 * single hypercall. The domain information will be stored into the supplied
251 * array of xc_domaininfo_t structures.
252 *
253 * @parm xc_handle a handle to an open hypervisor interface
254 * @parm first_domain the first domain to enumerate information from.
255 * Domains are currently enumerate in order of creation.
256 * @parm max_domains the number of elements in info
257 * @parm info an array of max_doms size that will contain the information for
258 * the enumerated domains.
259 * @return the number of domains enumerated or -1 on error
260 */
261 int xc_domain_getinfolist(int xc_handle,
262 uint32_t first_domain,
263 unsigned int max_domains,
264 xc_domaininfo_t *info);
266 /**
267 * This function returns information about the execution context of a
268 * particular vcpu of a domain.
269 *
270 * @parm xc_handle a handle to an open hypervisor interface
271 * @parm domid the domain to get information from
272 * @parm vcpu the vcpu number
273 * @parm ctxt a pointer to a structure to store the execution context of the
274 * domain
275 * @return 0 on success, -1 on failure
276 */
277 int xc_vcpu_getcontext(int xc_handle,
278 uint32_t domid,
279 uint32_t vcpu,
280 vcpu_guest_context_t *ctxt);
282 typedef dom0_getvcpuinfo_t xc_vcpuinfo_t;
283 int xc_vcpu_getinfo(int xc_handle,
284 uint32_t domid,
285 uint32_t vcpu,
286 xc_vcpuinfo_t *info);
288 int xc_domain_setcpuweight(int xc_handle,
289 uint32_t domid,
290 float weight);
291 long long xc_domain_get_cpu_usage(int xc_handle,
292 domid_t domid,
293 int vcpu);
295 int xc_domain_sethandle(int xc_handle, uint32_t domid,
296 xen_domain_handle_t handle);
298 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
299 int xc_shadow_control(int xc_handle,
300 uint32_t domid,
301 unsigned int sop,
302 unsigned long *dirty_bitmap,
303 unsigned long pages,
304 xc_shadow_control_stats_t *stats);
306 int xc_bvtsched_global_set(int xc_handle,
307 unsigned long ctx_allow);
309 int xc_bvtsched_domain_set(int xc_handle,
310 uint32_t domid,
311 uint32_t mcuadv,
312 int warpback,
313 int32_t warpvalue,
314 long long warpl,
315 long long warpu);
317 int xc_bvtsched_global_get(int xc_handle,
318 unsigned long *ctx_allow);
320 int xc_bvtsched_domain_get(int xc_handle,
321 uint32_t domid,
322 uint32_t *mcuadv,
323 int *warpback,
324 int32_t *warpvalue,
325 long long *warpl,
326 long long *warpu);
328 int xc_sedf_domain_set(int xc_handle,
329 uint32_t domid,
330 uint64_t period, uint64_t slice,
331 uint64_t latency, uint16_t extratime,
332 uint16_t weight);
334 int xc_sedf_domain_get(int xc_handle,
335 uint32_t domid,
336 uint64_t* period, uint64_t *slice,
337 uint64_t *latency, uint16_t *extratime,
338 uint16_t *weight);
340 typedef evtchn_status_t xc_evtchn_status_t;
342 /*
343 * EVENT CHANNEL FUNCTIONS
344 */
346 /**
347 * This function allocates an unbound port. Ports are named endpoints used for
348 * interdomain communication. This function is most useful in opening a
349 * well-known port within a domain to receive events on.
350 *
351 * @parm xc_handle a handle to an open hypervisor interface
352 * @parm dom the ID of the local domain (the 'allocatee')
353 * @parm remote_dom the ID of the domain who will later bind
354 * @return allocated port (in @dom) on success, -1 on failure
355 */
356 int xc_evtchn_alloc_unbound(int xc_handle,
357 uint32_t dom,
358 uint32_t remote_dom);
360 int xc_evtchn_status(int xc_handle,
361 uint32_t dom, /* may be DOMID_SELF */
362 evtchn_port_t port,
363 xc_evtchn_status_t *status);
365 int xc_physdev_pci_access_modify(int xc_handle,
366 uint32_t domid,
367 int bus,
368 int dev,
369 int func,
370 int enable);
372 int xc_readconsolering(int xc_handle,
373 char **pbuffer,
374 unsigned int *pnr_chars,
375 int clear);
377 typedef dom0_physinfo_t xc_physinfo_t;
378 int xc_physinfo(int xc_handle,
379 xc_physinfo_t *info);
381 int xc_sched_id(int xc_handle,
382 int *sched_id);
384 int xc_domain_setmaxmem(int xc_handle,
385 uint32_t domid,
386 unsigned int max_memkb);
388 int xc_domain_memory_increase_reservation(int xc_handle,
389 uint32_t domid,
390 unsigned long nr_extents,
391 unsigned int extent_order,
392 unsigned int address_bits,
393 unsigned long *extent_start);
395 int xc_domain_memory_decrease_reservation(int xc_handle,
396 uint32_t domid,
397 unsigned long nr_extents,
398 unsigned int extent_order,
399 unsigned long *extent_start);
401 int xc_domain_memory_populate_physmap(int xc_handle,
402 uint32_t domid,
403 unsigned long nr_extents,
404 unsigned int extent_order,
405 unsigned int address_bits,
406 unsigned long *extent_start);
408 int xc_domain_translate_gpfn_list(int xc_handle,
409 uint32_t domid,
410 unsigned long nr_gpfns,
411 unsigned long *gpfn_list,
412 unsigned long *mfn_list);
414 int xc_domain_ioport_permission(int xc_handle,
415 uint32_t domid,
416 uint32_t first_port,
417 uint32_t nr_ports,
418 uint32_t allow_access);
420 int xc_domain_irq_permission(int xc_handle,
421 uint32_t domid,
422 uint8_t pirq,
423 uint8_t allow_access);
425 int xc_domain_iomem_permission(int xc_handle,
426 uint32_t domid,
427 unsigned long first_mfn,
428 unsigned long nr_mfns,
429 uint8_t allow_access);
431 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
432 unsigned long mfn);
434 typedef dom0_perfc_desc_t xc_perfc_desc_t;
435 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
436 int xc_perfc_control(int xc_handle,
437 uint32_t op,
438 xc_perfc_desc_t *desc);
440 /* read/write msr */
441 long long xc_msr_read(int xc_handle, int cpu_mask, int msr);
442 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
443 unsigned int high);
445 /**
446 * Memory maps a range within one domain to a local address range. Mappings
447 * should be unmapped with munmap and should follow the same rules as mmap
448 * regarding page alignment. Returns NULL on failure.
449 *
450 * In Linux, the ring queue for the control channel is accessible by mapping
451 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
452 * stored there is of type control_if_t.
453 *
454 * @parm xc_handle a handle on an open hypervisor interface
455 * @parm dom the domain to map memory from
456 * @parm size the amount of memory to map (in multiples of page size)
457 * @parm prot same flag as in mmap().
458 * @parm mfn the frame address to map.
459 */
460 void *xc_map_foreign_range(int xc_handle, uint32_t dom,
461 int size, int prot,
462 unsigned long mfn );
464 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
465 unsigned long *arr, int num );
467 /**
468 * Translates a virtual address in the context of a given domain and
469 * vcpu returning the machine page frame number of the associated
470 * page.
471 *
472 * @parm xc_handle a handle on an open hypervisor interface
473 * @parm dom the domain to perform the translation in
474 * @parm vcpu the vcpu to perform the translation on
475 * @parm virt the virtual address to translate
476 */
477 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
478 int vcpu, unsigned long long virt);
480 int xc_get_pfn_list(int xc_handle, uint32_t domid, unsigned long *pfn_buf,
481 unsigned long max_pfns);
483 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
484 unsigned long *pfn_buf,
485 unsigned int start_page, unsigned int nr_pages);
487 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
488 unsigned long dst_pfn, const char *src_page);
490 int xc_clear_domain_page(int xc_handle, uint32_t domid,
491 unsigned long dst_pfn);
493 int xc_ia64_copy_to_domain_pages(int xc_handle, uint32_t domid,
494 void* src_page, unsigned long dst_pfn, int nr_pages);
496 long xc_get_max_pages(int xc_handle, uint32_t domid);
498 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
499 domid_t dom);
501 int xc_memory_op(int xc_handle, int cmd, void *arg);
503 int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
504 int num, unsigned long *arr);
507 /* Get current total pages allocated to a domain. */
508 long xc_get_tot_pages(int xc_handle, uint32_t domid);
511 /*
512 * Trace Buffer Operations
513 */
515 /**
516 * This function enables or disables tracing. Trace buffer memory must
517 * be already allocated by setting the size to a non-zero value, otherwise
518 * tracing cannot be enabled.
519 *
520 * @parm xc_handle a handle to an open hypervisor interface
521 * @parm enable the desired action, 1 for enable, 0 for disable
522 * @return 0 on success, -1 on failure.
523 */
524 int xc_tbuf_enable(int xc_handle, int enable);
526 /**
527 * This function sets the size of the trace buffers. Setting the size
528 * is currently a one-shot operation that may be performed either at boot
529 * time or via this interface, not both. The buffer size must be set before
530 * enabling tracing.
531 *
532 * @parm xc_handle a handle to an open hypervisor interface
533 * @parm size the size in pages per cpu for the trace buffers
534 * @return 0 on success, -1 on failure.
535 */
536 int xc_tbuf_set_size(int xc_handle, uint32_t size);
538 /**
539 * This function retrieves the current size of the trace buffers.
540 * Note that the size returned is in terms of bytes, not pages.
542 * @parm xc_handle a handle to an open hypervisor interface
543 * @parm size will contain the size in bytes for the trace buffers
544 * @return 0 on success, -1 on failure.
545 */
546 int xc_tbuf_get_size(int xc_handle, uint32_t *size);
549 /* Execute a privileged dom0 operation. */
550 int xc_dom0_op(int xc_handle, dom0_op_t *op);
552 int xc_version(int xc_handle, int cmd, void *arg);
554 /*
555 * MMU updates.
556 */
557 #define MAX_MMU_UPDATES 1024
558 struct xc_mmu {
559 mmu_update_t updates[MAX_MMU_UPDATES];
560 int idx;
561 domid_t subject;
562 };
563 typedef struct xc_mmu xc_mmu_t;
564 xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
565 int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
566 unsigned long long ptr, unsigned long long val);
567 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
569 #endif