diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-08-31 02:56:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-08-31 04:42:23 -0400 |
commit | dec4ad86c2fbea062e9ef9caa6d6e79f7c5e0b12 (patch) | |
tree | 9882d3b1f59fb293cf0f70afc80bdc7bb1e0021e /include/linux/hugetlb.h | |
parent | 4a58448b0a375f7198de34dd0d3e2881afeaf025 (diff) |
hugepage: fix broken check for offset alignment in hugepage mappings
For hugepage mappings, the file offset, like the address and size, needs to
be aligned to the size of a hugepage.
In commit 68589bc353037f233fe510ad9ff432338c95db66, the check for this was
moved into prepare_hugepage_range() along with the address and size checks.
But since BenH's rework of the get_unmapped_area() paths leading up to
commit 4b1d89290b62bb2db476c94c82cf7442aab440c8, prepare_hugepage_range()
is only called for MAP_FIXED mappings, not for other mappings. This means
we're no longer ever checking for an aligned offset - I've confirmed that
mmap() will (apparently) succeed with a misaligned offset on both powerpc
and i386 at least.
This patch restores the check, removing it from prepare_hugepage_range()
and putting it back into hugetlbfs_file_mmap(). I'm putting it there,
rather than in the get_unmapped_area() path so it only needs to go in one
place, than separately in the half-dozen or so arch-specific
implementations of hugetlb_get_unmapped_area().
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cc: Adam Litke <agl@us.ibm.com>
Cc: Andi Kleen <ak@suse.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/hugetlb.h')
-rw-r--r-- | include/linux/hugetlb.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index e6a71c82d204..3a19b032c0eb 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
@@ -66,11 +66,8 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr, | |||
66 | * If the arch doesn't supply something else, assume that hugepage | 66 | * If the arch doesn't supply something else, assume that hugepage |
67 | * size aligned regions are ok without further preparation. | 67 | * size aligned regions are ok without further preparation. |
68 | */ | 68 | */ |
69 | static inline int prepare_hugepage_range(unsigned long addr, unsigned long len, | 69 | static inline int prepare_hugepage_range(unsigned long addr, unsigned long len) |
70 | pgoff_t pgoff) | ||
71 | { | 70 | { |
72 | if (pgoff & (~HPAGE_MASK >> PAGE_SHIFT)) | ||
73 | return -EINVAL; | ||
74 | if (len & ~HPAGE_MASK) | 71 | if (len & ~HPAGE_MASK) |
75 | return -EINVAL; | 72 | return -EINVAL; |
76 | if (addr & ~HPAGE_MASK) | 73 | if (addr & ~HPAGE_MASK) |
@@ -78,8 +75,7 @@ static inline int prepare_hugepage_range(unsigned long addr, unsigned long len, | |||
78 | return 0; | 75 | return 0; |
79 | } | 76 | } |
80 | #else | 77 | #else |
81 | int prepare_hugepage_range(unsigned long addr, unsigned long len, | 78 | int prepare_hugepage_range(unsigned long addr, unsigned long len); |
82 | pgoff_t pgoff); | ||
83 | #endif | 79 | #endif |
84 | 80 | ||
85 | #ifndef ARCH_HAS_SETCLEAR_HUGE_PTE | 81 | #ifndef ARCH_HAS_SETCLEAR_HUGE_PTE |
@@ -117,7 +113,7 @@ static inline unsigned long hugetlb_total_pages(void) | |||
117 | #define hugetlb_report_meminfo(buf) 0 | 113 | #define hugetlb_report_meminfo(buf) 0 |
118 | #define hugetlb_report_node_meminfo(n, buf) 0 | 114 | #define hugetlb_report_node_meminfo(n, buf) 0 |
119 | #define follow_huge_pmd(mm, addr, pmd, write) NULL | 115 | #define follow_huge_pmd(mm, addr, pmd, write) NULL |
120 | #define prepare_hugepage_range(addr,len,pgoff) (-EINVAL) | 116 | #define prepare_hugepage_range(addr,len) (-EINVAL) |
121 | #define pmd_huge(x) 0 | 117 | #define pmd_huge(x) 0 |
122 | #define is_hugepage_only_range(mm, addr, len) 0 | 118 | #define is_hugepage_only_range(mm, addr, len) 0 |
123 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) | 119 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) |