Merge branch 'stable-0.10' of git://git.sv.gnu.org/qemu into stable-0.10
[qemu-kvm/fedora.git] / kvm / libkvm / libkvm.h
blobf5ed190392a2ef441d4dd35c411536f89f220521
1 /** \file libkvm.h
2 * libkvm API
3 */
5 #ifndef LIBKVM_H
6 #define LIBKVM_H
8 #if defined(__s390__)
9 #include <asm/ptrace.h>
10 #endif
12 #include <stdint.h>
14 #ifndef __user
15 #define __user /* temporary, until installed via make headers_install */
16 #endif
18 #include <linux/kvm.h>
20 #include <signal.h>
22 struct kvm_context;
24 typedef struct kvm_context *kvm_context_t;
26 #if defined(__x86_64__) || defined(__i386__)
27 struct kvm_msr_list *kvm_get_msr_list(kvm_context_t);
28 int kvm_get_msrs(kvm_context_t, int vcpu, struct kvm_msr_entry *msrs, int n);
29 int kvm_set_msrs(kvm_context_t, int vcpu, struct kvm_msr_entry *msrs, int n);
30 #endif
32 /*!
33 * \brief KVM callbacks structure
35 * This structure holds pointers to various functions that KVM will call
36 * when it encounters something that cannot be virtualized, such as
37 * accessing hardware devices via MMIO or regular IO.
39 struct kvm_callbacks {
40 /// For 8bit IO reads from the guest (Usually when executing 'inb')
41 int (*inb)(void *opaque, uint16_t addr, uint8_t *data);
42 /// For 16bit IO reads from the guest (Usually when executing 'inw')
43 int (*inw)(void *opaque, uint16_t addr, uint16_t *data);
44 /// For 32bit IO reads from the guest (Usually when executing 'inl')
45 int (*inl)(void *opaque, uint16_t addr, uint32_t *data);
46 /// For 8bit IO writes from the guest (Usually when executing 'outb')
47 int (*outb)(void *opaque, uint16_t addr, uint8_t data);
48 /// For 16bit IO writes from the guest (Usually when executing 'outw')
49 int (*outw)(void *opaque, uint16_t addr, uint16_t data);
50 /// For 32bit IO writes from the guest (Usually when executing 'outl')
51 int (*outl)(void *opaque, uint16_t addr, uint32_t data);
52 /// generic memory reads to unmapped memory (For MMIO devices)
53 int (*mmio_read)(void *opaque, uint64_t addr, uint8_t *data,
54 int len);
55 /// generic memory writes to unmapped memory (For MMIO devices)
56 int (*mmio_write)(void *opaque, uint64_t addr, uint8_t *data,
57 int len);
58 #ifdef KVM_CAP_SET_GUEST_DEBUG
59 int (*debug)(void *opaque, void *env,
60 struct kvm_debug_exit_arch *arch_info);
61 #endif
62 /*!
63 * \brief Called when the VCPU issues an 'hlt' instruction.
65 * Typically, you should yeild here to prevent 100% CPU utilization
66 * on the host CPU.
68 int (*halt)(void *opaque, int vcpu);
69 int (*shutdown)(void *opaque, void *env);
70 int (*io_window)(void *opaque);
71 int (*try_push_interrupts)(void *opaque);
72 #ifdef KVM_CAP_USER_NMI
73 void (*push_nmi)(void *opaque);
74 #endif
75 void (*post_kvm_run)(void *opaque, void *env);
76 int (*pre_kvm_run)(void *opaque, void *env);
77 int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
78 #if defined(__powerpc__)
79 int (*powerpc_dcr_read)(int vcpu, uint32_t dcrn, uint32_t *data);
80 int (*powerpc_dcr_write)(int vcpu, uint32_t dcrn, uint32_t data);
81 #endif
82 #if defined(__s390__)
83 int (*s390_handle_intercept)(kvm_context_t context, int vcpu,
84 struct kvm_run *run);
85 int (*s390_handle_reset)(kvm_context_t context, int vcpu,
86 struct kvm_run *run);
87 #endif
90 /*!
91 * \brief Create new KVM context
93 * This creates a new kvm_context. A KVM context is a small area of data that
94 * holds information about the KVM instance that gets created by this call.\n
95 * This should always be your first call to KVM.
97 * \param callbacks Pointer to a valid kvm_callbacks structure
98 * \param opaque Not used
99 * \return NULL on failure
101 kvm_context_t kvm_init(struct kvm_callbacks *callbacks,
102 void *opaque);
105 * \brief Cleanup the KVM context
107 * Should always be called when closing down KVM.\n
108 * Exception: If kvm_init() fails, this function should not be called, as the
109 * context would be invalid
111 * \param kvm Pointer to the kvm_context that is to be freed
113 void kvm_finalize(kvm_context_t kvm);
116 * \brief Disable the in-kernel IRQCHIP creation
118 * In-kernel irqchip is enabled by default. If userspace irqchip is to be used,
119 * this should be called prior to kvm_create().
121 * \param kvm Pointer to the kvm_context
123 void kvm_disable_irqchip_creation(kvm_context_t kvm);
126 * \brief Disable the in-kernel PIT creation
128 * In-kernel pit is enabled by default. If userspace pit is to be used,
129 * this should be called prior to kvm_create().
131 * \param kvm Pointer to the kvm_context
133 void kvm_disable_pit_creation(kvm_context_t kvm);
136 * \brief Create new virtual machine
138 * This creates a new virtual machine, maps physical RAM to it, and creates a
139 * virtual CPU for it.\n
140 * \n
141 * Memory gets mapped for addresses 0->0xA0000, 0xC0000->phys_mem_bytes
143 * \param kvm Pointer to the current kvm_context
144 * \param phys_mem_bytes The amount of physical ram you want the VM to have
145 * \param phys_mem This pointer will be set to point to the memory that
146 * kvm_create allocates for physical RAM
147 * \return 0 on success
149 int kvm_create(kvm_context_t kvm,
150 unsigned long phys_mem_bytes,
151 void **phys_mem);
152 int kvm_create_vm(kvm_context_t kvm);
153 int kvm_check_extension(kvm_context_t kvm, int ext);
154 void kvm_create_irqchip(kvm_context_t kvm);
157 * \brief Create a new virtual cpu
159 * This creates a new virtual cpu (the first vcpu is created by kvm_create()).
160 * Should be called from a thread dedicated to the vcpu.
162 * \param kvm kvm context
163 * \param slot vcpu number (> 0)
164 * \return 0 on success, -errno on failure
166 int kvm_create_vcpu(kvm_context_t kvm, int slot);
169 * \brief Start the VCPU
171 * This starts the VCPU and virtualization is started.\n
172 * \n
173 * This function will not return until any of these conditions are met:
174 * - An IO/MMIO handler does not return "0"
175 * - An exception that neither the guest OS, nor KVM can handle occurs
177 * \note This function will call the callbacks registered in kvm_init()
178 * to emulate those functions
179 * \note If you at any point want to interrupt the VCPU, kvm_run() will
180 * listen to the EINTR signal. This allows you to simulate external interrupts
181 * and asyncronous IO.
183 * \param kvm Pointer to the current kvm_context
184 * \param vcpu Which virtual CPU should be started
185 * \return 0 on success, but you really shouldn't expect this function to
186 * return except for when an error has occured, or when you have sent it
187 * an EINTR signal.
189 int kvm_run(kvm_context_t kvm, int vcpu, void *env);
192 * \brief Get interrupt flag from on last exit to userspace
194 * This gets the CPU interrupt flag as it was on the last exit to userspace.
196 * \param kvm Pointer to the current kvm_context
197 * \param vcpu Which virtual CPU should get dumped
198 * \return interrupt flag value (0 or 1)
200 int kvm_get_interrupt_flag(kvm_context_t kvm, int vcpu);
203 * \brief Get the value of the APIC_BASE msr as of last exit to userspace
205 * This gets the APIC_BASE msr as it was on the last exit to userspace.
207 * \param kvm Pointer to the current kvm_context
208 * \param vcpu Which virtual CPU should get dumped
209 * \return APIC_BASE msr contents
211 uint64_t kvm_get_apic_base(kvm_context_t kvm, int vcpu);
214 * \brief Check if a vcpu is ready for interrupt injection
216 * This checks if vcpu interrupts are not masked by mov ss or sti.
218 * \param kvm Pointer to the current kvm_context
219 * \param vcpu Which virtual CPU should get dumped
220 * \return boolean indicating interrupt injection readiness
222 int kvm_is_ready_for_interrupt_injection(kvm_context_t kvm, int vcpu);
225 * \brief Read VCPU registers
227 * This gets the GP registers from the VCPU and outputs them
228 * into a kvm_regs structure
230 * \note This function returns a \b copy of the VCPUs registers.\n
231 * If you wish to modify the VCPUs GP registers, you should call kvm_set_regs()
233 * \param kvm Pointer to the current kvm_context
234 * \param vcpu Which virtual CPU should get dumped
235 * \param regs Pointer to a kvm_regs which will be populated with the VCPUs
236 * registers values
237 * \return 0 on success
239 int kvm_get_regs(kvm_context_t kvm, int vcpu, struct kvm_regs *regs);
242 * \brief Write VCPU registers
244 * This sets the GP registers on the VCPU from a kvm_regs structure
246 * \note When this function returns, the regs pointer and the data it points to
247 * can be discarded
248 * \param kvm Pointer to the current kvm_context
249 * \param vcpu Which virtual CPU should get dumped
250 * \param regs Pointer to a kvm_regs which will be populated with the VCPUs
251 * registers values
252 * \return 0 on success
254 int kvm_set_regs(kvm_context_t kvm, int vcpu, struct kvm_regs *regs);
256 * \brief Read VCPU fpu registers
258 * This gets the FPU registers from the VCPU and outputs them
259 * into a kvm_fpu structure
261 * \note This function returns a \b copy of the VCPUs registers.\n
262 * If you wish to modify the VCPU FPU registers, you should call kvm_set_fpu()
264 * \param kvm Pointer to the current kvm_context
265 * \param vcpu Which virtual CPU should get dumped
266 * \param fpu Pointer to a kvm_fpu which will be populated with the VCPUs
267 * fpu registers values
268 * \return 0 on success
270 int kvm_get_fpu(kvm_context_t kvm, int vcpu, struct kvm_fpu *fpu);
273 * \brief Write VCPU fpu registers
275 * This sets the FPU registers on the VCPU from a kvm_fpu structure
277 * \note When this function returns, the fpu pointer and the data it points to
278 * can be discarded
279 * \param kvm Pointer to the current kvm_context
280 * \param vcpu Which virtual CPU should get dumped
281 * \param fpu Pointer to a kvm_fpu which holds the new vcpu fpu state
282 * \return 0 on success
284 int kvm_set_fpu(kvm_context_t kvm, int vcpu, struct kvm_fpu *fpu);
287 * \brief Read VCPU system registers
289 * This gets the non-GP registers from the VCPU and outputs them
290 * into a kvm_sregs structure
292 * \note This function returns a \b copy of the VCPUs registers.\n
293 * If you wish to modify the VCPUs non-GP registers, you should call
294 * kvm_set_sregs()
296 * \param kvm Pointer to the current kvm_context
297 * \param vcpu Which virtual CPU should get dumped
298 * \param regs Pointer to a kvm_sregs which will be populated with the VCPUs
299 * registers values
300 * \return 0 on success
302 int kvm_get_sregs(kvm_context_t kvm, int vcpu, struct kvm_sregs *regs);
305 * \brief Write VCPU system registers
307 * This sets the non-GP registers on the VCPU from a kvm_sregs structure
309 * \note When this function returns, the regs pointer and the data it points to
310 * can be discarded
311 * \param kvm Pointer to the current kvm_context
312 * \param vcpu Which virtual CPU should get dumped
313 * \param regs Pointer to a kvm_sregs which will be populated with the VCPUs
314 * registers values
315 * \return 0 on success
317 int kvm_set_sregs(kvm_context_t kvm, int vcpu, struct kvm_sregs *regs);
319 #ifdef KVM_CAP_MP_STATE
321 * * \brief Read VCPU MP state
324 int kvm_get_mpstate(kvm_context_t kvm, int vcpu,
325 struct kvm_mp_state *mp_state);
328 * * \brief Write VCPU MP state
331 int kvm_set_mpstate(kvm_context_t kvm, int vcpu,
332 struct kvm_mp_state *mp_state);
334 * * \brief Reset VCPU MP state
337 static inline int kvm_reset_mpstate(kvm_context_t kvm, int vcpu)
339 struct kvm_mp_state mp_state = {.mp_state = KVM_MP_STATE_UNINITIALIZED};
340 return kvm_set_mpstate(kvm, vcpu, &mp_state);
342 #endif
345 * \brief Simulate an external vectored interrupt
347 * This allows you to simulate an external vectored interrupt.
349 * \param kvm Pointer to the current kvm_context
350 * \param vcpu Which virtual CPU should get dumped
351 * \param irq Vector number
352 * \return 0 on success
354 int kvm_inject_irq(kvm_context_t kvm, int vcpu, unsigned irq);
356 #ifdef KVM_CAP_SET_GUEST_DEBUG
357 int kvm_set_guest_debug(kvm_context_t, int vcpu, struct kvm_guest_debug *dbg);
358 #endif
360 #if defined(__i386__) || defined(__x86_64__)
362 * \brief Setup a vcpu's cpuid instruction emulation
364 * Set up a table of cpuid function to cpuid outputs.\n
366 * \param kvm Pointer to the current kvm_context
367 * \param vcpu Which virtual CPU should be initialized
368 * \param nent number of entries to be installed
369 * \param entries cpuid function entries table
370 * \return 0 on success, or -errno on error
372 int kvm_setup_cpuid(kvm_context_t kvm, int vcpu, int nent,
373 struct kvm_cpuid_entry *entries);
376 * \brief Setup a vcpu's cpuid instruction emulation
378 * Set up a table of cpuid function to cpuid outputs.
379 * This call replaces the older kvm_setup_cpuid interface by adding a few
380 * parameters to support cpuid functions that have sub-leaf values.
382 * \param kvm Pointer to the current kvm_context
383 * \param vcpu Which virtual CPU should be initialized
384 * \param nent number of entries to be installed
385 * \param entries cpuid function entries table
386 * \return 0 on success, or -errno on error
388 int kvm_setup_cpuid2(kvm_context_t kvm, int vcpu, int nent,
389 struct kvm_cpuid_entry2 *entries);
392 * \brief Setting the number of shadow pages to be allocated to the vm
394 * \param kvm pointer to kvm_context
395 * \param nrshadow_pages number of pages to be allocated
397 int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int nrshadow_pages);
400 * \brief Getting the number of shadow pages that are allocated to the vm
402 * \param kvm pointer to kvm_context
403 * \param nrshadow_pages number of pages to be allocated
405 int kvm_get_shadow_pages(kvm_context_t kvm , unsigned int *nrshadow_pages);
408 * \brief Set up cr8 for next time the vcpu is executed
410 * This is a fast setter for cr8, which will be applied when the
411 * vcpu next enters guest mode.
413 * \param kvm Pointer to the current kvm_context
414 * \param vcpu Which virtual CPU should get dumped
415 * \param cr8 next cr8 value
417 void kvm_set_cr8(kvm_context_t kvm, int vcpu, uint64_t cr8);
420 * \brief Get cr8 for sync tpr in qemu apic emulation
422 * This is a getter for cr8, which used to sync with the tpr in qemu
423 * apic emualtion.
425 * \param kvm Pointer to the current kvm_context
426 * \param vcpu Which virtual CPU should get dumped
428 __u64 kvm_get_cr8(kvm_context_t kvm, int vcpu);
429 #endif
432 * \brief Set a vcpu's signal mask for guest mode
434 * A vcpu can have different signals blocked in guest mode and user mode.
435 * This allows guest execution to be interrupted on a signal, without requiring
436 * that the signal be delivered to a signal handler (the signal can be
437 * dequeued using sigwait(2).
439 * \param kvm Pointer to the current kvm_context
440 * \param vcpu Which virtual CPU should be initialized
441 * \param sigset signal mask for guest mode
442 * \return 0 on success, or -errno on error
444 int kvm_set_signal_mask(kvm_context_t kvm, int vcpu, const sigset_t *sigset);
447 * \brief Dump all VCPU information
449 * This dumps \b all the information that KVM has about a virtual CPU, namely:
450 * - GP Registers
451 * - System registers (selectors, descriptors, etc)
452 * - VMCS Data
453 * - MSRS
454 * - Pending interrupts
456 * \param kvm Pointer to the current kvm_context
457 * \param vcpu Which virtual CPU should get dumped
458 * \return 0 on success
460 int kvm_dump_vcpu(kvm_context_t kvm, int vcpu);
463 * \brief Dump VCPU registers
465 * This dumps some of the information that KVM has about a virtual CPU, namely:
466 * - GP Registers
468 * A much more verbose version of this is available as kvm_dump_vcpu()
470 * \param kvm Pointer to the current kvm_context
471 * \param vcpu Which virtual CPU should get dumped
472 * \return 0 on success
474 void kvm_show_regs(kvm_context_t kvm, int vcpu);
477 void *kvm_create_phys_mem(kvm_context_t, unsigned long phys_start,
478 unsigned long len, int log, int writable);
479 void kvm_destroy_phys_mem(kvm_context_t, unsigned long phys_start,
480 unsigned long len);
481 void kvm_unregister_memory_area(kvm_context_t, uint64_t phys_start,
482 unsigned long len);
484 int kvm_is_containing_region(kvm_context_t kvm, unsigned long phys_start, unsigned long size);
485 int kvm_register_phys_mem(kvm_context_t kvm,
486 unsigned long phys_start, void *userspace_addr,
487 unsigned long len, int log);
488 int kvm_get_dirty_pages(kvm_context_t, unsigned long phys_addr, void *buf);
489 int kvm_get_dirty_pages_range(kvm_context_t kvm, unsigned long phys_addr,
490 unsigned long end_addr, void *buf, void*opaque,
491 int (*cb)(unsigned long start, unsigned long len,
492 void*bitmap, void *opaque));
493 int kvm_register_coalesced_mmio(kvm_context_t kvm,
494 uint64_t addr, uint32_t size);
495 int kvm_unregister_coalesced_mmio(kvm_context_t kvm,
496 uint64_t addr, uint32_t size);
499 * \brief Create a memory alias
501 * Aliases a portion of physical memory to another portion. If the guest
502 * accesses the alias region, it will behave exactly as if it accessed
503 * the target memory.
505 int kvm_create_memory_alias(kvm_context_t,
506 uint64_t phys_start, uint64_t len,
507 uint64_t target_phys);
510 * \brief Destroy a memory alias
512 * Removes an alias created with kvm_create_memory_alias().
514 int kvm_destroy_memory_alias(kvm_context_t, uint64_t phys_start);
517 * \brief Get a bitmap of guest ram pages which are allocated to the guest.
519 * \param kvm Pointer to the current kvm_context
520 * \param phys_addr Memory slot phys addr
521 * \param bitmap Long aligned address of a big enough bitmap (one bit per page)
523 int kvm_get_mem_map(kvm_context_t kvm, unsigned long phys_addr, void *bitmap);
524 int kvm_get_mem_map_range(kvm_context_t kvm, unsigned long phys_addr,
525 unsigned long len, void *buf, void *opaque,
526 int (*cb)(unsigned long start,unsigned long len,
527 void* bitmap, void* opaque));
528 int kvm_set_irq_level(kvm_context_t kvm, int irq, int level, int *status);
530 int kvm_dirty_pages_log_enable_slot(kvm_context_t kvm,
531 uint64_t phys_start,
532 uint64_t len);
533 int kvm_dirty_pages_log_disable_slot(kvm_context_t kvm,
534 uint64_t phys_start,
535 uint64_t len);
537 * \brief Enable dirty-pages-logging for all memory regions
539 * \param kvm Pointer to the current kvm_context
541 int kvm_dirty_pages_log_enable_all(kvm_context_t kvm);
544 * \brief Disable dirty-page-logging for some memory regions
546 * Disable dirty-pages-logging for those memory regions that were
547 * created with dirty-page-logging disabled.
549 * \param kvm Pointer to the current kvm_context
551 int kvm_dirty_pages_log_reset(kvm_context_t kvm);
554 * \brief Query whether in kernel irqchip is used
556 * \param kvm Pointer to the current kvm_context
558 int kvm_irqchip_in_kernel(kvm_context_t kvm);
560 int kvm_has_sync_mmu(kvm_context_t kvm);
562 #ifdef KVM_CAP_IRQCHIP
564 * \brief Dump in kernel IRQCHIP contents
566 * Dump one of the in kernel irq chip devices, including PIC (master/slave)
567 * and IOAPIC into a kvm_irqchip structure
569 * \param kvm Pointer to the current kvm_context
570 * \param chip The irq chip device to be dumped
572 int kvm_get_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip);
575 * \brief Set in kernel IRQCHIP contents
577 * Write one of the in kernel irq chip devices, including PIC (master/slave)
578 * and IOAPIC
581 * \param kvm Pointer to the current kvm_context
582 * \param chip THe irq chip device to be written
584 int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip);
586 #if defined(__i386__) || defined(__x86_64__)
588 * \brief Get in kernel local APIC for vcpu
590 * Save the local apic state including the timer of a virtual CPU
592 * \param kvm Pointer to the current kvm_context
593 * \param vcpu Which virtual CPU should be accessed
594 * \param s Local apic state of the specific virtual CPU
596 int kvm_get_lapic(kvm_context_t kvm, int vcpu, struct kvm_lapic_state *s);
599 * \brief Set in kernel local APIC for vcpu
601 * Restore the local apic state including the timer of a virtual CPU
603 * \param kvm Pointer to the current kvm_context
604 * \param vcpu Which virtual CPU should be accessed
605 * \param s Local apic state of the specific virtual CPU
607 int kvm_set_lapic(kvm_context_t kvm, int vcpu, struct kvm_lapic_state *s);
609 #endif
612 * \brief Simulate an NMI
614 * This allows you to simulate a non-maskable interrupt.
616 * \param kvm Pointer to the current kvm_context
617 * \param vcpu Which virtual CPU should get dumped
618 * \return 0 on success
620 int kvm_inject_nmi(kvm_context_t kvm, int vcpu);
622 #endif
625 * \brief Query wheather in kernel pit is used
627 * \param kvm Pointer to the current kvm_context
629 int kvm_pit_in_kernel(kvm_context_t kvm);
632 * \brief Initialize coalesced MMIO
634 * Check for coalesced MMIO capability and store in context
636 * \param kvm Pointer to the current kvm_context
638 int kvm_init_coalesced_mmio(kvm_context_t kvm);
640 #ifdef KVM_CAP_PIT
642 #if defined(__i386__) || defined(__x86_64__)
644 * \brief Get in kernel PIT of the virtual domain
646 * Save the PIT state.
648 * \param kvm Pointer to the current kvm_context
649 * \param s PIT state of the virtual domain
651 int kvm_get_pit(kvm_context_t kvm, struct kvm_pit_state *s);
654 * \brief Set in kernel PIT of the virtual domain
656 * Restore the PIT state.
657 * Timer would be retriggerred after restored.
659 * \param kvm Pointer to the current kvm_context
660 * \param s PIT state of the virtual domain
662 int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s);
663 #endif
665 int kvm_reinject_control(kvm_context_t kvm, int pit_reinject);
667 #endif
669 #ifdef KVM_CAP_VAPIC
672 * \brief Enable kernel tpr access reporting
674 * When tpr access reporting is enabled, the kernel will call the
675 * ->tpr_access() callback every time the guest vcpu accesses the tpr.
677 * \param kvm Pointer to the current kvm_context
678 * \param vcpu vcpu to enable tpr access reporting on
680 int kvm_enable_tpr_access_reporting(kvm_context_t kvm, int vcpu);
683 * \brief Disable kernel tpr access reporting
685 * Undoes the effect of kvm_enable_tpr_access_reporting().
687 * \param kvm Pointer to the current kvm_context
688 * \param vcpu vcpu to disable tpr access reporting on
690 int kvm_disable_tpr_access_reporting(kvm_context_t kvm, int vcpu);
692 int kvm_enable_vapic(kvm_context_t kvm, int vcpu, uint64_t vapic);
694 #endif
696 #if defined(__s390__)
697 int kvm_s390_initial_reset(kvm_context_t kvm, int slot);
698 int kvm_s390_interrupt(kvm_context_t kvm, int slot,
699 struct kvm_s390_interrupt *kvmint);
700 int kvm_s390_set_initial_psw(kvm_context_t kvm, int slot, psw_t psw);
701 int kvm_s390_store_status(kvm_context_t kvm, int slot, unsigned long addr);
702 #endif
704 #ifdef KVM_CAP_DEVICE_ASSIGNMENT
706 * \brief Notifies host kernel about a PCI device to be assigned to a guest
708 * Used for PCI device assignment, this function notifies the host
709 * kernel about the assigning of the physical PCI device to a guest.
711 * \param kvm Pointer to the current kvm_context
712 * \param assigned_dev Parameters, like bus, devfn number, etc
714 int kvm_assign_pci_device(kvm_context_t kvm,
715 struct kvm_assigned_pci_dev *assigned_dev);
718 * \brief Notifies host kernel about changes to IRQ for an assigned device
720 * Used for PCI device assignment, this function notifies the host
721 * kernel about the changes in IRQ number for an assigned physical
722 * PCI device.
724 * \param kvm Pointer to the current kvm_context
725 * \param assigned_irq Parameters, like dev id, host irq, guest irq, etc
727 int kvm_assign_irq(kvm_context_t kvm,
728 struct kvm_assigned_irq *assigned_irq);
731 * \brief Determines whether destroying memory regions is allowed
733 * KVM before 2.6.29 had a bug when destroying memory regions.
735 * \param kvm Pointer to the current kvm_context
737 int kvm_destroy_memory_region_works(kvm_context_t kvm);
738 #endif
740 #ifdef KVM_CAP_DEVICE_DEASSIGNMENT
742 * \brief Notifies host kernel about a PCI device to be deassigned from a guest
744 * Used for hot remove PCI device, this function notifies the host
745 * kernel about the deassigning of the physical PCI device from a guest.
747 * \param kvm Pointer to the current kvm_context
748 * \param assigned_dev Parameters, like bus, devfn number, etc
750 int kvm_deassign_pci_device(kvm_context_t kvm,
751 struct kvm_assigned_pci_dev *assigned_dev);
752 #endif
755 * \brief Checks whether the generic irq routing capability is present
757 * Checks whether kvm can reroute interrupts among the various interrupt
758 * controllers.
760 * \param kvm Pointer to the current kvm_context
762 int kvm_has_gsi_routing(kvm_context_t kvm);
765 * \brief Determines the number of gsis that can be routed
767 * Returns the number of distinct gsis that can be routed by kvm. This is
768 * also the number of distinct routes (if a gsi has two routes, than another
769 * gsi cannot be used...)
771 * \param kvm Pointer to the current kvm_context
773 int kvm_get_gsi_count(kvm_context_t kvm);
776 * \brief Clears the temporary irq routing table
778 * Clears the temporary irq routing table. Nothing is committed to the
779 * running VM.
781 * \param kvm Pointer to the current kvm_context
783 int kvm_clear_gsi_routes(kvm_context_t kvm);
786 * \brief Adds an irq route to the temporary irq routing table
788 * Adds an irq route to the temporary irq routing table. Nothing is
789 * committed to the running VM.
791 * \param kvm Pointer to the current kvm_context
793 int kvm_add_irq_route(kvm_context_t kvm, int gsi, int irqchip, int pin);
796 * \brief Removes an irq route from the temporary irq routing table
798 * Adds an irq route to the temporary irq routing table. Nothing is
799 * committed to the running VM.
801 * \param kvm Pointer to the current kvm_context
803 int kvm_del_irq_route(kvm_context_t kvm, int gsi, int irqchip, int pin);
806 * \brief Commit the temporary irq routing table
808 * Commit the temporary irq routing table to the running VM.
810 * \param kvm Pointer to the current kvm_context
812 int kvm_commit_irq_routes(kvm_context_t kvm);
814 uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg);
816 #endif