kvm: Introduce kvm_has_intx_set_mask
[qemu-kvm.git] / qemu-kvm.h
blob3c4f023becc853fc14cd7303f2a39ecefe25c9e5
1 /*
2 * qemu/kvm integration
4 * Copyright (C) 2006-2008 Qumranet Technologies
6 * Licensed under the terms of the GNU GPL version 2 or higher.
7 */
8 #ifndef THE_ORIGINAL_AND_TRUE_QEMU_KVM_H
9 #define THE_ORIGINAL_AND_TRUE_QEMU_KVM_H
11 #include "cpu.h"
13 #include <signal.h>
14 #include <stdlib.h>
16 #ifdef CONFIG_KVM
18 #include <stdint.h>
20 #ifndef __user
21 #define __user /* temporary, until installed via make headers_install */
22 #endif
24 #include <linux/kvm.h>
26 #include <signal.h>
28 /* FIXME: share this number with kvm */
29 /* FIXME: or dynamically alloc/realloc regions */
30 #define KVM_MAX_NUM_MEM_REGIONS 32u
31 #define MAX_VCPUS 16
33 #include "kvm.h"
35 #if defined(__i386__) || defined(__x86_64__)
36 /*!
37 * \brief Get in kernel PIT of the virtual domain
39 * Save the PIT state.
41 * \param kvm Pointer to the current kvm_context
42 * \param s PIT state of the virtual domain
44 int kvm_get_pit(KVMState *s, struct kvm_pit_state *pit_state);
46 /*!
47 * \brief Set in kernel PIT of the virtual domain
49 * Restore the PIT state.
50 * Timer would be retriggerred after restored.
52 * \param kvm Pointer to the current kvm_context
53 * \param s PIT state of the virtual domain
55 int kvm_set_pit(KVMState *s, struct kvm_pit_state *pit_state);
57 int kvm_reinject_control(KVMState *s, int pit_reinject);
59 /*!
60 * \brief Set in kernel PIT state2 of the virtual domain
63 * \param kvm Pointer to the current kvm_context
64 * \param ps2 PIT state2 of the virtual domain
65 * \return 0 on success
67 int kvm_set_pit2(KVMState *s, struct kvm_pit_state2 *ps2);
69 /*!
70 * \brief Get in kernel PIT state2 of the virtual domain
73 * \param kvm Pointer to the current kvm_context
74 * \param ps2 PIT state2 of the virtual domain
75 * \return 0 on success
77 int kvm_get_pit2(KVMState *s, struct kvm_pit_state2 *ps2);
79 #endif
81 int kvm_enable_vapic(CPUState *env, uint64_t vapic);
83 /*!
84 * \brief Notifies host kernel about a PCI device to be assigned to a guest
86 * Used for PCI device assignment, this function notifies the host
87 * kernel about the assigning of the physical PCI device to a guest.
89 * \param kvm Pointer to the current kvm_context
90 * \param assigned_dev Parameters, like bus, devfn number, etc
92 int kvm_assign_pci_device(KVMState *s,
93 struct kvm_assigned_pci_dev *assigned_dev);
95 /*!
96 * \brief Assign IRQ for an assigned device
98 * Used for PCI device assignment, this function assigns IRQ numbers for
99 * an physical device and guest IRQ handling.
101 * \param kvm Pointer to the current kvm_context
102 * \param assigned_irq Parameters, like dev id, host irq, guest irq, etc
104 int kvm_assign_irq(KVMState *s, struct kvm_assigned_irq *assigned_irq);
107 * \brief Deassign IRQ for an assigned device
109 * Used for PCI device assignment, this function deassigns IRQ numbers
110 * for an assigned device.
112 * \param kvm Pointer to the current kvm_context
113 * \param assigned_irq Parameters, like dev id, host irq, guest irq, etc
115 int kvm_deassign_irq(KVMState *s, struct kvm_assigned_irq *assigned_irq);
118 * \brief Notifies host kernel about a PCI device to be deassigned from a guest
120 * Used for hot remove PCI device, this function notifies the host
121 * kernel about the deassigning of the physical PCI device from a guest.
123 * \param kvm Pointer to the current kvm_context
124 * \param assigned_dev Parameters, like bus, devfn number, etc
126 int kvm_deassign_pci_device(KVMState *s,
127 struct kvm_assigned_pci_dev *assigned_dev);
130 * \brief Clears the temporary irq routing table
132 * Clears the temporary irq routing table. Nothing is committed to the
133 * running VM.
136 int kvm_clear_gsi_routes(void);
139 * \brief Removes an irq route from the temporary irq routing table
141 * Adds an irq route to the temporary irq routing table. Nothing is
142 * committed to the running VM.
144 int kvm_del_irq_route(int gsi, int irqchip, int pin);
146 struct kvm_irq_routing_entry;
148 void kvm_add_routing_entry(KVMState *s, struct kvm_irq_routing_entry *entry);
151 * \brief Removes a routing from the temporary irq routing table
153 * Remove a routing to the temporary irq routing table. Nothing is
154 * committed to the running VM.
156 int kvm_del_routing_entry(struct kvm_irq_routing_entry *entry);
159 * \brief Updates a routing in the temporary irq routing table
161 * Update a routing in the temporary irq routing table
162 * with a new value. entry type and GSI can not be changed.
163 * Nothing is committed to the running VM.
165 int kvm_update_routing_entry(struct kvm_irq_routing_entry *entry,
166 struct kvm_irq_routing_entry *newentry);
169 int kvm_assign_set_msix_nr(KVMState *s, struct kvm_assigned_msix_nr *msix_nr);
170 int kvm_assign_set_msix_entry(KVMState *s,
171 struct kvm_assigned_msix_entry *entry);
173 #else /* !CONFIG_KVM */
175 struct kvm_pit_state {
178 #endif /* !CONFIG_KVM */
180 void kvm_hpet_enable_kpit(void);
181 void kvm_hpet_disable_kpit(void);
183 void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
185 int kvm_add_ioport_region(unsigned long start, unsigned long size,
186 bool is_hot_plug);
187 int kvm_remove_ioport_region(unsigned long start, unsigned long size,
188 bool is_hot_unplug);
190 int kvm_update_ioport_access(CPUState *env);
191 int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
192 bool enable);
194 int kvm_create_pit(KVMState *s);
196 extern int kvm_pit_reinject;
197 extern unsigned int kvm_shadow_memory;
199 int kvm_handle_tpr_access(CPUState *env);
200 void kvm_tpr_enable_vapic(CPUState *env);
202 #endif