]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ARM-related ptep_to_address() fix
authorAndrew Morton <akpm@osdl.org>
Sat, 17 Apr 2004 10:32:46 +0000 (03:32 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 17 Apr 2004 10:32:46 +0000 (03:32 -0700)
From: William Lee Irwin III <wli@holomorphy.com>

rmk mentioned that ARM was borked as the relation, assumed by generic rmap,
PTRS_PER_PTE*sizeof(pte_t) == PAGE_SIZE, fails to hold.  The following
patch, developed jointly with him (or depending on POV, by him with me
acting as codemonkey), is reported to resolve the issue.

Specifically, while ARM dedicates an entire PAGE_SIZE -sized block of
memory to each PTE table, the PTE table itself only spans half that, the
remainder being dedicated to hardware-interpreted structures.  As the
hardware structure must be contiguous, wider ptes can't be used.  So the
core-visible PTE table only spans PAGE_SIZE/2 bytes, violating the
assumption.  This corrects masking and scaling done in ptep_to_address().

include/asm-generic/rmap.h

index 7de7730e9cc3c05df4a90d8357cfa491de704143..f743d9f80b0fac976b3a5a7623a79ac5aaaaa256 100644 (file)
@@ -57,7 +57,8 @@ static inline unsigned long ptep_to_address(pte_t * ptep)
 {
        struct page * page = kmap_atomic_to_page(ptep);
        unsigned long low_bits;
-       low_bits = ((unsigned long)ptep & ~PAGE_MASK) * PTRS_PER_PTE;
+       low_bits = ((unsigned long)ptep & (PTRS_PER_PTE*sizeof(pte_t) - 1))
+                       * (PAGE_SIZE/sizeof(pte_t));
        return page->index + low_bits;
 }