public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: Sander Eikelenboom <linux@eikelenboom.it>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [2.6.35] AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40  BUG: unable to handle kernel NULL pointer dereference at 0000000000000198
Date: Wed, 11 Aug 2010 00:24:19 +0200	[thread overview]
Message-ID: <20100810222419.GW23755@8bytes.org> (raw)
In-Reply-To: <1498209076.20100810233659@eikelenboom.it>

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]

On Tue, Aug 10, 2010 at 11:36:59PM +0200, Sander Eikelenboom wrote:
> It boots now, dmesg attached.

Ok, here is a quick and dirty patch wich should make your system boot
again. It introduces other issues which will show up when you try to
assign the devices to a virtual machine. But at least the devices should
work again on bare-metal.

	Joerg


[-- Attachment #2: iommu-alias-fix.diff --]
[-- Type: text/x-diff, Size: 1935 bytes --]

diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index 7014e88..b667e80 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -285,6 +285,8 @@ struct protection_domain {
 
 };
 
+#define INVALID_ALIAS_ID (~0U)
+
 /*
  * This struct contains device specific data for the IOMMU
  */
@@ -294,6 +296,9 @@ struct iommu_dev_data {
 	struct device *alias;		  /* The Alias Device */
 	struct protection_domain *domain; /* Domain the device is bound to */
 	atomic_t bind;			  /* Domain attach reverent count */
+
+	u32	alias_id;		  /* Use in case device aliases to
+					     non-existend PCI BDF */
 };
 
 /*
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 0d20286..673d0a4 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -148,11 +148,17 @@ static int iommu_init_device(struct device *dev)
 
 	dev_data->dev = dev;
 
+	dev_data->alias_id = INVALID_ALIAS_ID;
+
 	devid = get_device_id(dev);
 	alias = amd_iommu_alias_table[devid];
 	pdev = pci_get_bus_and_slot(PCI_BUS(alias), alias & 0xff);
 	if (pdev)
 		dev_data->alias = &pdev->dev;
+	else {
+		dev_data->alias = dev;
+		dev_data->alias_id = alias;
+	}
 
 	atomic_set(&dev_data->bind, 0);
 
@@ -1448,6 +1454,9 @@ static void do_attach(struct device *dev, struct protection_domain *domain)
 	list_add(&dev_data->list, &domain->dev_list);
 	set_dte_entry(devid, domain);
 
+	if (dev_data->alias_id != INVALID_ALIAS_ID)
+		set_dte_enry(dev_data->alias_id, domain);
+
 	/* Do reference counting */
 	domain->dev_iommu[iommu->index] += 1;
 	domain->dev_cnt                 += 1;
@@ -1475,6 +1484,9 @@ static void do_detach(struct device *dev)
 	list_del(&dev_data->list);
 	clear_dte_entry(devid);
 
+	if (dev_data->alias_id != INVALID_ALIAS_ID)
+		clear_dte_enry(dev_data->alias_id);
+
 	/* Flush the DTE entry */
 	iommu_flush_device(dev);
 }

  parent reply	other threads:[~2010-08-10 22:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1154489525.20100810164850@eikelenboom.it>
     [not found] ` <20100810162606.GQ23755@8bytes.org>
2010-08-10 16:57   ` [2.6.35] AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40 BUG: unable to handle kernel NULL pointer dereference at 0000000000000198 Sander Eikelenboom
2010-08-10 18:01     ` Joerg Roedel
2010-08-10 18:05       ` Sander Eikelenboom
2010-08-10 20:28         ` Joerg Roedel
2010-08-10 20:36           ` Sander Eikelenboom
2010-08-10 20:47             ` Joerg Roedel
2010-08-10 20:57               ` Sander Eikelenboom
2010-08-10 21:25                 ` Joerg Roedel
2010-08-10 21:48                   ` Sander Eikelenboom
2010-08-10 21:36               ` Sander Eikelenboom
2010-08-10 22:02                 ` Joerg Roedel
2010-08-10 22:24                 ` Joerg Roedel [this message]
2010-08-11 17:54                   ` Sander Eikelenboom

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=20100810222419.GW23755@8bytes.org \
    --to=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@eikelenboom.it \
    /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