From: Joerg Roedel <joerg.roedel@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
Chris Wright <chrisw@sous-sol.org>,
Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 3/6] amd-iommu: flush domain tlb when attaching a new device
Date: Tue, 16 Jun 2009 10:56:12 +0200 [thread overview]
Message-ID: <1245142575-7166-4-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1245142575-7166-1-git-send-email-joerg.roedel@amd.com>
From: Chris Wright <chrisw@sous-sol.org>
When kexec'ing to a new kernel (for example, when crashing and launching
a kdump session), the AMD IOMMU may have cached translations. The kexec'd
kernel, during initialization, will invalidate the IOMMU device table
entries, but not the domain translations. These stale entries can cause
a device's DMA to fail, makes it rough to write a dump to disk when the
disk controller can't DMA ;-)
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 1c60554..9372f04 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -434,6 +434,16 @@ static void iommu_flush_tlb(struct amd_iommu *iommu, u16 domid)
iommu_queue_inv_iommu_pages(iommu, address, domid, 0, 1);
}
+/* Flush the whole IO/TLB for a given protection domain - including PDE */
+static void iommu_flush_tlb_pde(struct amd_iommu *iommu, u16 domid)
+{
+ u64 address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS;
+
+ INC_STATS_COUNTER(domain_flush_single);
+
+ iommu_queue_inv_iommu_pages(iommu, address, domid, 1, 1);
+}
+
/*
* This function is used to flush the IO/TLB for a given protection domain
* on every IOMMU in the system
@@ -1078,7 +1088,13 @@ static void attach_device(struct amd_iommu *iommu,
amd_iommu_pd_table[devid] = domain;
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
+ /*
+ * We might boot into a crash-kernel here. The crashed kernel
+ * left the caches in the IOMMU dirty. So we have to flush
+ * here to evict all dirty stuff.
+ */
iommu_queue_inv_dev_entry(iommu, devid);
+ iommu_flush_tlb_pde(iommu, domain->id);
}
/*
--
1.6.3.1
next prev parent reply other threads:[~2009-06-16 8:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 8:56 [git pull][PATCH 0/6] amd-iommu fixes Joerg Roedel
2009-06-16 8:56 ` [PATCH 1/6] amd-iommu: disable IOMMU hardware on shutdown Joerg Roedel
2009-06-16 8:56 ` [PATCH 2/6] x86: disable IOMMUs on kernel crash Joerg Roedel
2009-06-16 8:56 ` Joerg Roedel [this message]
2009-06-16 8:56 ` [PATCH 4/6] amd-iommu: disable cmd buffer and evt logging before reprogramming iommu Joerg Roedel
2009-06-16 8:56 ` [PATCH 5/6] amd-iommu: set event buffer head and tail to 0 manually Joerg Roedel
2009-06-16 8:56 ` [PATCH 6/6] amd-iommu: resume cleanup Joerg Roedel
2009-06-16 9:52 ` [git pull][PATCH 0/6] amd-iommu fixes Ingo Molnar
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=1245142575-7166-4-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=chrisw@sous-sol.org \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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