From patchwork Wed Jul 19 09:33:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9850909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2608602C8 for ; Wed, 19 Jul 2017 09:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE1FE203B9 for ; Wed, 19 Jul 2017 09:36:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B21DE28621; Wed, 19 Jul 2017 09:36:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3FAB3203B9 for ; Wed, 19 Jul 2017 09:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AqIpflRc4zSSP2gEfmT6OaRa3RzhpAf/MeVs1KWaZSM=; b=KaKhkfDKMkO/ibJbXFZsLi6h+m /r+EJDDlL7g//gmeVANdA64zPP7YyceNBZBXif1iphpdhgVfWbuzWn8qP7XYvqcLspW2TaoiVMx3H T890UlpGCKJbhHcqCfDuKYk7d9khc4hUHYGZekDEF5t57p3Edt8RL3buqriplkRIII2T6vBDMZgQT 0rQwHKZuKaRFzHrNwhMjC9t7wzPJTcxRqEAg+IqVjLIXkES2le5XXw0gXKDeVA+jQZapDKa6ocx5b bIUMWLrnMCSioC5vd45jmRrurMcDSwguaAlYfB3WsHPX6xp7RMsnoVeyE4kkWZQuVE0+Z4FlDejaw BVuN771w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dXlP6-0003s6-1R; Wed, 19 Jul 2017 09:36:24 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXlOJ-0002o1-QX for linux-arm-kernel@lists.infradead.org; Wed, 19 Jul 2017 09:35:43 +0000 Received: by mail-wm0-x230.google.com with SMTP id g127so9896606wmd.0 for ; Wed, 19 Jul 2017 02:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bl8jp8/1x34FRJUeY5xsZ7o3FJjb17KyjmIogXIwyeg=; b=HR97UXnYwLqtBPCHIrQfzOTqoCuYTGIo0LC54H/1WLA1NB9oFd5xzdZhhxeJlqanqw iWzA3uQ8IK+Q9nDBDf3oc0zKoLUPJDFN+qvMKwBj9FtnIrMiju5tVVC2KdoBzdmUQHVc OeP+5LamvWKt6HBQOWb2Gq/tHxDaynwBWpEHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bl8jp8/1x34FRJUeY5xsZ7o3FJjb17KyjmIogXIwyeg=; b=AEElomiyoZW8l3x/pajIOkP6eF5efgHrK/Q8HjkG8ciHW4K5bRhhoAf66OX59iUsT5 JoVBOtDNYssvjmOXLR+nlseib0fwTNB97i6xLuYFzehmw9laaJnBCl4JfBEGd3dwyjBm DMa0D5zNibtBYz7spReDKBtBJ1W3MbKTPMDoXYRRmgJBWeJYJXAP8KXNCCCvuPgMTldN y+QbhudqBCg4Cke75ERupQuqmDBsvlO+j+WQVyAzds+eSiP8y5MTKd3WLjqgsstEKObq KzXvwONT3GYPFbXYjNIPAZbqKpvupG2XywQzogsjljJ+VRTfLn5ngjZ5Qy8+4jq6JoXO Qb+g== X-Gm-Message-State: AIVw113D3j+7MCBhKDG9p0tbavUeSSDGl/KX+XbSKTwoW/ObawIrDsDY Fld1tSNNGmedXCk9 X-Received: by 10.28.8.144 with SMTP id 138mr4939425wmi.8.1500456913665; Wed, 19 Jul 2017 02:35:13 -0700 (PDT) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id y12sm8227473wrb.39.2017.07.19.02.35.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jul 2017 02:35:13 -0700 (PDT) From: Anup Patel To: Will Deacon , Robin Murphy , Joerg Roedel , Baptiste Reynal , Alex Williamson Subject: [PATCH 4/5] vfio: Allow No-IOMMU mode for IOMMUs with bypass capability Date: Wed, 19 Jul 2017 15:03:57 +0530 Message-Id: <1500456838-18405-5-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500456838-18405-1-git-send-email-anup.patel@broadcom.com> References: <1500456838-18405-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170719_023537_005174_3CA74E48 X-CRM114-Status: GOOD ( 12.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Scott Branden , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, Anup Patel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Not allowing No-IOMMU mode for devices already having iommu_ops on their bus is little conservative. We now have IOMMU (such as ARM SMMU) which can bypass transcations for which IOMMU domain is not configured hence No-IOMMU mode should not be allowed when iommu_ops are available and IOMMU_CAP_BYPASS is not available. Signed-off-by: Anup Patel --- drivers/vfio/vfio.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 330d505..61f3807 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -124,11 +124,18 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) #ifdef CONFIG_VFIO_NOIOMMU /* * With noiommu enabled, an IOMMU group will be created for a device - * that doesn't already have one and doesn't have an iommu_ops on their - * bus. We set iommudata simply to be able to identify these groups + * that: + * 1. Doesn't already have IOMMU group + * 2. Doesn't have an iommu_ops on their bus + * 3. Doesn't have transaction bypass capability if iommu_ops + * is available on their bus + * + * We set iommudata simply to be able to identify these groups * as special use and for reclamation later. */ - if (group || !noiommu || iommu_present(dev->bus)) + if (group || !noiommu || + (iommu_present(dev->bus) && + !iommu_capable(dev->bus, IOMMU_CAP_BYPASS))) return group; group = iommu_group_alloc();