From patchwork Wed Jan 2 19:40:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guilherme G. Piccoli" X-Patchwork-Id: 1020060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43VLxd0dZLz9s4s; Thu, 3 Jan 2019 06:40:37 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gemNS-0005UN-8K; Wed, 02 Jan 2019 19:40:30 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gemNR-0005UG-Oo for kernel-team@lists.ubuntu.com; Wed, 02 Jan 2019 19:40:29 +0000 Received: from mail-qt1-f198.google.com ([209.85.160.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gemNR-0007zW-F7 for kernel-team@lists.ubuntu.com; Wed, 02 Jan 2019 19:40:29 +0000 Received: by mail-qt1-f198.google.com with SMTP id d31so40100653qtc.4 for ; Wed, 02 Jan 2019 11:40:29 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=dNjIKKEFbGSaoWfetbLDfjwF8xUhmD2kNPoJR4c+rM0=; b=FCwetxJNiD9vwCwhZSHy36D7qAgjFepI7HNw88774wbT5l4rniiMsjc5THWrmBHgG2 sSsi+Det9oJfN6VM6HpRMymr+sNt7iNFRp3CzC+JzrGkIFW2OKQ3xQH865sug9lbgu6f 4qdasFohRPKeb9ZbHAE3ndD6A59+mCZ/6qGRjUwWutC3u5CKXI0gxcmUYtnslfZNw6YU xITHWmuDsf1vL3Kyb+7VFeTReTaqsDJ0Xoulc5CX/nhmRx/HD1DlYC5BT7ZSdGSZsLTd 5tqPqBC4DrOW+s3M5MGZVFRFvnYSxuiz3OnomfIlolB+byzpqWL4P/CHyAfsRYMUz0bO F7DA== X-Gm-Message-State: AJcUukehBLVavUdh83/BY7S4qdBncd8hDrHIoxCHRyDx+WYfoF1DMez1 1RjkQd1fyHRVytCTEUyAuYTOEdb9on21HTzqwom+mcIDnkFMPcvW75i2lJhgiY4Gs4z2kLpgll9 5mTH1yfmaRd151hVfWZq+jSlqeuvW6KRLVBcsciswCA== X-Received: by 2002:a37:9b41:: with SMTP id d62mr41138661qke.215.1546458028407; Wed, 02 Jan 2019 11:40:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN7j2UHQHJuGzBCAsmhChU/6AO1SXHtwYMZslD86unTZ0Tyt9dZq4vRP/FK+HLAPOEY6RPAdAg== X-Received: by 2002:a37:9b41:: with SMTP id d62mr41138651qke.215.1546458028245; Wed, 02 Jan 2019 11:40:28 -0800 (PST) Received: from localhost ([2001:67c:1562:8007::aac:4196]) by smtp.gmail.com with ESMTPSA id l195sm4813103qke.58.2019.01.02.11.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 11:40:27 -0800 (PST) From: "Guilherme G. Piccoli" To: kernel-team@lists.ubuntu.com Subject: [SRU X] [PATCH 1/1] iommu/vt-d: Make sure IOMMUs are off when intel_iommu=off Date: Wed, 2 Jan 2019 17:40:16 -0200 Message-Id: <20190102194016.7412-2-gpiccoli@canonical.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190102194016.7412-1-gpiccoli@canonical.com> References: <20190102194016.7412-1-gpiccoli@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cascardo@canonical.com, gpiccoli@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Joerg Roedel BugLink: https://launchpad.net/bugs/1810328 When booting into a kexec kernel with intel_iommu=off, and the previous kernel had intel_iommu=on, the IOMMU hardware is still enabled and gets not disabled by the new kernel. This causes the boot to fail because DMA is blocked by the hardware. Disable the IOMMUs when we find it enabled in the kexec kernel and boot with intel_iommu=off. Signed-off-by: Joerg Roedel (backported from commit 161b28aae1651aa7ad63ec14753aa8a751154340 upstream) [gpiccoli: context adjustment] Signed-off-by: Guilherme G. Piccoli Acked-by: Kleber Sacilotto de Souza Acked-by: Stefan Bader --- drivers/iommu/intel-iommu.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 49b266433f4c..03f817d118f3 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -4648,6 +4648,15 @@ const struct attribute_group *intel_iommu_groups[] = { NULL, }; +static void intel_disable_iommus(void) +{ + struct intel_iommu *iommu = NULL; + struct dmar_drhd_unit *drhd; + + for_each_iommu(iommu, drhd) + iommu_disable_translation(iommu); +} + int __init intel_iommu_init(void) { int ret = -ENODEV; @@ -4676,8 +4685,15 @@ int __init intel_iommu_init(void) goto out_free_dmar; } - if (no_iommu || dmar_disabled) + if (no_iommu || dmar_disabled) { + /* + * Make sure the IOMMUs are switched off, even when we + * boot into a kexec kernel and the previous kernel left + * them enabled + */ + intel_disable_iommus(); goto out_free_dmar; + } if (list_empty(&dmar_rmrr_units)) pr_info("No RMRR found\n");