pci-assign: Use PCI-2.3-based shared legacy interrupts
[qemu-kvm.git] / qemu-kvm.h
blob2b23dafbb48f80f0b928ed14feda8890fbb3171e
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);
117 int kvm_device_intx_set_mask(KVMState *s, uint32_t dev_id, bool masked);
120 * \brief Notifies host kernel about a PCI device to be deassigned from a guest
122 * Used for hot remove PCI device, this function notifies the host
123 * kernel about the deassigning of the physical PCI device from a guest.
125 * \param kvm Pointer to the current kvm_context
126 * \param assigned_dev Parameters, like bus, devfn number, etc
128 int kvm_deassign_pci_device(KVMState *s,
129 struct kvm_assigned_pci_dev *assigned_dev);
132 * \brief Clears the temporary irq routing table
134 * Clears the temporary irq routing table. Nothing is committed to the
135 * running VM.
138 int kvm_clear_gsi_routes(void);
141 * \brief Removes an irq route from the temporary irq routing table
143 * Adds an irq route to the temporary irq routing table. Nothing is
144 * committed to the running VM.
146 int kvm_del_irq_route(int gsi, int irqchip, int pin);
148 struct kvm_irq_routing_entry;
150 void kvm_add_routing_entry(KVMState *s, struct kvm_irq_routing_entry *entry);
153 * \brief Removes a routing from the temporary irq routing table
155 * Remove a routing to the temporary irq routing table. Nothing is
156 * committed to the running VM.
158 int kvm_del_routing_entry(struct kvm_irq_routing_entry *entry);
161 * \brief Updates a routing in the temporary irq routing table
163 * Update a routing in the temporary irq routing table
164 * with a new value. entry type and GSI can not be changed.
165 * Nothing is committed to the running VM.
167 int kvm_update_routing_entry(struct kvm_irq_routing_entry *entry,
168 struct kvm_irq_routing_entry *newentry);
171 int kvm_assign_set_msix_nr(KVMState *s, struct kvm_assigned_msix_nr *msix_nr);
172 int kvm_assign_set_msix_entry(KVMState *s,
173 struct kvm_assigned_msix_entry *entry);
175 #else /* !CONFIG_KVM */
177 struct kvm_pit_state {
180 #endif /* !CONFIG_KVM */
182 void kvm_hpet_enable_kpit(void);
183 void kvm_hpet_disable_kpit(void);
185 void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
187 int kvm_add_ioport_region(unsigned long start, unsigned long size,
188 bool is_hot_plug);
189 int kvm_remove_ioport_region(unsigned long start, unsigned long size,
190 bool is_hot_unplug);
192 int kvm_update_ioport_access(CPUState *env);
193 int kvm_arch_set_ioport_access(unsigned long start, unsigned long size,
194 bool enable);
196 int kvm_create_pit(KVMState *s);
198 extern int kvm_pit_reinject;
199 extern unsigned int kvm_shadow_memory;
201 int kvm_handle_tpr_access(CPUState *env);
202 void kvm_tpr_enable_vapic(CPUState *env);
204 #endif