From patchwork Mon Aug 6 12:27:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 10557037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5B1D157B for ; Mon, 6 Aug 2018 12:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9287E293C6 for ; Mon, 6 Aug 2018 12:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86B69293CB; Mon, 6 Aug 2018 12:40:23 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 EEBE2293C6 for ; Mon, 6 Aug 2018 12:40:22 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=diWhMB56D7QJjOKJHqu3zTCGMF9oBuqlqew3q0/b1io=; b=h2vJWSeMiWYw77 DqYB4aSryBAbYutUmp+7Gnhe2+5d5uAHFMxJqR02rtQeFEgaJBl427FV0Iu8CJlCeYi5T7WiciZe0 MkkxhGFE6kzqLb6xO/+m4nDSgAz4mR2prmVQY22iJBwNEZukGMpLIskKkCBDq2SIFxtSXS38CS8xw 0aaPrQS44RlAcXfT0HCIH1IqOY51dE8wMW7yuJLJoUcVvb+otsMh9m43/wYpRUglZGFq75UOY7f0H drLR6C589y8ZwzLz9gMpXDqB6Zfn4DbwH+qYQNPtOJN0+Xp5cJZkSU8V1uT7rmsNab5/BnJ6mZQkH GHYXHVjBdAAqSbbMJNhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmeo7-0004EU-Ne; Mon, 06 Aug 2018 12:40:19 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmecH-0004uh-JX for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 12:28:12 +0000 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 83F3F1D0FA220; Mon, 6 Aug 2018 20:27:49 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.399.0; Mon, 6 Aug 2018 20:27:44 +0800 From: Zhen Lei To: Robin Murphy , Will Deacon , Joerg Roedel , linux-arm-kernel , iommu , linux-kernel Subject: [PATCH v4 5/5] iommu/arm-smmu-v3: add bootup option "arm_iommu" Date: Mon, 6 Aug 2018 20:27:04 +0800 Message-ID: <1533558424-16748-6-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1533558424-16748-1-git-send-email-thunder.leizhen@huawei.com> References: <1533558424-16748-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_052805_925219_64453F31 X-CRM114-Status: GOOD ( 12.78 ) 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: Hanjun Guo , LinuxArm , Libin , Zhen Lei 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 Add a bootup option to make the system manager can choose which mode to be used. The default mode is strict. Signed-off-by: Zhen Lei --- Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++ drivers/iommu/arm-smmu-v3.c | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) -- 1.8.3 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 533ff5c..426e989 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1720,6 +1720,15 @@ nobypass [PPC/POWERNV] Disable IOMMU bypass, using IOMMU for PCI devices. + arm_iommu= [ARM64] + non-strict [Default Off] + Put off TLBs invalidation and release memory first. + It's good for scatter-gather performance but lacks full + isolation, an untrusted device can access the reused + memory because the TLBs may still valid. Please take + full consideration before choosing this mode. + Note that, VFIO will always use strict mode. + iommu.passthrough= [ARM64] Configure DMA to bypass the IOMMU by default. Format: { "0" | "1" } diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 904bc1e..9a30892 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -631,6 +631,21 @@ struct arm_smmu_option_prop { { 0, NULL}, }; +static u32 smmu_non_strict __read_mostly; + +static int __init arm_smmu_setup(char *str) +{ + if (!strncmp(str, "non-strict", 10)) { + smmu_non_strict = 1; + pr_warn("WARNING: iommu non-strict mode is chosen.\n" + "It's good for scatter-gather performance but lacks full isolation\n"); + add_taint(TAINT_WARN, LOCKDEP_STILL_OK); + } + + return 0; +} +early_param("arm_iommu", arm_smmu_setup); + static inline void __iomem *arm_smmu_page1_fixup(unsigned long offset, struct arm_smmu_device *smmu) { @@ -1622,7 +1637,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain) if (smmu->features & ARM_SMMU_FEAT_COHERENCY) pgtbl_cfg.quirks = IO_PGTABLE_QUIRK_NO_DMA; - if (domain->type == IOMMU_DOMAIN_DMA) { + if ((domain->type == IOMMU_DOMAIN_DMA) && smmu_non_strict) { domain->non_strict = 1; pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT; }