linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: eric.auger@linaro.org (Eric Auger)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 4/9] KVM: KVM-VFIO: update user API to program forwarded IRQ
Date: Mon, 25 Aug 2014 15:27:39 +0200	[thread overview]
Message-ID: <1408973264-30384-5-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1408973264-30384-1-git-send-email-eric.auger@linaro.org>

add new device group commands:
- KVM_DEV_VFIO_DEVICE_ASSIGN_IRQ and
  KVM_DEV_VFIO_DEVICE_DEASSIGN_IRQ

which enable to turn forwarded IRQ mode on/off.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
 Documentation/virtual/kvm/devices/vfio.txt | 25 +++++++++++++++++++++++++
 arch/arm/include/uapi/asm/kvm.h            |  6 ++++++
 include/uapi/linux/kvm.h                   |  3 +++
 3 files changed, 34 insertions(+)

diff --git a/Documentation/virtual/kvm/devices/vfio.txt b/Documentation/virtual/kvm/devices/vfio.txt
index ef51740..c8b3fa1 100644
--- a/Documentation/virtual/kvm/devices/vfio.txt
+++ b/Documentation/virtual/kvm/devices/vfio.txt
@@ -13,6 +13,7 @@ VFIO-group is held by KVM.
 
 Groups:
   KVM_DEV_VFIO_GROUP
+  KVM_DEV_VFIO_DEVICE
 
 KVM_DEV_VFIO_GROUP attributes:
   KVM_DEV_VFIO_GROUP_ADD: Add a VFIO group to VFIO-KVM device tracking
@@ -20,3 +21,27 @@ KVM_DEV_VFIO_GROUP attributes:
 
 For each, kvm_device_attr.addr points to an int32_t file descriptor
 for the VFIO group.
+
+KVM_DEV_VFIO_DEVICE attributes:
+  KVM_DEV_VFIO_DEVICE_ASSIGN_IRQ
+  KVM_DEV_VFIO_DEVICE_DEASSIGN_IRQ
+
+For each, kvm_device_attr.addr points to an kvm_arch_forwarded_irq.
+This user API makes possible to create a special IRQ handling mode,
+currently supported only on ARM, where KVM and a VFIO platform driver
+collaborate to improve IRQ handling performance.
+fd represents the file descriptor of a valid VFIO device whose physical
+IRQ, referenced by its irq_index is injected to the VM guest_irq.
+
+On ASSIGN_IRQ, KVM-VFIO device programs:
+- the host, to not complete the physical IRQ itself.
+- the GIC, to automatically complete the physical IRQ when the guest
+  completes the virtual IRQ
+This avoid trapping the end-of-interrupt for level sensitive IRQ.
+
+On DEASSIGN_IRQ, one come back to the mode where the host completes the
+physical IRQ and the guest only completes the virtual IRQ.
+
+It is up to the caller of this API to get the assurance the IRQ is not
+outstanding when the ASSIGN/DEASSIGN is called. This could lead to some
+inconsistency on who is going to complete the IRQ.
diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
index 3034c66..1920b33 100644
--- a/arch/arm/include/uapi/asm/kvm.h
+++ b/arch/arm/include/uapi/asm/kvm.h
@@ -109,6 +109,12 @@ struct kvm_sync_regs {
 struct kvm_arch_memory_slot {
 };
 
+struct kvm_arch_forwarded_irq {
+	__u32 fd; /* file desciptor of the VFIO device */
+	__u32 irq_index; /* platform device index of the IRQ */
+	__u32 guest_irq; /* virtual IRQ number */
+};
+
 /* If you need to interpret the index values, here is the key: */
 #define KVM_REG_ARM_COPROC_MASK		0x000000000FFF0000
 #define KVM_REG_ARM_COPROC_SHIFT	16
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index cf3a2ff..b149ba8 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -954,6 +954,9 @@ struct kvm_device_attr {
 #define  KVM_DEV_VFIO_GROUP			1
 #define   KVM_DEV_VFIO_GROUP_ADD			1
 #define   KVM_DEV_VFIO_GROUP_DEL			2
+#define  KVM_DEV_VFIO_DEVICE			2
+#define   KVM_DEV_VFIO_DEVICE_ASSIGN_IRQ			1
+#define   KVM_DEV_VFIO_DEVICE_DEASSIGN_IRQ			2
 #define KVM_DEV_TYPE_ARM_VGIC_V2	5
 #define KVM_DEV_TYPE_FLIC		6
 
-- 
1.9.1

  parent reply	other threads:[~2014-08-25 13:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-25 13:27 [RFC 0/9] KVM-VFIO IRQ forward control Eric Auger
2014-08-25 13:27 ` [RFC 1/9] KVM: ARM: VGIC: fix multiple injection of level sensitive forwarded IRQ Eric Auger
2014-08-25 13:27 ` [RFC 2/9] KVM: ARM: VGIC: add forwarded irq rbtree lock Eric Auger
2014-08-25 13:27 ` [RFC 3/9] VFIO: platform: handler tests whether the IRQ is forwarded Eric Auger
2014-08-25 13:27 ` Eric Auger [this message]
2014-08-26 19:01   ` [RFC 4/9] KVM: KVM-VFIO: update user API to program forwarded IRQ Alex Williamson
2014-08-27 15:19     ` Eric Auger
2014-08-25 13:27 ` [RFC 5/9] VFIO: Extend external user API Eric Auger
2014-08-26 19:02   ` Alex Williamson
2014-08-27 15:20     ` Eric Auger
2014-08-25 13:27 ` [RFC 6/9] KVM: KVM-VFIO: allow arch specific implementation Eric Auger
2014-08-25 13:27 ` [RFC 7/9] KVM: KVM-VFIO: add new VFIO external API hooks Eric Auger
2014-08-25 13:27 ` [RFC 8/9] KVM: KVM-VFIO: add kvm_vfio_arch_data and accessors Eric Auger
2014-08-26 19:02   ` Alex Williamson
2014-08-27 15:22     ` Eric Auger
2014-08-27 15:37       ` Alex Williamson
2014-08-27 15:42         ` Eric Auger
2014-08-25 13:27 ` [RFC 9/9] KVM: KVM_VFIO: ARM: implement irq forwarding control Eric Auger
2014-08-26 19:02   ` Alex Williamson
2014-08-27 15:24     ` Eric Auger
2014-08-26 17:49 ` [RFC 0/9] KVM-VFIO IRQ forward control Alex Williamson
2014-08-27 15:10   ` Eric Auger

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=1408973264-30384-5-git-send-email-eric.auger@linaro.org \
    --to=eric.auger@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).