From: David Woodhouse <dwmw2@infradead.org>
To: torvalds@linux-foundation.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Faidon Liambotis <paravoid@debian.org>,
Matt Domsch <Matt_Domsch@dell.com>,
"Siddha, Suresh B" <suresh.b.siddha@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
bugzilla-daemon@bugzilla.kernel.org,
bugme-daemon@bugzilla.kernel.org, bero@arklinux.org,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] intel-iommu: Work around yet another BIOS bug
Date: Thu, 20 Aug 2009 09:01:58 +0100 [thread overview]
Message-ID: <1250755318.8974.26.camel@macbook.infradead.org> (raw)
In-Reply-To: <1250754748.8974.17.camel@macbook.infradead.org>
Yet another reason why trusting this stuff to the BIOS was a bad idea.
There now seem to be a bunch of BIOSes which report an IOMMU at a
physical address which just returns all ones. (Perhaps only when VT-d is
actually _disabled_ in the BIOS?)
Well done, Dell and HP -- although I didn't think it was possible, you
have _further_ lowered my already-unprintable opinion of closed source
BIOSes and BIOS engineers.
This patch makes the kernel detect this particularly brokenness and
abort early -- and fixes up the missing iounmap in the error paths which
I noticed while I was poking at it.
This should fix kernel.org bug #14003, which was being called a
'regression' -- I think because the IOMMU code used to trip over
_another_ BIOS bug earlier than this one, and that one _did_ cause it to
abort.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
drivers/pci/dmar.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 7b287cb..380b60e 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -632,20 +632,31 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG);
iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG);
+ if (iommu->cap == (uint64_t)-1 && iommu->ecap == (uint64_t)-1) {
+ /* Promote an attitude of violence to a BIOS engineer today */
+ WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
+ "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+ drhd->reg_base_addr,
+ dmi_get_system_info(DMI_BIOS_VENDOR),
+ dmi_get_system_info(DMI_BIOS_VERSION),
+ dmi_get_system_info(DMI_PRODUCT_VERSION));
+ goto err_unmap;
+ }
+
#ifdef CONFIG_DMAR
agaw = iommu_calculate_agaw(iommu);
if (agaw < 0) {
printk(KERN_ERR
"Cannot get a valid agaw for iommu (seq_id = %d)\n",
iommu->seq_id);
- goto error;
+ goto err_unmap;
}
msagaw = iommu_calculate_max_sagaw(iommu);
if (msagaw < 0) {
printk(KERN_ERR
"Cannot get a valid max agaw for iommu (seq_id = %d)\n",
iommu->seq_id);
- goto error;
+ goto err_unmap;
}
#endif
iommu->agaw = agaw;
@@ -665,7 +676,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
}
ver = readl(iommu->reg + DMAR_VER_REG);
- pr_debug("IOMMU %llx: ver %d:%d cap %llx ecap %llx\n",
+ pr_info("IOMMU %llx: ver %d:%d cap %llx ecap %llx\n",
(unsigned long long)drhd->reg_base_addr,
DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver),
(unsigned long long)iommu->cap,
@@ -675,7 +686,10 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
drhd->iommu = iommu;
return 0;
-error:
+
+ err_unmap:
+ iounmap(iommu->reg);
+ error:
kfree(iommu);
return -1;
}
--
1.6.2.5
--
dwmw2
next prev parent reply other threads:[~2009-08-20 8:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-14003-10286@http.bugzilla.kernel.org/>
2009-08-19 21:26 ` [Bugme-new] [Bug 14003] New: Infinite loop on bootup while handling DMAR Andrew Morton
2009-08-20 1:15 ` Suresh Siddha
2009-08-20 7:52 ` David Woodhouse
2009-08-20 8:01 ` David Woodhouse [this message]
2009-08-20 9:44 ` [PATCH] intel-iommu: Work around yet another BIOS bug Andrew Morton
2009-08-20 11:14 ` David Woodhouse
2009-08-20 18:48 ` Andrew Morton
2009-08-20 12:36 ` Matthew Wilcox
2009-08-20 19:29 ` Ray Lee
2009-08-20 19:32 ` David Woodhouse
2009-08-20 21:47 ` Grant Grundler
2009-08-20 21:54 ` David Woodhouse
2009-08-31 13:15 ` Carl-Daniel Hailfinger
2009-08-20 8:40 ` [Bugme-new] [Bug 14003] New: Infinite loop on bootup while handling DMAR Faidon Liambotis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250755318.8974.26.camel@macbook.infradead.org \
--to=dwmw2@infradead.org \
--cc=Matt_Domsch@dell.com \
--cc=akpm@linux-foundation.org \
--cc=bero@arklinux.org \
--cc=bugme-daemon@bugzilla.kernel.org \
--cc=bugzilla-daemon@bugzilla.kernel.org \
--cc=hpa@zytor.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=paravoid@debian.org \
--cc=suresh.b.siddha@intel.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome