* [PATCH 1/5] x86/amd-iommu: Fix possible integer overflow
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
@ 2010-01-22 17:18 ` Joerg Roedel
2010-01-22 17:18 ` [PATCH 2/5] x86/amd-iommu: Fix NULL pointer dereference in __detach_device() Joerg Roedel
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2010-01-22 17:18 UTC (permalink / raw)
To: Ingo Molnar; +Cc: x86, linux-kernel, iommu, Joerg Roedel, stable
The variable i in this function could be increased to over
2**32 which would result in an integer overflow when using
int. Fix it by changing i to unsigned long.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 23824fe..c2ccbd7 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -980,7 +980,7 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
{
int index = dma_dom->aperture_size >> APERTURE_RANGE_SHIFT;
struct amd_iommu *iommu;
- int i;
+ unsigned long i;
#ifdef CONFIG_IOMMU_STRESS
populate = false;
--
1.6.6
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 2/5] x86/amd-iommu: Fix NULL pointer dereference in __detach_device()
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
2010-01-22 17:18 ` [PATCH 1/5] x86/amd-iommu: Fix possible integer overflow Joerg Roedel
@ 2010-01-22 17:18 ` Joerg Roedel
2010-01-22 17:18 ` [PATCH 3/5] x86/amd-iommu: Fix IOMMU-API initialization for iommu=pt Joerg Roedel
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2010-01-22 17:18 UTC (permalink / raw)
To: Ingo Molnar; +Cc: x86, linux-kernel, iommu, Joerg Roedel
In the __detach_device function the reference count for a
device-domain binding may become zero. This results in the
device being removed from the domain and dev_data->domain
will be NULL. This is bad because this pointer is
dereferenced when trying to unlock the domain->lock. This
patch fixes the issue by keeping the domain in a seperate
variable.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index c2ccbd7..4478a48 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1489,11 +1489,14 @@ static void __detach_device(struct device *dev)
{
struct iommu_dev_data *dev_data = get_dev_data(dev);
struct iommu_dev_data *alias_data;
+ struct protection_domain *domain;
unsigned long flags;
BUG_ON(!dev_data->domain);
- spin_lock_irqsave(&dev_data->domain->lock, flags);
+ domain = dev_data->domain;
+
+ spin_lock_irqsave(&domain->lock, flags);
if (dev_data->alias != dev) {
alias_data = get_dev_data(dev_data->alias);
@@ -1504,7 +1507,7 @@ static void __detach_device(struct device *dev)
if (atomic_dec_and_test(&dev_data->bind))
do_detach(dev);
- spin_unlock_irqrestore(&dev_data->domain->lock, flags);
+ spin_unlock_irqrestore(&domain->lock, flags);
/*
* If we run in passthrough mode the device must be assigned to the
--
1.6.6
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 3/5] x86/amd-iommu: Fix IOMMU-API initialization for iommu=pt
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
2010-01-22 17:18 ` [PATCH 1/5] x86/amd-iommu: Fix possible integer overflow Joerg Roedel
2010-01-22 17:18 ` [PATCH 2/5] x86/amd-iommu: Fix NULL pointer dereference in __detach_device() Joerg Roedel
@ 2010-01-22 17:18 ` Joerg Roedel
2010-01-22 17:18 ` [PATCH 4/5] x86/amd-iommu: Fix deassignment of a device from the pt_domain Joerg Roedel
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2010-01-22 17:18 UTC (permalink / raw)
To: Ingo Molnar; +Cc: x86, linux-kernel, iommu, Joerg Roedel, stable
This patch moves the initialization of the iommu-api out of
the dma-ops initialization code. This ensures that the
iommu-api is initialized even with iommu=pt.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/include/asm/amd_iommu_proto.h | 1 +
arch/x86/kernel/amd_iommu.c | 8 ++++++--
arch/x86/kernel/amd_iommu_init.c | 3 +++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/amd_iommu_proto.h b/arch/x86/include/asm/amd_iommu_proto.h
index 4d817f9..d2544f1 100644
--- a/arch/x86/include/asm/amd_iommu_proto.h
+++ b/arch/x86/include/asm/amd_iommu_proto.h
@@ -31,6 +31,7 @@ extern void amd_iommu_reset_cmd_buffer(struct amd_iommu *iommu);
extern int amd_iommu_init_devices(void);
extern void amd_iommu_uninit_devices(void);
extern void amd_iommu_init_notifier(void);
+extern void amd_iommu_init_api(void);
#ifndef CONFIG_AMD_IOMMU_STATS
static inline void amd_iommu_stats_init(void) { }
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 4478a48..751ce73 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2221,6 +2221,12 @@ static struct dma_map_ops amd_iommu_dma_ops = {
/*
* The function which clues the AMD IOMMU driver into dma_ops.
*/
+
+void __init amd_iommu_init_api(void)
+{
+ register_iommu(&amd_iommu_ops);
+}
+
int __init amd_iommu_init_dma_ops(void)
{
struct amd_iommu *iommu;
@@ -2256,8 +2262,6 @@ int __init amd_iommu_init_dma_ops(void)
/* Make the driver finally visible to the drivers */
dma_ops = &amd_iommu_dma_ops;
- register_iommu(&amd_iommu_ops);
-
amd_iommu_stats_init();
return 0;
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index fb490ce..9dc91b4 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -1292,9 +1292,12 @@ static int __init amd_iommu_init(void)
ret = amd_iommu_init_passthrough();
else
ret = amd_iommu_init_dma_ops();
+
if (ret)
goto free;
+ amd_iommu_init_api();
+
amd_iommu_init_notifier();
enable_iommus();
--
1.6.6
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 4/5] x86/amd-iommu: Fix deassignment of a device from the pt_domain
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
` (2 preceding siblings ...)
2010-01-22 17:18 ` [PATCH 3/5] x86/amd-iommu: Fix IOMMU-API initialization for iommu=pt Joerg Roedel
@ 2010-01-22 17:18 ` Joerg Roedel
2010-01-22 17:18 ` [PATCH 5/5] lib/dma-debug.c: mark file-local struct symbol static Joerg Roedel
2010-01-27 10:04 ` [git pull] IOMMU fixes for 2.6.33-rc5 Ingo Molnar
5 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2010-01-22 17:18 UTC (permalink / raw)
To: Ingo Molnar; +Cc: x86, linux-kernel, iommu, Joerg Roedel, stable
Deassigning a device from the passthrough domain does not
work and breaks device assignment to kvm guests. This patch
fixes the issue.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 751ce73..adb0ba0 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1511,9 +1511,11 @@ static void __detach_device(struct device *dev)
/*
* If we run in passthrough mode the device must be assigned to the
- * passthrough domain if it is detached from any other domain
+ * passthrough domain if it is detached from any other domain.
+ * Make sure we can deassign from the pt_domain itself.
*/
- if (iommu_pass_through && dev_data->domain == NULL)
+ if (iommu_pass_through &&
+ (dev_data->domain == NULL && domain != pt_domain))
__attach_device(dev, pt_domain);
}
--
1.6.6
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 5/5] lib/dma-debug.c: mark file-local struct symbol static.
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
` (3 preceding siblings ...)
2010-01-22 17:18 ` [PATCH 4/5] x86/amd-iommu: Fix deassignment of a device from the pt_domain Joerg Roedel
@ 2010-01-22 17:18 ` Joerg Roedel
2010-01-27 10:04 ` [git pull] IOMMU fixes for 2.6.33-rc5 Ingo Molnar
5 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2010-01-22 17:18 UTC (permalink / raw)
To: Ingo Molnar; +Cc: x86, linux-kernel, iommu, Thiago Farina, Joerg Roedel
From: Thiago Farina <tfransosi@gmail.com>
warning: symbol 'filter_fops' was not declared. Should it be static?
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
lib/dma-debug.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 7399744..e039958 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -587,7 +587,7 @@ out_unlock:
return count;
}
-const struct file_operations filter_fops = {
+static const struct file_operations filter_fops = {
.read = filter_read,
.write = filter_write,
};
--
1.6.6
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [git pull] IOMMU fixes for 2.6.33-rc5
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
` (4 preceding siblings ...)
2010-01-22 17:18 ` [PATCH 5/5] lib/dma-debug.c: mark file-local struct symbol static Joerg Roedel
@ 2010-01-27 10:04 ` Ingo Molnar
5 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2010-01-27 10:04 UTC (permalink / raw)
To: Joerg Roedel; +Cc: Ingo Molnar, x86, linux-kernel, iommu
* Joerg Roedel <joerg.roedel@amd.com> wrote:
> Hi Ingo,
>
> The following changes since commit 92dcffb916d309aa01778bf8963a6932e4014d07:
> Linus Torvalds (1):
> Linux 2.6.33-rc5
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu.git iommu/fixes
>
> Joerg Roedel (5):
> x86/amd-iommu: Fix possible integer overflow
> x86/amd-iommu: Fix NULL pointer dereference in __detach_device()
> x86/amd-iommu: Fix IOMMU-API initialization for iommu=pt
> x86/amd-iommu: Fix deassignment of a device from the pt_domain
> Merge branches 'amd-iommu/fixes' and 'dma-debug/fixes' into iommu/fixes
>
> Thiago Farina (1):
> lib/dma-debug.c: mark file-local struct symbol static.
>
> arch/x86/include/asm/amd_iommu_proto.h | 1 +
> arch/x86/kernel/amd_iommu.c | 23 ++++++++++++++++-------
> arch/x86/kernel/amd_iommu_init.c | 3 +++
> lib/dma-debug.c | 2 +-
> 4 files changed, 21 insertions(+), 8 deletions(-)
>
> The patches fix several issues with device kvm device assignement when the
> amd iommu driver is configured to run in passthrough mode. One patch fixes a
> possible integer overflow in the driver as well. The last patch in the
> series fixes a build warning in the dma-api debug code. Please pull.
Pulled, thanks a lot Joerg!
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread