Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752537AbdDLBlF (ORCPT ); Tue, 11 Apr 2017 21:41:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60740 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbdDLBlC (ORCPT ); Tue, 11 Apr 2017 21:41:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7E42C4DD7D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=bhe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7E42C4DD7D Date: Wed, 12 Apr 2017 09:40:56 +0800 From: Baoquan He To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, Joerg Roedel , David Woodhouse , linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/vt-d: Make sure IOMMUs are off when intel_iommu=off Message-ID: <20170412014056.GB3033@x1> References: <1490799639-15965-1-git-send-email-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1490799639-15965-1-git-send-email-joro@8bytes.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Apr 2017 01:41:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2066 Lines: 70 Hi Joerg, Do you plan to merge this one as urgent? There's bug created about this issue on rhel, it would be great if it can be put in next or merged so that we can back port it. Thanks Baoquan On 03/29/17 at 05:00pm, Joerg Roedel wrote: > From: Joerg Roedel > > 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 > --- > 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 d412a31..1662288 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -4730,6 +4730,15 @@ static int intel_iommu_cpu_dead(unsigned int cpu) > return 0; > } > > +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); > +} > + > static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev) > { > return container_of(dev, struct intel_iommu, iommu.dev); > @@ -4840,8 +4849,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"); > -- > 1.9.1 > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu