From patchwork Thu Feb 11 14:34:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8280921 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 17A78BEEE5 for ; Thu, 11 Feb 2016 14:37:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21FC1203AC for ; Thu, 11 Feb 2016 14:37:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39F9B2035D for ; Thu, 11 Feb 2016 14:37:17 +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 1aTsLY-0004ww-1Z; Thu, 11 Feb 2016 14:35:52 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTsL3-0003Le-Cm for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2016 14:35:23 +0000 Received: by mail-wm0-x22a.google.com with SMTP id g62so71533514wme.0 for ; Thu, 11 Feb 2016 06:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i3FW+63Ncuxln/JNpMSbbUZHEKCYUSS45T2f/pM/I/k=; b=SqaEdcg8eODzQ1WTWbYDCWcaWUu95MFJZ7bfFv258MFyEwRiw88KbHHAyRSC1d2GN9 EhSdILwTjYg1VzVAhP3oD1ap1K/ftOHM46WkSmjaxTTQkN5Cn1cfYJlGnkjh5j8fObj4 95vspLfzhtslHeeuUvsmigp3R50o2GDVZ+pms= 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=i3FW+63Ncuxln/JNpMSbbUZHEKCYUSS45T2f/pM/I/k=; b=h5DJKC36LvvGkq4kaQB6wNKXnFRfDNNmBuEhEiNqr7xqlBpJd/tSpNTscZT/bRoum/ cCzNT/g7FDKsuIRVb0yKq2Kx6MFenr/Wikc8zLyo4DoCGZgkoeUDVW3oq0UGx/FiBcBx FyBLfbgjdPwC4yR7yCU9VUCtBR4irXXM6fYd5ej0SwZWfhg1MExAHSpfjCDHiQAKaYrt vRrvUTigYRpiPYgT4pzve8F+ADvPl3/CposdYEzAoYHCF7CTlmrOZYoP4k2xITlew8BB FOTQ4HCP9qxBrBPkK/faRbBM4hP5zWY2lIrFgysxE0ibyJiiu03fRLdcu5HaJ7IK2KZo Asag== X-Gm-Message-State: AG10YOQiqhUhCT/avIjhXv0wD3DaX5yapPByFYKjftQZrHpPiE6A98PZvUoXT9UDkfkCoYom X-Received: by 10.28.23.73 with SMTP id 70mr17295990wmx.37.1455201299714; Thu, 11 Feb 2016 06:34:59 -0800 (PST) Received: from new-host-12.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id t205sm8290751wmt.23.2016.02.11.06.34.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 06:34:57 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [RFC v2 02/15] vfio: expose MSI mapping requirement through VFIO_IOMMU_GET_INFO Date: Thu, 11 Feb 2016 14:34:09 +0000 Message-Id: <1455201262-5259-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455201262-5259-1-git-send-email-eric.auger@linaro.org> References: <1455201262-5259-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160211_063521_762866_DB315B6F X-CRM114-Status: GOOD ( 13.88 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas.Lendacky@amd.com, brijesh.singh@amd.com, patches@linaro.org, Manish.Jaggi@caviumnetworks.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com, leo.duran@amd.com, suravee.suthikulpanit@amd.com, sherry.hurwitz@amd.com 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=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 This patch allows the user-space to retrieve whether msi write transaction addresses must be mapped. This is returned through the VFIO_IOMMU_GET_INFO API and its new flag: VFIO_IOMMU_INFO_REQUIRE_MSI_MAP. Signed-off-by: Bharat Bhushan Signed-off-by: Eric Auger --- RFC v1 -> v1: - derived from [RFC PATCH 3/6] vfio: Extend iommu-info to return MSIs automap state - renamed allow_msi_reconfig into require_msi_mapping - fixed VFIO_IOMMU_GET_INFO --- drivers/vfio/vfio_iommu_type1.c | 26 ++++++++++++++++++++++++++ include/uapi/linux/vfio.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 6f1ea3d..c5b57e1 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -255,6 +255,29 @@ static int vaddr_get_pfn(unsigned long vaddr, int prot, unsigned long *pfn) } /* + * vfio_domains_require_msi_mapping: indicates whether MSI write transaction + * addresses must be mapped + * + * returns true if it does + */ +static bool vfio_domains_require_msi_mapping(struct vfio_iommu *iommu) +{ + struct vfio_domain *d; + bool ret; + + mutex_lock(&iommu->lock); + /* All domains have same require_msi_map property, pick first */ + d = list_first_entry(&iommu->domain_list, struct vfio_domain, next); + if (iommu_domain_get_attr(d->domain, DOMAIN_ATTR_MSI_MAPPING, NULL) < 0) + ret = false; + else + ret = true; + mutex_unlock(&iommu->lock); + + return ret; +} + +/* * Attempt to pin pages. We really don't want to track all the pfns and * the iommu can only map chunks of consecutive pfns anyway, so get the * first page and all consecutive pages with the same locking. @@ -997,6 +1020,9 @@ static long vfio_iommu_type1_ioctl(void *iommu_data, info.flags = VFIO_IOMMU_INFO_PGSIZES; + if (vfio_domains_require_msi_mapping(iommu)) + info.flags |= VFIO_IOMMU_INFO_REQUIRE_MSI_MAP; + info.iova_pgsizes = vfio_pgsize_bitmap(iommu); return copy_to_user((void __user *)arg, &info, minsz); diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 7d7a4c6..43e183b 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -400,6 +400,7 @@ struct vfio_iommu_type1_info { __u32 argsz; __u32 flags; #define VFIO_IOMMU_INFO_PGSIZES (1 << 0) /* supported page sizes info */ +#define VFIO_IOMMU_INFO_REQUIRE_MSI_MAP (1 << 1)/* MSI must be mapped */ __u64 iova_pgsizes; /* Bitmap of supported page sizes */ };