From: Joerg Roedel <joerg.roedel@amd.com>
To: Ingo Molnar <mingo@redhat.com>
Cc: x86@kernel.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Chris Wright <chrisw@sous-sol.org>,
Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 07/12] x86/amd-iommu: warn when issuing command to uninitialized cmd buffer
Date: Wed, 7 Apr 2010 14:46:44 +0200 [thread overview]
Message-ID: <1270644409-10123-8-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1270644409-10123-1-git-send-email-joerg.roedel@amd.com>
From: Chris Wright <chrisw@sous-sol.org>
To catch future potential issues we can add a warning whenever we issue
a command before the command buffer is fully initialized.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/include/asm/amd_iommu_types.h | 1 +
arch/x86/kernel/amd_iommu.c | 1 +
arch/x86/kernel/amd_iommu_init.c | 5 +++--
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index 5e46e78..86a0ff0 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -141,6 +141,7 @@
/* constants to configure the command buffer */
#define CMD_BUFFER_SIZE 8192
+#define CMD_BUFFER_UNINITIALIZED 1
#define CMD_BUFFER_ENTRIES 512
#define MMIO_CMD_SIZE_SHIFT 56
#define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index b06f29e..71dfc0a 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -392,6 +392,7 @@ static int __iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
u32 tail, head;
u8 *target;
+ WARN_ON(iommu->cmd_buf_size & CMD_BUFFER_UNINITIALIZED);
tail = readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
target = iommu->cmd_buf + tail;
memcpy_toio(target, cmd, sizeof(*cmd));
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 8975965..5edf41c 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -438,7 +438,7 @@ static u8 * __init alloc_command_buffer(struct amd_iommu *iommu)
if (cmd_buf == NULL)
return NULL;
- iommu->cmd_buf_size = CMD_BUFFER_SIZE;
+ iommu->cmd_buf_size = CMD_BUFFER_SIZE | CMD_BUFFER_UNINITIALIZED;
return cmd_buf;
}
@@ -474,12 +474,13 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu)
&entry, sizeof(entry));
amd_iommu_reset_cmd_buffer(iommu);
+ iommu->cmd_buf_size &= ~(CMD_BUFFER_UNINITIALIZED);
}
static void __init free_command_buffer(struct amd_iommu *iommu)
{
free_pages((unsigned long)iommu->cmd_buf,
- get_order(iommu->cmd_buf_size));
+ get_order(iommu->cmd_buf_size & ~(CMD_BUFFER_UNINITIALIZED)));
}
/* allocates the memory where the IOMMU will log its events to */
--
1.7.0.4
next prev parent reply other threads:[~2010-04-07 12:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-07 12:46 [GIT PULL][PATCH 0/12] IOMMU fixes for 2.6.34-rc3 Joerg Roedel
2010-04-07 12:46 ` [PATCH 01/12] x86/amd-iommu: Remove double NULL check in check_device Joerg Roedel
2010-04-07 12:46 ` [PATCH 02/12] x86/amd-iommu: Protect IOMMU-API map/unmap path Joerg Roedel
2010-04-07 12:46 ` [PATCH 03/12] x86/amd-iommu: Pt mode fix for domain_destroy Joerg Roedel
2010-04-07 12:46 ` [PATCH 04/12] x86/amd-iommu: Report errors in acpi parsing functions upstream Joerg Roedel
2010-04-07 12:46 ` [PATCH 05/12] x86/amd-iommu: Use helper function to destroy domain Joerg Roedel
2010-04-07 12:46 ` [PATCH 06/12] x86/amd-iommu: enable iommu before attaching devices Joerg Roedel
2010-04-07 12:46 ` Joerg Roedel [this message]
2010-04-07 12:46 ` [PATCH 08/12] Revert "x86: disable IOMMUs on kernel crash" Joerg Roedel
2010-04-07 12:46 ` [PATCH 09/12] x86/amd-iommu: use for_each_pci_dev Joerg Roedel
2010-04-07 12:46 ` [PATCH 10/12] x86/amd-iommu: Remove obsolete parameter documentation Joerg Roedel
2010-04-07 12:46 ` [PATCH 11/12] dma-debug: Cleanup for copy-loop in filter_write() Joerg Roedel
2010-04-07 12:46 ` [PATCH 12/12] x86/gart: Disable GART explicitly before initialization Joerg Roedel
2010-04-13 11:25 ` [GIT PULL][PATCH 0/12] IOMMU fixes for 2.6.34-rc3 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=1270644409-10123-8-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@redhat.com \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®