Skip to content

Commit

Permalink
[PATCH] highmem: catch illegal nesting
Browse files Browse the repository at this point in the history
Catch illegally nested kmap_atomic()s even if the page that is mapped by
the 'inner' instance is from lowmem.

This avoids spuriously zapped kmap-atomic ptes and turns hard to find
crashes into clear asserts at the bug site.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Feb 11, 2007
1 parent 3e4fdaf commit 656dad3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arch/i386/mm/highmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ void *kmap_atomic(struct page *page, enum km_type type)

/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
pagefault_disable();

idx = type + KM_TYPE_NR*smp_processor_id();
BUG_ON(!pte_none(*(kmap_pte-idx)));

if (!PageHighMem(page))
return page_address(page);

idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
if (!pte_none(*(kmap_pte-idx)))
BUG();
set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));

return (void*) vaddr;
Expand Down

0 comments on commit 656dad3

Please sign in to comment.