aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-03-23 10:35:08 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-24 03:39:32 -0400
commit9537a48ed4b9e4b738943d6da0a0fd4278adf905 (patch)
tree06f512876680265ece3bd46b14c2b1c234202918
parent35d40952dba7b0689a16bd1463fb7698f8dbe639 (diff)
dma-debug: make memory range checks more consistent
Impact: extend on-kernel-stack DMA debug checks to all !highmem pages We only checked dma_map_single() - extend it to dma_map_page() and dma_map_sg() as well. Also, fix dma_map_single() corner case bug: make sure we dont stack-check highmem (not mapped) pages. Reported-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Cc: iommu@lists.linux-foundation.org LKML-Reference: <1237818908-26516-1-git-send-email-joerg.roedel@amd.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--lib/dma-debug.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index f9e6d38b4b34..1a992089486c 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -722,10 +722,11 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
722 entry->size = size; 722 entry->size = size;
723 entry->direction = direction; 723 entry->direction = direction;
724 724
725 if (map_single) { 725 if (map_single)
726 void *addr = ((char *)page_address(page)) + offset;
727
728 entry->type = dma_debug_single; 726 entry->type = dma_debug_single;
727
728 if (!PageHighMem(page)) {
729 void *addr = ((char *)page_address(page)) + offset;
729 check_for_stack(dev, addr); 730 check_for_stack(dev, addr);
730 check_for_illegal_area(dev, addr, size); 731 check_for_illegal_area(dev, addr, size);
731 } 732 }
@@ -779,8 +780,10 @@ void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
779 entry->sg_call_ents = nents; 780 entry->sg_call_ents = nents;
780 entry->sg_mapped_ents = mapped_ents; 781 entry->sg_mapped_ents = mapped_ents;
781 782
782 check_for_stack(dev, sg_virt(s)); 783 if (!PageHighMem(sg_page(s))) {
783 check_for_illegal_area(dev, sg_virt(s), s->length); 784 check_for_stack(dev, sg_virt(s));
785 check_for_illegal_area(dev, sg_virt(s), s->length);
786 }
784 787
785 add_dma_entry(entry); 788 add_dma_entry(entry);
786 } 789 }