Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3154587imm; Fri, 20 Jul 2018 11:04:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdEoalc/2RYhKPeL+cih+jUssIu9zdGMBUylDyyjTCp3R44ExeKG1Y/0i4O9T/EMWW57Lqs X-Received: by 2002:a63:4763:: with SMTP id w35-v6mr2994634pgk.140.1532109867263; Fri, 20 Jul 2018 11:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532109867; cv=none; d=google.com; s=arc-20160816; b=EfAWeZYdUkMy3CWHl9yild0xFmjjeXfRqvs24AXIL7SbhX7ilKlvk4lGdicLdulVQi 28Wl8S2mNBkAMyNxyPIeuW9ym9U54u7yaUG1WFsZ8BPxLQGJ6uWqgaDJG5fF7E9Dj5QS E/9+f9btLBOFB8ievvtW95NnFHLID+6JhzTT/4kxu161B+RDNTZQ6R21SPj2Of/lCLoJ bNKtEwtz8voPaHsNK8QDGdrT6aXGlSyxRh6O42XvQHwCNGyN4exrXw/zhgun+/8UI2uu /yA3oWrKqZQaRFZVpkFlFED56mlyL4rEc9bAAMbFjb8WqkEq4M4PRXFXbYhG6EmAo3RB BJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=GCp62Z/oWd+D7S5Y1kWvUc7vFKn+4MHRRwBmAV6Pi2E=; b=RjO4PIENw/WSdt6dw75A7iBL0xGGQ5Q72yClRocfw+1Q7g/bcuHXVIN8m1jz4lqasW E/Kn5Uyawwu9sXC3SpM+GbH1lPmbhG50ztgcYPwBo+PyqxUGRAMZOUWnVBh/BWaNVxQ2 RoCISERBDDsqT7ZnLhcn3E2dCM1JCpzPmSJCGqcMVI3iDY3vHbTUTTNX6JI06+jjk8k0 nm0H3GuCgFFTPrBjgZ7/Z2l7oHmLVbubFa+gbIY3ehSUy/e1PxxxLWu02Xkw9rt9j10M zekA1z2iD0U+qEghiKnWbfizBNp4hVh4hkusiFsPjjlrMXmGiw+F60+LjKRq7Ht3moYc Z3EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b="PP6BI/Au"; 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 y2-v6si2068592plp.459.2018.07.20.11.04.12; Fri, 20 Jul 2018 11:04:27 -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; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b="PP6BI/Au"; 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 S2388349AbeGTSwT (ORCPT + 99 others); Fri, 20 Jul 2018 14:52:19 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42878 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388065AbeGTSwT (ORCPT ); Fri, 20 Jul 2018 14:52:19 -0400 Received: by mail-pg1-f194.google.com with SMTP id y4-v6so7488483pgp.9 for ; Fri, 20 Jul 2018 11:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GCp62Z/oWd+D7S5Y1kWvUc7vFKn+4MHRRwBmAV6Pi2E=; b=PP6BI/AuZEOStL+fJhPux8ZpoqISAofEGG52pDguhZJAH4zrrPRg12WSB731FFi0Bw 6EEy9GD5i5tYR8BZTPcOkbGgazbZxe/M6aZ1axh6eUK1E+8ir07LoGbAhaLL7HzqVNsb bf+ZI4r/cVY1k6lRogj4NvBgFauflTRa/WuILFM16LTE+/4rIuGUNFhEp7jxsvu3RcVD s9Rd2WbR0VzX4aijLR8oJQz9ohDHjG+UGmAxLq+rO6IaqRkTxjIX0IPBupfuQj1YZfcZ WBXYTg919mVlQ471eZT6khon3o21r88z85p3n5S6lzh40/QywiQtK8dGdhIvNqzr1M38 lCOQ== 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=GCp62Z/oWd+D7S5Y1kWvUc7vFKn+4MHRRwBmAV6Pi2E=; b=VgcVLUEtmpdbICwbKWiIl/S2k+k8tW4Ayp2eG0i8HRX0rRZQ9luAQHKEiciwqPOdXG YhQHGSIPb/ar0/hPk1JUHwRAw5VIjtRKcDnSVF33PsYXJ4N/4ASVXVmPQPn7GdUkmvz+ OYJhTYJxekwi8ZxZ3rMUDTY3rPQWCoGWh+zmHLpYAnY+pp2EDRwbD+PXSt3XQwUXPQCh FBKa7KGPDuflfrYqnWCXmeg9PDwwfUiK1GpRtzJSi3EzGBJyurP1rObj9v9JjicaUmhH vlVsWKLMBzGaPpYiH2NWDooX9zRfSuwNhirSU8EmJEiDrdCLY+VjWThCFGNHk8dsuz8d EpeQ== X-Gm-Message-State: AOUpUlGwKUpUfyF9PCJMMxolYLPv1cnSxEJZ8zvsfTYQlmUkIuy9GgGj XVijmBk7e/lA6PoI7QG5388row== X-Received: by 2002:a62:ee06:: with SMTP id e6-v6mr3194899pfi.2.1532109776092; Fri, 20 Jul 2018 11:02:56 -0700 (PDT) Received: from localhost.localdomain (99-152-116-91.lightspeed.sntcca.sbcglobal.net. [99.152.116.91]) by smtp.gmail.com with ESMTPSA id z10-v6sm3468601pfh.83.2018.07.20.11.02.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 11:02:54 -0700 (PDT) From: Olof Johansson To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Olof Johansson Subject: [PATCH] iommu: Add config option to set passthrough as default Date: Fri, 20 Jul 2018 11:02:23 -0700 Message-Id: <20180720180223.29573-1-olof@lixom.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180711205936.18614-1-olof@lixom.net> References: <20180711205936.18614-1-olof@lixom.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows the default behavior to be controlled by a kernel config option instead of changing the commandline for the kernel to include "iommu.passthrough=on" or "iommu=pt" on machines where this is desired. Likewise, for machines where this config option is enabled, it can be disabled at boot time with "iommu.passthrough=off" or "iommu=nopt". Also corrected iommu=pt documentation for IA-64, since it has no code that parses iommu= at all. Signed-off-by: Olof Johansson --- Chances since v1: - Added analogous behavior for Intel/AMD - Added iommu=nopt for x86 and updated docs Documentation/admin-guide/kernel-parameters.txt | 3 ++- arch/x86/kernel/pci-dma.c | 8 ++++++++ drivers/iommu/Kconfig | 11 +++++++++++ drivers/iommu/iommu.c | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index c9dbdf1009f1..4c822aa50f13 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1744,7 +1744,8 @@ merge nomerge soft - pt [x86, IA-64] + pt [x86] + nopt [x86] nobypass [PPC/POWERNV] Disable IOMMU bypass, using IOMMU for PCI devices. diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index ab5d9dd668d2..0acb135de7fb 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -40,8 +40,14 @@ int iommu_detected __read_mostly = 0; * devices and allow every device to access to whole physical memory. This is * useful if a user wants to use an IOMMU only for KVM device assignment to * guests and not for driver dma translation. + * It is also possible to disable by default in kernel config, and enable with + * iommu=nopt at boot time. */ +#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH +int iommu_pass_through __read_mostly = 1; +#else int iommu_pass_through __read_mostly; +#endif extern struct iommu_table_entry __iommu_table[], __iommu_table_end[]; @@ -135,6 +141,8 @@ static __init int iommu_setup(char *p) #endif if (!strncmp(p, "pt", 2)) iommu_pass_through = 1; + if (!strncmp(p, "nopt", 4)) + iommu_pass_through = 0; gart_parse_options(p); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 568ae81b0e99..1813319c8342 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -70,6 +70,17 @@ config IOMMU_DEBUGFS debug/iommu directory, and then populate a subdirectory with entries as required. +config IOMMU_DEFAULT_PASSTHROUGH + bool "IOMMU passthrough by default" + depends on IOMMU_API + help + Enable passthrough by default, removing the need to pass in + iommu.passthrough=on or iommu=pt through command line. If this + is enabled, you can still disable with iommu.passthrough=off + or iommu=nopt depending on the architecture. + + If unsure, say N here. + config IOMMU_IOVA tristate diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index d227b864a109..6f8f59684def 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -36,7 +36,11 @@ static struct kset *iommu_group_kset; static DEFINE_IDA(iommu_group_ida); +#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH +static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY; +#else static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA; +#endif struct iommu_callback_data { const struct iommu_ops *ops; -- 2.11.0