* [PATCH] lib/dma-debug: check for vmalloc buffers used with the DMA-API
@ 2012-09-03 11:00 Jan Luebbe
2012-09-18 13:18 ` Joerg Roedel
0 siblings, 1 reply; 3+ messages in thread
From: Jan Luebbe @ 2012-09-03 11:00 UTC (permalink / raw)
To: Joerg Roedel; +Cc: linux-kernel, Jan Luebbe
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
I'm not sure why we don't check for high memory, is there any problem
with this approach?
lib/dma-debug.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..7d60ff0 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,9 @@ static void check_for_illegal_area(struct device *dev, void *addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
+ if (is_vmalloc_or_module_addr(addr) ||
+ is_vmalloc_or_module_addr(addr+len))
+ err_printk(dev, NULL, "DMA-API: device driver maps memory from vmalloc or module address range [addr=%p] [len=%lu]\n", addr, len);
}
static void check_sync(struct device *dev,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/dma-debug: check for vmalloc buffers used with the DMA-API
2012-09-03 11:00 [PATCH] lib/dma-debug: check for vmalloc buffers used with the DMA-API Jan Luebbe
@ 2012-09-18 13:18 ` Joerg Roedel
2012-09-19 15:28 ` [PATCH v2] lib/dma-debug: check for vmalloc and module addresses " Jan Luebbe
0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2012-09-18 13:18 UTC (permalink / raw)
To: Jan Luebbe; +Cc: linux-kernel
On Mon, Sep 03, 2012 at 01:00:04PM +0200, Jan Luebbe wrote:
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> ---
> I'm not sure why we don't check for high memory, is there any problem
> with this approach?
>
> lib/dma-debug.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/dma-debug.c b/lib/dma-debug.c
> index 66ce414..7d60ff0 100644
> --- a/lib/dma-debug.c
> +++ b/lib/dma-debug.c
> @@ -944,6 +944,9 @@ static void check_for_illegal_area(struct device *dev, void *addr, unsigned long
> if (overlap(addr, len, _text, _etext) ||
> overlap(addr, len, __start_rodata, __end_rodata))
> err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
> + if (is_vmalloc_or_module_addr(addr) ||
> + is_vmalloc_or_module_addr(addr+len))
> + err_printk(dev, NULL, "DMA-API: device driver maps memory from vmalloc or module address range [addr=%p] [len=%lu]\n", addr, len);
Hmm, this only checks whether the start or end+1 address is in the
vmalloc/module range. I think it is better to check for overlap against
VMALLOC_START/END and do a seperate overlap check for MODULES_VADDR and
MODULES_END when needed.
Thanks,
Joerg
--
AMD Operating System Research Center
Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] lib/dma-debug: check for vmalloc and module addresses used with the DMA-API
2012-09-18 13:18 ` Joerg Roedel
@ 2012-09-19 15:28 ` Jan Luebbe
0 siblings, 0 replies; 3+ messages in thread
From: Jan Luebbe @ 2012-09-19 15:28 UTC (permalink / raw)
To: Joerg Roedel; +Cc: linux-kernel, Jan Luebbe
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
Changes since v1:
- As recommended by Joerg Roedel, check for overlap with vmalloc and
module address ranges.
lib/dma-debug.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..b35992b 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,14 @@ static void check_for_illegal_area(struct device *dev, void *addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
+#ifdef CONFIG_MMU
+ if (overlap(addr, len, (void *)VMALLOC_START, (void *)VMALLOC_END))
+ err_printk(dev, NULL, "DMA-API: device driver maps memory from vmalloc address range [addr=%p] [len=%lu]\n", addr, len);
+#endif
+#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
+ if (overlap(addr, len, (void *)MODULES_VADDR, (void *)MODULES_END))
+ err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel module address range [addr=%p] [len=%lu]\n", addr, len);
+#endif
}
static void check_sync(struct device *dev,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-19 15:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 11:00 [PATCH] lib/dma-debug: check for vmalloc buffers used with the DMA-API Jan Luebbe
2012-09-18 13:18 ` Joerg Roedel
2012-09-19 15:28 ` [PATCH v2] lib/dma-debug: check for vmalloc and module addresses " Jan Luebbe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).