From patchwork Mon Aug 25 13:27:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 35913 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77DDD20565 for ; Mon, 25 Aug 2014 13:28:46 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id v10sf39266307qac.4 for ; Mon, 25 Aug 2014 06:28:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=jMEZuFS/oaSUmTMKyMXcZi55Z5UvaHWDmrzYIa4fHH4=; b=HIFb/hOI3Pz4HfWVkR+g8bqO5i0G5ZetsH/80jXSN2zbtCzZ8KC2ef84wSUnwLaN9w xgvgXZHpPdQMt0/zilmSe3KDIs9jusdV5g0mYIuz0Fm4TgZ+ed7HDWasbeszijMp1kl6 sy3OR9abaMn4mIV9xYJO/Ozpp2SEL2QUxSQeB5vY2fjmVvy1htSNHDDlHSu10f3x3sbF YOamj2lLPIpIB/7XN1m+hyuCeXhymqamX9/GiZoEBqDgmSUfaH+frC366tFD/rm3o2SD ezhNjNYmAQIU+tVBJ+nv4atvXvXWZFD8Gvca0kVbRl5KOi10jdbKEEN7nWrQkaEQgpIl LnTQ== X-Gm-Message-State: ALoCoQnOBRqNEkK3WfgD44DBgwT0RLMJsxVdJUXjnDm2rk1K9LtUEf8/mSTk8PK0OKx1Dt33Ihbu X-Received: by 10.236.123.200 with SMTP id v48mr484765yhh.54.1408973326339; Mon, 25 Aug 2014 06:28:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.210 with SMTP id c76ls2129996qgd.56.gmail; Mon, 25 Aug 2014 06:28:46 -0700 (PDT) X-Received: by 10.52.88.74 with SMTP id be10mr2945307vdb.54.1408973326109; Mon, 25 Aug 2014 06:28:46 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id a7si17292610vdy.11.2014.08.25.06.28.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id im17so15110871vcb.17 for ; Mon, 25 Aug 2014 06:28:46 -0700 (PDT) X-Received: by 10.52.3.40 with SMTP id 8mr15606437vdz.24.1408973325998; Mon, 25 Aug 2014 06:28:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp117322vcb; Mon, 25 Aug 2014 06:28:45 -0700 (PDT) X-Received: by 10.180.103.168 with SMTP id fx8mr15756245wib.63.1408973324878; Mon, 25 Aug 2014 06:28:44 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id hi3si10701776wjc.113.2014.08.25.06.28.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.170 as permitted sender) client-ip=209.85.212.170; Received: by mail-wi0-f170.google.com with SMTP id f8so3697666wiw.5 for ; Mon, 25 Aug 2014 06:28:44 -0700 (PDT) X-Received: by 10.194.90.233 with SMTP id bz9mr9076761wjb.94.1408973324323; Mon, 25 Aug 2014 06:28: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 co6sm100101595wjb.31.2014.08.25.06.28.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28: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 Cc: linux-kernel@vger.kernel.org, patches@linaro.org, will.deacon@arm.com, a.motakis@virtualopensystems.com, a.rigo@virtualopensystems.com, john.liuli@huawei.com Subject: [RFC 4/9] KVM: KVM-VFIO: update user API to program forwarded IRQ Date: Mon, 25 Aug 2014 15:27:39 +0200 Message-Id: <1408973264-30384-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408973264-30384-1-git-send-email-eric.auger@linaro.org> References: <1408973264-30384-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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