mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: avi@redhat.com, mst@redhat.com
Cc: gleb@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v9 1/2] kvm: Use a reserved IRQ source ID for irqfd
Date: Tue, 21 Aug 2012 13:29:06 -0600	[thread overview]
Message-ID: <20120821192903.24958.90138.stgit@bling.home> (raw)
In-Reply-To: <20120821190800.24958.74812.stgit@bling.home>

KVM_IRQFD currently uses the reserved KVM_USERSPACE_IRQ_SOURCE_ID
which is also shared with userspace injection methods like
KVM_IRQ_LINE.  This can cause a conflict if an irqfd triggers on
a GSI asserted through KVM_IRQ_LINE.  Move irqfd to it's own
reserved IRQ source ID.  Add a capability for userspace to test
for this fix.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 arch/x86/kvm/x86.c       |    3 +++
 include/linux/kvm.h      |    1 +
 include/linux/kvm_host.h |    1 +
 virt/kvm/eventfd.c       |    6 +++---
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 42bce48..cd98673 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2174,6 +2174,7 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_GET_TSC_KHZ:
 	case KVM_CAP_PCI_2_3:
 	case KVM_CAP_KVMCLOCK_CTRL:
+	case KVM_CAP_IRQFD_IRQ_SOURCE_ID:
 		r = 1;
 		break;
 	case KVM_CAP_COALESCED_MMIO:
@@ -6258,6 +6259,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 	/* Reserve bit 0 of irq_sources_bitmap for userspace irq source */
 	set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap);
+	/* Reserve bit 1 of irq_sources_bitmap for irqfd irq source */
+	set_bit(KVM_IRQFD_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap);
 
 	raw_spin_lock_init(&kvm->arch.tsc_write_lock);
 
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 2ce09aa..ae66b9c 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -618,6 +618,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_PPC_GET_SMMU_INFO 78
 #define KVM_CAP_S390_COW 79
 #define KVM_CAP_PPC_ALLOC_HTAB 80
+#define KVM_CAP_IRQFD_IRQ_SOURCE_ID 81
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index b70b48b..b763230 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -71,6 +71,7 @@
 #define KVM_REQ_PMI               17
 
 #define KVM_USERSPACE_IRQ_SOURCE_ID	0
+#define KVM_IRQFD_IRQ_SOURCE_ID		1
 
 struct kvm;
 struct kvm_vcpu;
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 7d7e2aa..2245cfa 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -67,8 +67,8 @@ irqfd_inject(struct work_struct *work)
 	struct _irqfd *irqfd = container_of(work, struct _irqfd, inject);
 	struct kvm *kvm = irqfd->kvm;
 
-	kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1);
-	kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0);
+	kvm_set_irq(kvm, KVM_IRQFD_IRQ_SOURCE_ID, irqfd->gsi, 1);
+	kvm_set_irq(kvm, KVM_IRQFD_IRQ_SOURCE_ID, irqfd->gsi, 0);
 }
 
 /*
@@ -138,7 +138,7 @@ irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
 		irq = rcu_dereference(irqfd->irq_entry);
 		/* An event has been signaled, inject an interrupt */
 		if (irq)
-			kvm_set_msi(irq, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1);
+			kvm_set_msi(irq, kvm, KVM_IRQFD_IRQ_SOURCE_ID, 1);
 		else
 			schedule_work(&irqfd->inject);
 		rcu_read_unlock();


  reply	other threads:[~2012-08-21 19:29 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 19:28 [PATCH v9 0/2] kvm: level irqfd support Alex Williamson
2012-08-21 19:29 ` Alex Williamson [this message]
2012-08-21 19:58   ` [PATCH v9 1/2] kvm: Use a reserved IRQ source ID for irqfd Michael S. Tsirkin
2012-08-21 20:06     ` Alex Williamson
2012-08-21 20:41       ` Michael S. Tsirkin
2012-08-21 21:14         ` Alex Williamson
2012-08-22  0:41           ` Michael S. Tsirkin
2012-08-22  1:34             ` Alex Williamson
2012-09-05 14:35             ` Avi Kivity
2012-09-05 14:51               ` Michael S. Tsirkin
2012-09-05 14:59                 ` Avi Kivity
2012-09-05 15:13                   ` Michael S. Tsirkin
2012-09-05 15:22                     ` Avi Kivity
2012-09-05 15:28                       ` Michael S. Tsirkin
2012-09-05 15:35                         ` Avi Kivity
2012-09-05 15:09                 ` Michael S. Tsirkin
2012-09-05 15:12                   ` Avi Kivity
2012-09-05 15:15                     ` Michael S. Tsirkin
2012-09-05 14:46   ` Avi Kivity
2012-09-05 15:07     ` Michael S. Tsirkin
2012-09-05 15:15       ` Avi Kivity
2012-08-21 19:29 ` [PATCH v9 2/2] kvm: On Ack, De-assert & Notify KVM_IRQFD extension Alex Williamson
2012-08-21 20:37   ` Michael S. Tsirkin
2012-08-21 21:11     ` Alex Williamson
2012-08-22  0:14       ` Michael S. Tsirkin
2012-08-22  1:48         ` Alex Williamson
2012-09-05 14:57   ` Avi Kivity
2012-09-17 16:13     ` Alex Williamson
2012-08-22  0:31 ` [PATCH v9 0/2] kvm: level irqfd support Michael S. Tsirkin
2012-08-22  1:28   ` Alex Williamson
2012-08-22  8:25     ` Michael S. Tsirkin
2012-09-17 18:08       ` Alex Williamson
2012-08-22 10:10 ` Michael S. Tsirkin
2012-09-05 14:42 ` Avi Kivity
2012-09-05 14:52   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120821192903.24958.90138.stgit@bling.home \
    --to=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome