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: Zhen Lei X-Patchwork-Id: 143505 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3229033ljj; Mon, 6 Aug 2018 05:27:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcuxwpROhGUPl9vBG5ifVyPAiCQB58iGRFZjZTtP/coSYPLOXuiVOc27kDNoIPwED/MwZdn X-Received: by 2002:a63:6604:: with SMTP id a4-v6mr14062602pgc.404.1533558475084; Mon, 06 Aug 2018 05:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533558475; cv=none; d=google.com; s=arc-20160816; b=FcyqZRz6dUJ607v3qsIGDvS/X4MMpizNoefF6uxkaIElhmQJpnoY7T0HW/aA1No1kU mpfFD0wWMMRVCuoJNOY0gd3dadR72EH201rZCLRzLHtoV9SIGidqHRQg9nAvZKgyuxqE wlBYvVNRc5W6kRTgi/yhcYGhkUWpShs731g+pHkJ3sFQcJhuUBNZV7HZjC8JSzgdwDdX s5YX2l9OA3QX2pKsQOyVEzkMnXkBUjmizSaq+R1yt0MxCwarfDhD7BFGWiJ0DrmcB1IO iOLZcyYNzzqp7bclZ9AYrlrVV5Cmb0dHC2IwhMAPL4RAmgu4pRUgNc5cH7bzXV/t0RWZ OpAA== 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=GqJOQfb0lLlj/VnUpIWiOWjjtek7o9QGyTgYPBIN8+U=; b=jBvwaoAOz9Gu9zuekMBTtWhEQlLlDaYj0SA160KzuhD73tRFnXaujHEyW6VrkhlDrY H0NN9TKDVzrPxXWOLgmOclmITH05E+mIfi1Umgu65CVgxtoGJyH9enTO5IoEnmM0Tm5v ZdIoitXqXTR+C/aRUegLd7yTxu/3aoTAoqauco9/yujVpooSsaj4zURwog/v2vDesmpe y3p/hVIMm+mssMp+IKSV/DXs4heM9dEOSEsUvX2LcXukBcl+bWY7mf1GrX5jn2YL1jd0 b5gsEFgx7Q5qFAIso3M8P0W974m2a3g963OHuAhIwOSnVh29qJ2whWL3mJrqx5/xh7Dn zBLA== 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 h1-v6si9993644pld.152.2018.08.06.05.27.54; Mon, 06 Aug 2018 05:27:55 -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 S1731738AbeHFOgp (ORCPT + 31 others); Mon, 6 Aug 2018 10:36:45 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:50796 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726901AbeHFOgo (ORCPT ); Mon, 6 Aug 2018 10:36:44 -0400 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 CC: Zhen Lei , LinuxArm , Hanjun Guo , Libin 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 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 | 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; }