Skip to content

Commit

Permalink
kmemcheck: add DMA hooks
Browse files Browse the repository at this point in the history
This patch hooks into the DMA API to prevent the reporting of the
false positives that would otherwise be reported when memory is
accessed that is also used directly by devices.

[rebased for mainline inclusion]
Signed-off-by: Vegard Nossum <[email protected]>
  • Loading branch information
vegard committed Jun 15, 2009
1 parent 2dff440 commit d700285
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/x86/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Documentation/DMA-API.txt for documentation.
*/

#include <linux/kmemcheck.h>
#include <linux/scatterlist.h>
#include <linux/dma-debug.h>
#include <linux/dma-attrs.h>
Expand Down Expand Up @@ -60,6 +61,7 @@ dma_map_single(struct device *hwdev, void *ptr, size_t size,
dma_addr_t addr;

BUG_ON(!valid_dma_direction(dir));
kmemcheck_mark_initialized(ptr, size);
addr = ops->map_page(hwdev, virt_to_page(ptr),
(unsigned long)ptr & ~PAGE_MASK, size,
dir, NULL);
Expand Down
16 changes: 16 additions & 0 deletions include/linux/kmemcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ static inline bool kmemcheck_page_is_tracked(struct page *p)
{
return false;
}

static inline void kmemcheck_mark_unallocated(void *address, unsigned int n)
{
}

static inline void kmemcheck_mark_uninitialized(void *address, unsigned int n)
{
}

static inline void kmemcheck_mark_initialized(void *address, unsigned int n)
{
}

static inline void kmemcheck_mark_freed(void *address, unsigned int n)
{
}
#endif /* CONFIG_KMEMCHECK */

#endif /* LINUX_KMEMCHECK_H */

0 comments on commit d700285

Please sign in to comment.