diff mbox

kvm: Add suport for KVM_EOI_EVENTFD

Message ID 20101029171113.8956.19058.stgit@s20.home (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Williamson Oct. 29, 2010, 5:12 p.m. UTC
None
diff mbox

Patch

diff --git a/kvm-all.c b/kvm-all.c
index 0e60748..75dbe76 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -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"
diff --git a/kvm.h b/kvm.h
index 02280a6..777904a 100644
--- a/kvm.h
+++ b/kvm.h
@@ -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);
diff --git a/kvm/include/linux/kvm.h b/kvm/include/linux/kvm.h
index e46729e..5490f62 100644
--- a/kvm/include/linux/kvm.h
+++ b/kvm/include/linux/kvm.h
@@ -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