From patchwork Wed Aug 15 01:28:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 144259 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp249628ljj; Tue, 14 Aug 2018 18:32:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwDW/QCwvbqqAIB87c7eyp4H5tTK34pAyuqKHSLr5jLHHmrkYI6QZY6JsrEKtYgK8aerf9P X-Received: by 2002:a63:24c:: with SMTP id 73-v6mr23730502pgc.252.1534296768449; Tue, 14 Aug 2018 18:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534296768; cv=none; d=google.com; s=arc-20160816; b=PKKVjj+4Sh3rADS74qlH98wG8u7qgxe0UXt55nIAX57AjtHqvEHBWToDh5fC/1jtIj MivqFUl1gi3orUFp49M1pgILMKEqRB+v4ctWTXsWypMXzZ2ZjtZ/BdRySvOZUWUqFp+h 1Wj66iNhGk/5nPkH6UhoKMCJy0uWHNgOFtKDCc2a5HTBDHXgzSNcb5Ys9zMCp8ZauV5T UvF5SgwM9BxZO2csEZG/wxFeWlDIy5YeZrOxGuMH4RAcL0OXaSB77l7Dx6aueXUcbhvQ 92aLptcXVTkqS4mjKTHWFWfBOwLFcDdvMkiFWCMaixKwBC1QfBDWSyivAicdolZcL7en oOqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=c2qYry4B0b2KU9VYW8Qj2Ur3iXZyAIlSlbpa2aPlB9k=; b=sqkXdmFfCppQ8aotlDKn2iPYSxdKCB0mBwxh9t/81kviPkbkYb6wZ9x/puL5xKTDxM paZEHyw1xebSMbx8gkxDUxVNFmWGFzFmCGCdEGHuekI6RpMjKbYKTPbh3eiBBUb+niG+ Lz3JWHisfZVDEcr077w+eBS7BF7xXY1DfQ6FU1kjAGJcQgtmSH2r8dZo2HbMyB2d3Tot lwxsx+lu0+kgXqJ2eLg5FRroGFu0VaeDWnvvB2y4Td/sERYNQW2XeB54BK8FvCPKRxdu JnbrEa52AvuKzyEhlUhGu1BaI3pTakNubcA7x8KZcwfuQG82ZDGNhqHJC6IYSqe7iCKW YeBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si11524010plq.285.2018.08.14.18.32.48; Tue, 14 Aug 2018 18:32:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728472AbeHOEWi (ORCPT + 32 others); Wed, 15 Aug 2018 00:22:38 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10726 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725847AbeHOEWh (ORCPT ); Wed, 15 Aug 2018 00:22:37 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6F72B8C1BE635; Wed, 15 Aug 2018 09:32:42 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 09:32:33 +0800 From: Zhen Lei To: Robin Murphy , Will Deacon , Joerg Roedel , linux-arm-kernel , iommu , linux-kernel CC: Zhen Lei , LinuxArm , Hanjun Guo , Libin , "John Garry" Subject: [PATCH v5 5/5] iommu/arm-smmu-v3: add bootup option "iommu.non_strict" Date: Wed, 15 Aug 2018 09:28:30 +0800 Message-ID: <1534296510-12888-6-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1534296510-12888-1-git-send-email-thunder.leizhen@huawei.com> References: <1534296510-12888-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 13 +++++++++++++ drivers/iommu/arm-smmu-v3.c | 22 +++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) -- 1.8.3 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 5cde1ff..cb9d043e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1720,6 +1720,19 @@ nobypass [PPC/POWERNV] Disable IOMMU bypass, using IOMMU for PCI devices. + iommu.non_strict= [ARM64] + Format: { "0" | "1" } + 0 - strict mode, default. + Release IOVAs after the related TLBs are invalid + completely. + 1 - non-strict mode. + 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 61eb7ec..0eda90e 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -631,6 +631,26 @@ struct arm_smmu_option_prop { { 0, NULL}, }; +static bool smmu_non_strict __read_mostly; + +static int __init arm_smmu_setup(char *str) +{ + int ret; + + ret = kstrtobool(str, &smmu_non_strict); + if (ret) + return ret; + + if (smmu_non_strict) { + 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("iommu.non_strict", arm_smmu_setup); + static inline void __iomem *arm_smmu_page1_fixup(unsigned long offset, struct arm_smmu_device *smmu) { @@ -1622,7 +1642,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 = true; pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT; }