From patchwork Mon Sep 1 12:52:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 4819141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5858AC0338 for ; Mon, 1 Sep 2014 12:56:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A02A2013A for ; Mon, 1 Sep 2014 12:56:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B10D2016C for ; Mon, 1 Sep 2014 12:56:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XOR7s-0001MT-0A; Mon, 01 Sep 2014 12:54:28 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XOR7W-0000z5-Qm for linux-arm-kernel@lists.infradead.org; Mon, 01 Sep 2014 12:54:07 +0000 Received: by mail-wg0-f45.google.com with SMTP id k14so5276019wgh.4 for ; Mon, 01 Sep 2014 05:53:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AHAX+77uTqlmj5Ax6AhDKOfRw4M4xiXOYff3RvKJh/w=; b=fIvRl6LyMhUpb836AqeAMQcEHxspYj933WSpCVBBsnrmKMEgaJlbvOyxeQD/gyo2Rs A34CvA/yB5uPpaxXZWb01cYaov+VKvI8CoaTSlvCooXXC95aQhw8srFG6psEHZ+Hfxb3 z47wR2cRAKg85F5hd0lDNqQ9Jv59LDoGG58LQzgmFy+n/iaQLSOri0PwFbhtQLPqhnwP 6qDMCThVTm946+qZPLYx6jj6ZI6V9x/lboEi17/Dc7QJnNokysqA/OU8H65gZVeyhcGd y2XyJhwYlZyK6tFiwLBr+r2GMJ5qlsbK1BVBD7V8TfCUZo/r/PTQRTLxKk5uhtaSYZdX povQ== X-Gm-Message-State: ALoCoQloz5icD57KAbcsMc3EFkHXvvp7nk7y8ltfQ7dLesJgqbA8ho4hgrKNhSBF5YRfmi/x1tbx X-Received: by 10.194.122.6 with SMTP id lo6mr31825678wjb.17.1409576024266; Mon, 01 Sep 2014 05:53:44 -0700 (PDT) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id y5sm1928678wje.32.2014.09.01.05.53.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:43 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, joel.schopp@amd.com, kim.phillips@freescale.com, paulus@samba.org, gleb@kernel.org, pbonzini@redhat.com Subject: [RFC v2 5/9] KVM: KVM-VFIO: update user API to program forwarded IRQ Date: Mon, 1 Sep 2014 14:52:44 +0200 Message-Id: <1409575968-5329-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> References: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140901_055407_020013_FC9AD71F X-CRM114-Status: GOOD ( 13.63 ) X-Spam-Score: -0.7 (/) Cc: patches@linaro.org, john.liuli@huawei.com, will.deacon@arm.com, a.rigo@virtualopensystems.com, linux-kernel@vger.kernel.org, a.motakis@virtualopensystems.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP add new device group commands: - KVM_DEV_VFIO_DEVICE_FORWARD_IRQ and KVM_DEV_VFIO_DEVICE_UNFORWARD_IRQ which enable to turn forwarded IRQ mode on/off. the kvm_arch_forwarded_irq struct embodies a forwarded IRQ Signed-off-by: Eric Auger --- v1 -> v2: - struct kvm_arch_forwarded_irq moved from arch/arm/include/uapi/asm/kvm.h to include/uapi/linux/kvm.h also irq_index renamed into index and guest_irq renamed into gsi - ASSIGN/DEASSIGN renamed into FORWARD/UNFORWARD --- Documentation/virtual/kvm/devices/vfio.txt | 26 ++++++++++++++++++++++++++ include/uapi/linux/kvm.h | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/Documentation/virtual/kvm/devices/vfio.txt b/Documentation/virtual/kvm/devices/vfio.txt index ef51740..048baa0 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,28 @@ 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_FORWARD_IRQ + KVM_DEV_VFIO_DEVICE_UNFORWARD_IRQ + +For each, kvm_device_attr.addr points to a kvm_arch_forwarded_irq struct. +This user API makes possible to create a special IRQ handling mode, +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 index, is injected into the VM guest irq (gsi). + +On FORWARD_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 avoids trapping the end-of-interrupt for level sensitive IRQ. + +On UNFORWARD_IRQ, one returns to the mode where the host completes the +physical IRQ and the guest completes the virtual IRQ. + +It is up to the caller of this API to make sure the IRQ is not +outstanding when the FORWARD/UNFORWARD is called. This could lead to +some inconsistency on who is going to complete the IRQ. diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index cf3a2ff..8cd7b0e 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -947,6 +947,12 @@ struct kvm_device_attr { __u64 addr; /* userspace address of attr data */ }; +struct kvm_arch_forwarded_irq { + __u32 fd; /* file desciptor of the VFIO device */ + __u32 index; /* VFIO device IRQ index */ + __u32 gsi; /* gsi, ie. virtual IRQ number */ +}; + #define KVM_DEV_TYPE_FSL_MPIC_20 1 #define KVM_DEV_TYPE_FSL_MPIC_42 2 #define KVM_DEV_TYPE_XICS 3 @@ -954,6 +960,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_FORWARD_IRQ 1 +#define KVM_DEV_VFIO_DEVICE_UNFORWARD_IRQ 2 #define KVM_DEV_TYPE_ARM_VGIC_V2 5 #define KVM_DEV_TYPE_FLIC 6