From patchwork Fri Jun 5 14:10:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 481337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 316D01401AF for ; Sat, 6 Jun 2015 00:17:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=8bytes.org header.i=@8bytes.org header.b=ex3I9yPC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422705AbbFEORX (ORCPT ); Fri, 5 Jun 2015 10:17:23 -0400 Received: from 8bytes.org ([81.169.241.247]:59119 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423019AbbFEOLN (ORCPT ); Fri, 5 Jun 2015 10:11:13 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 4F9655BB; Fri, 5 Jun 2015 16:11:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1433513471; bh=ZPiWCf3yFoZPqcdkMkdc2vmErrGUvHCxKf7YfJ3AuVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ex3I9yPCUIAzhmm5203H6ZmxYbob0eYhuJEzoXa6cyPyJJ1Q0EEfbNIwEcNWoOMLO S5kA5T8xzQzYjDS2803pCI7obroHlgPAg6lYCgyYvhNcgfYbFvUZ1YxGYhnsKeIysp WsfdHeHuKoVgkZcPr25fZ2GOpw6ZPUIG6fo0jI6S2eiK5xqVYVrR2MCsL8FqwrvR+m 1zMax54FhYyrUh/PRxUarg25vakBcoEm4BgG+jhEFJE2qoDHOB/oMng0PeIINjgogq swdfWaQ5pJAR2TGB3ORmVWZvvS+S8qRstzKoYF9qj6//8DC8r1U7YZIqU3Zs3Qd/EF Qm/XRUDa5xP8g== From: Joerg Roedel To: iommu@lists.linux-foundation.org Cc: zhen-hual@hp.com, bhe@redhat.com, dwmw2@infradead.org, vgoyal@redhat.com, dyoung@redhat.com, alex.williamson@redhat.com, ddutile@redhat.com, ishii.hironobu@jp.fujitsu.com, indou.takao@jp.fujitsu.com, bhelgaas@google.com, doug.hatch@hp.com, jerry.hoemann@hp.com, tom.vaden@hp.com, li.zhang6@hp.com, lisa.mitchell@hp.com, billsumnerlinux@gmail.com, rwright@hp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kexec@lists.infradead.org, joro@8bytes.org, jroedel@suse.de Subject: [PATCH 04/17] iommu/vt-d: Load old data structures only in kdump kernel Date: Fri, 5 Jun 2015 16:10:50 +0200 Message-Id: <1433513463-19128-5-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433513463-19128-1-git-send-email-joro@8bytes.org> References: <1433513463-19128-1-git-send-email-joro@8bytes.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Joerg Roedel If we are not in a kdump kernel anybody could have left the iommu enabled. We have no reason at all to trust the data the data structures in this case, so don't even try to preserve anything. Tested-by: Baoquan He Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 14 ++++++++++++++ drivers/iommu/intel_irq_remapping.c | 12 +++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 982b8c8..d66bec6 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -2943,6 +2944,19 @@ static int __init init_dmars(void) goto free_iommu; iommu_check_pre_te_status(iommu); + + /* + * We don't even try to preserve anything when we are not in a + * kdump kernel. + */ + if (!is_kdump_kernel() && iommu->pre_enabled_trans) { + iommu_disable_translation(iommu); + iommu->pre_enabled_trans = 0; + g_translation_pre_enabled = 0; + pr_warn("Translation was enabled for %s but we are not in kdump mode\n", + iommu->name); + } + if (iommu->pre_enabled_trans) { pr_info("IOMMU Copying translate tables from panicked kernel\n"); ret = intel_iommu_load_translation_tables(iommu); diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c index 46d80ad..c3f0686 100644 --- a/drivers/iommu/intel_irq_remapping.c +++ b/drivers/iommu/intel_irq_remapping.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -666,11 +667,12 @@ static int __init intel_enable_irq_remapping(void) iommu_check_pre_ir_status(iommu); - /* - * Here we do not disable intr remapping, - * if already enabled prior to OS handover. - */ - /* iommu_disable_irq_remapping(iommu); */ + if (!is_kdump_kernel() && iommu->pre_enabled_ir) { + iommu_disable_irq_remapping(iommu); + iommu->pre_enabled_ir = 0; + pr_warn("IRQ remapping was enabled on %s but we are not in kdump mode\n", + iommu->name); + } dmar_disable_qi(iommu); }