From patchwork Thu Feb 14 20:44:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 10813785 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 43AF56C2 for ; Thu, 14 Feb 2019 20:45:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30EB72EB03 for ; Thu, 14 Feb 2019 20:45:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 222E32EB36; Thu, 14 Feb 2019 20:45:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACE762EB1C for ; Thu, 14 Feb 2019 20:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728255AbfBNUpH (ORCPT ); Thu, 14 Feb 2019 15:45:07 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34006 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728231AbfBNUpG (ORCPT ); Thu, 14 Feb 2019 15:45:06 -0500 Received: by mail-pf1-f196.google.com with SMTP id j18so3688736pfe.1 for ; Thu, 14 Feb 2019 12:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xNS9jOHE65j1orTMurXb7fxroV+5e1Igqg3keBWoKCg=; b=mhZWfRU/vk2OJTUkVgBAUfMV8Mp+E2WKcowbYk2x9/Nd4Z9fkX5jtcOZGOct/fEUe6 uykPkifEL20VSr7UTIFXdwJt6PYarwXH7uwgTxQD10e3gvVYYVScNNkv7QISsYGSmk0C SBMcdRp0f8W3kcEsSyQH5DdNUWkADM7Ya+hms= 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:mime-version :content-transfer-encoding; bh=xNS9jOHE65j1orTMurXb7fxroV+5e1Igqg3keBWoKCg=; b=dBCwffBd7IDjo3nHNRu48z8OE3HXD8aBSLLmgDVC+SVXUDeIBlGp2iQXxLR2AeaSZL fK9B6Vai3ONZ7RWuwbLSsRE0lYRrmDiTO9SGqkixx9XcfgRZcvaxlmpucgx7gDxqbTdK vbgf0HF4h6SDWsME5rddZcbSBwJ0+w3mLhSWwFqnqt0kRzRIs5oGcB2QMu/wNBLYl5cO 0OkyHBAfuxBMgqpSAQ3/NJn5SIf7iS08+/iRUR2ka/ELLpPQkDQOUzDY7ncBG5BQekEg k2e2N7/km97otqaY4zONySwnwtqqrphFEfRUFWJzgXlLJ57g71C/ezvO6u9+oIa/3//Y BMlQ== X-Gm-Message-State: AHQUAuatX7hLiocg7pwL5IG/yACwenb1+O7DLtciV5DPej2vkb8AtuIy es4pC3XOM+0QBey0FrySLCDp8w== X-Google-Smtp-Source: AHgI3IYik4Oyp0I6WkFmgypJKgUBGMBGdGWsO/aOvikZNTnFQu/lVVcfaGwNFTN+4K3uXSnn53TvHg== X-Received: by 2002:a63:2ccb:: with SMTP id s194mr1761303pgs.214.1550177105959; Thu, 14 Feb 2019 12:45:05 -0800 (PST) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j5sm4074783pfe.84.2019.02.14.12.45.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 12:45:05 -0800 (PST) From: Douglas Anderson To: Joerg Roedel , Will Deacon , Robin Murphy Cc: linux-arm-msm@vger.kernel.org, Vivek Gautam , evgreen@chromium.org, tfiga@chromium.org, Douglas Anderson , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] iommu/arm-smmu: Allow disabling bypass via kernel config Date: Thu, 14 Feb 2019 12:44:33 -0800 Message-Id: <20190214204433.155715-1-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Right now the only way to disable the iommu bypass for the ARM SMMU is with the kernel command line parameter 'arm-smmu.disable_bypass'. In general kernel command line parameters make sense for things that someone would like to tweak without rebuilding the kernel or for very basic communication between the bootloader and the kernel, but are awkward for other things. Specifically: * Human parsing of the kernel command line can be difficult since it's just a big runon space separated line of text. * If every bit of the system was configured via the kernel command line the kernel command line would get very large and even more unwieldly. * Typically there are not easy ways in build systems to adjust the kernel command line for config-like options. Let's introduce a new config option that allows us to disable the iommu bypass without affecting the existing default nor the existing ability to adjust the configuration via kernel command line. Signed-off-by: Douglas Anderson --- drivers/iommu/Kconfig | 22 ++++++++++++++++++++++ drivers/iommu/arm-smmu.c | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 46fcd75d4364..c614beab08f8 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -359,6 +359,28 @@ config ARM_SMMU Say Y here if your SoC includes an IOMMU device implementing the ARM SMMU architecture. +config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT + bool "Default to disabling bypass on ARM SMMU v1 and v2" + depends on ARM_SMMU + default n + help + Say Y here to (by default) disable bypass streams such that + incoming transactions from devices that are not attached to + an iommu domain will report an abort back to the device and + will not be allowed to pass through the SMMU. + + Historically the ARM SMMU v1 and v2 driver has defaulted + to allow bypass by default but it could be disabled with + the parameter 'arm-smmu.disable_bypass'. The parameter is + still present and can be used to override this config + option, but this config option allows you to disable bypass + without bloating the kernel command line. + + Disabling bypass is more secure but presumably will break + old systems. + + Say N if unsure. + config ARM_SMMU_V3 bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64 diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 045d93884164..930c07635956 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -110,7 +110,8 @@ static int force_stage; module_param(force_stage, int, S_IRUGO); MODULE_PARM_DESC(force_stage, "Force SMMU mappings to be installed at a particular stage of translation. A value of '1' or '2' forces the corresponding stage. All other values are ignored (i.e. no stage is forced). Note that selecting a specific stage will disable support for nested translation."); -static bool disable_bypass; +static bool disable_bypass = + IS_ENABLED(CONFIG_ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT); module_param(disable_bypass, bool, S_IRUGO); MODULE_PARM_DESC(disable_bypass, "Disable bypass streams such that incoming transactions from devices that are not attached to an iommu domain will report an abort back to the device and will not be allowed to pass through the SMMU.");