aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2012-09-21 13:58:03 -0400
committerAvi Kivity <avi@redhat.com>2012-09-23 07:50:15 -0400
commit7a84428af7ca6a847f058c9ff244a18a2664fd1b (patch)
treee6c573c701736a75d618b670d66e98398b62769f /include
parent1e08ec4a130e2745d96df169e67c58df98a07311 (diff)
KVM: Add resampling irqfds for level triggered interrupts
To emulate level triggered interrupts, add a resample option to KVM_IRQFD. When specified, a new resamplefd is provided that notifies the user when the irqchip has been resampled by the VM. This may, for instance, indicate an EOI. Also in this mode, posting of an interrupt through an irqfd only asserts the interrupt. On resampling, the interrupt is automatically de-asserted prior to user notification. This enables level triggered interrupts to be posted and re-enabled from vfio with no userspace intervention. All resampling irqfds can make use of a single irq source ID, so we reserve a new one for this interface. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/kvm.h12
-rw-r--r--include/linux/kvm_host.h5
2 files changed, 15 insertions, 2 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index d808694673f9..0a6d6ba44c85 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -625,6 +625,7 @@ struct kvm_ppc_smmu_info {
625#ifdef __KVM_HAVE_READONLY_MEM 625#ifdef __KVM_HAVE_READONLY_MEM
626#define KVM_CAP_READONLY_MEM 81 626#define KVM_CAP_READONLY_MEM 81
627#endif 627#endif
628#define KVM_CAP_IRQFD_RESAMPLE 82
628 629
629#ifdef KVM_CAP_IRQ_ROUTING 630#ifdef KVM_CAP_IRQ_ROUTING
630 631
@@ -690,12 +691,21 @@ struct kvm_xen_hvm_config {
690#endif 691#endif
691 692
692#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 693#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
694/*
695 * Available with KVM_CAP_IRQFD_RESAMPLE
696 *
697 * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies
698 * the irqfd to operate in resampling mode for level triggered interrupt
699 * emlation. See Documentation/virtual/kvm/api.txt.
700 */
701#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
693 702
694struct kvm_irqfd { 703struct kvm_irqfd {
695 __u32 fd; 704 __u32 fd;
696 __u32 gsi; 705 __u32 gsi;
697 __u32 flags; 706 __u32 flags;
698 __u8 pad[20]; 707 __u32 resamplefd;
708 __u8 pad[16];
699}; 709};
700 710
701struct kvm_clock_data { 711struct kvm_clock_data {
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 80bfc880921e..2850656e2e96 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -119,7 +119,8 @@ static inline bool is_error_page(struct page *page)
119#define KVM_REQ_PMU 16 119#define KVM_REQ_PMU 16
120#define KVM_REQ_PMI 17 120#define KVM_REQ_PMI 17
121 121
122#define KVM_USERSPACE_IRQ_SOURCE_ID 0 122#define KVM_USERSPACE_IRQ_SOURCE_ID 0
123#define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID 1
123 124
124struct kvm; 125struct kvm;
125struct kvm_vcpu; 126struct kvm_vcpu;
@@ -343,6 +344,8 @@ struct kvm {
343 struct { 344 struct {
344 spinlock_t lock; 345 spinlock_t lock;
345 struct list_head items; 346 struct list_head items;
347 struct list_head resampler_list;
348 struct mutex resampler_lock;
346 } irqfds; 349 } irqfds;
347 struct list_head ioeventfds; 350 struct list_head ioeventfds;
348#endif 351#endif