@@ -1349,5 +1349,24 @@ int kvm_set_irqfd(int gsi, int fd, bool assigned)
}
#endif
+#if defined(KVM_EOI_EVENTFD)
+int kvm_eoi_eventfd(int gsi, int fd, uint32_t flags)
+{
+ struct kvm_eoi eoi = {
+ .fd = fd,
+ .gsi = gsi,
+ .flags = flags,
+ };
+ int r;
+
+ if (!kvm_enabled() || !kvm_irqchip_in_kernel())
+ return -ENOSYS;
+
+ r = kvm_vm_ioctl(kvm_state, KVM_EOI_EVENTFD, &eoi);
+ if (r < 0)
+ return r;
+ return 0;
+}
+#endif
#undef PAGE_SIZE
#include "qemu-kvm.c"
@@ -203,6 +203,16 @@ int kvm_set_irqfd(int gsi, int fd, bool assigned)
}
#endif
+#if defined(KVM_EOI_EVENTFD) && defined(CONFIG_KVM)
+int kvm_eoi_eventfd(int gsi, int fd, uint32_t flags);
+#else
+static inline
+int kvm_eoi_eventfd(int gsi, int fd, uint32_t flags)
+{
+ return -ENOSYS;
+}
+#endif
+
int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign);
int kvm_has_gsi_routing(void);
@@ -530,6 +530,7 @@ struct kvm_enable_cap {
#ifdef __KVM_HAVE_XCRS
#define KVM_CAP_XCRS 56
#endif
+#define KVM_CAP_EOI_EVENTFD 60
#ifdef KVM_CAP_IRQ_ROUTING
@@ -609,6 +610,16 @@ struct kvm_clock_data {
__u32 pad[9];
};
+#define KVM_EOI_EVENTFD_FLAG_DEASSIGN (1 << 0)
+#define KVM_EOI_EVENTFD_FLAG_DEASSERT (1 << 1)
+
+struct kvm_eoi {
+ __u32 fd;
+ __u32 gsi;
+ __u32 flags;
+ __u8 pad[20];
+};
+
/*
* ioctls for VM fds
*/
@@ -663,6 +674,8 @@ struct kvm_clock_data {
/* Available with KVM_CAP_PIT_STATE2 */
#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
+/* Available with KVM_CAP_EOI_EVENTFD */
+#define KVM_EOI_EVENTFD _IOW(KVMIO, 0xa2, struct kvm_eoi)
/*
* ioctls for vcpu fds