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 v8 4/6] kvm: Add assert-only option to KVM_IRQFD
Date: Fri, 10 Aug 2012 16:37:41 -0600 [thread overview]
Message-ID: <20120810223738.809.23098.stgit@bling.home> (raw)
In-Reply-To: <20120810223633.809.44188.stgit@bling.home>
This allows specifying that an irqfd is used only to assert the
specified gsi, whereas standard behavior is to follow the assertion
with a deassertion. This will later allow a level interrupt to be
asserted via eventfd and later de-asserted by other means.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
Documentation/virtual/kvm/api.txt | 6 ++++++
arch/x86/kvm/x86.c | 1 +
include/linux/kvm.h | 3 +++
virt/kvm/eventfd.c | 8 ++++++--
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 46f4b4d..17cd599 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1951,6 +1951,12 @@ KVM_IRQFD_FLAG_IRQ_SOURCE_ID which can be used to specify an IRQ
source ID (see KVM_IRQ_SOURCE_ID) to be used for the guest interrupt.
This flag has no effect on deassignment.
+When KVM_CAP_IRQFD_ASSERT_ONLY is available, KVM_IRQFD supports the
+KVM_IRQFD_FLAG_ASSERT_ONLY which specifies that an interrupt injected
+via the eventfd is only asserted. The default behavior is to assert
+then deassert the specified gsi when the eventfd is triggered. This
+flag has no effect on deassignment.
+
4.76 KVM_PPC_ALLOCATE_HTAB
Capability: KVM_CAP_PPC_ALLOC_HTAB
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 946c5bd..19680ed 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2175,6 +2175,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_PCI_2_3:
case KVM_CAP_KVMCLOCK_CTRL:
case KVM_CAP_IRQFD_IRQ_SOURCE_ID:
+ case KVM_CAP_IRQFD_ASSERT_ONLY:
r = 1;
break;
case KVM_CAP_COALESCED_MMIO:
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index deda8a9..19b1235 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -620,6 +620,7 @@ struct kvm_ppc_smmu_info {
#define KVM_CAP_PPC_ALLOC_HTAB 80
#define KVM_CAP_NR_IRQ_SOURCE_ID 81
#define KVM_CAP_IRQFD_IRQ_SOURCE_ID 82
+#define KVM_CAP_IRQFD_ASSERT_ONLY 83
#ifdef KVM_CAP_IRQ_ROUTING
@@ -687,6 +688,8 @@ struct kvm_xen_hvm_config {
#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
/* Available with KVM_CAP_IRQFD_IRQ_SOURCE_ID */
#define KVM_IRQFD_FLAG_IRQ_SOURCE_ID (1 << 1)
+/* Available with KVM_CAP_IRQFD_ASSERT_ONLY */
+#define KVM_IRQFD_FLAG_ASSERT_ONLY (1 << 2)
struct kvm_irqfd {
__u32 fd;
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 30150f1..df41038 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -52,6 +52,7 @@ struct _irqfd {
/* Used for level IRQ fast-path */
int gsi;
int irq_source_id;
+ bool assert_only;
struct work_struct inject;
/* Used for setup/shutdown */
struct eventfd_ctx *eventfd;
@@ -69,7 +70,8 @@ irqfd_inject(struct work_struct *work)
struct kvm *kvm = irqfd->kvm;
kvm_set_irq(kvm, irqfd->irq_source_id, irqfd->gsi, 1);
- kvm_set_irq(kvm, irqfd->irq_source_id, irqfd->gsi, 0);
+ if (!irqfd->assert_only)
+ kvm_set_irq(kvm, irqfd->irq_source_id, irqfd->gsi, 0);
}
/*
@@ -218,6 +220,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
irqfd->irq_source_id = args->irq_source_id;
else
irqfd->irq_source_id = KVM_USERSPACE_IRQ_SOURCE_ID;
+ irqfd->assert_only = args->flags & KVM_IRQFD_FLAG_ASSERT_ONLY;
INIT_LIST_HEAD(&irqfd->list);
INIT_WORK(&irqfd->inject, irqfd_inject);
INIT_WORK(&irqfd->shutdown, irqfd_shutdown);
@@ -346,7 +349,8 @@ int
kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
{
if (args->flags & ~(KVM_IRQFD_FLAG_DEASSIGN |
- KVM_IRQFD_FLAG_IRQ_SOURCE_ID))
+ KVM_IRQFD_FLAG_IRQ_SOURCE_ID |
+ KVM_IRQFD_FLAG_ASSERT_ONLY))
return -EINVAL;
if (args->flags & KVM_IRQFD_FLAG_DEASSIGN)
next prev parent reply other threads:[~2012-08-10 22:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 22:37 [PATCH v8 0/6] kvm: level irqfd support Alex Williamson
2012-08-10 22:37 ` [PATCH v8 1/6] kvm: Allow filtering of acked irqs Alex Williamson
2012-08-15 12:27 ` Michael S. Tsirkin
2012-08-15 16:47 ` Alex Williamson
2012-08-15 19:24 ` Michael S. Tsirkin
2012-08-10 22:37 ` [PATCH v8 2/6] kvm: Expose IRQ source IDs to userspace Alex Williamson
2012-08-15 12:59 ` Michael S. Tsirkin
2012-08-15 17:05 ` Alex Williamson
2012-08-10 22:37 ` [PATCH v8 3/6] kvm: Add IRQ source ID option to KVM_IRQFD Alex Williamson
2012-08-15 13:49 ` Michael S. Tsirkin
2012-08-15 17:08 ` Alex Williamson
2012-08-10 22:37 ` Alex Williamson [this message]
2012-08-10 22:37 ` [PATCH v8 5/6] kvm: KVM_IRQ_ACKFD Alex Williamson
2012-08-15 14:05 ` Michael S. Tsirkin
2012-08-15 17:17 ` Alex Williamson
2012-08-10 22:37 ` [PATCH v8 6/6] kvm: Add de-assert option to KVM_IRQ_ACKFD Alex Williamson
2012-08-15 14:11 ` Michael S. Tsirkin
2012-08-15 17:24 ` Alex Williamson
2012-08-15 14:28 ` [PATCH v8 0/6] kvm: level irqfd support Michael S. Tsirkin
2012-08-15 17:36 ` Alex Williamson
2012-08-15 19:22 ` Michael S. Tsirkin
2012-08-15 19:59 ` Alex Williamson
2012-08-16 12:34 ` Alex Williamson
2012-08-16 12:53 ` Michael S. Tsirkin
2012-08-16 16:29 ` Avi Kivity
2012-08-16 16:36 ` Michael S. Tsirkin
2012-08-16 16:39 ` Avi Kivity
2012-08-16 16:54 ` Michael S. Tsirkin
2012-08-16 16:54 ` Avi Kivity
2012-08-16 17:01 ` Michael S. Tsirkin
2012-08-16 16:37 ` Alex Williamson
2012-08-16 16:32 ` Avi Kivity
2012-08-16 16:45 ` Alex Williamson
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=20120810223738.809.23098.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;
as well as URLs for NNTP newsgroup(s).