mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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 commit68589bc353
, 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 commit4b1d89290b
, 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>
This commit is contained in:
parent
4a58448b0a
commit
dec4ad86c2
5 changed files with 17 additions and 18 deletions
|
@ -66,11 +66,8 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
|
|||
* If the arch doesn't supply something else, assume that hugepage
|
||||
* size aligned regions are ok without further preparation.
|
||||
*/
|
||||
static inline int prepare_hugepage_range(unsigned long addr, unsigned long len,
|
||||
pgoff_t pgoff)
|
||||
static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
|
||||
{
|
||||
if (pgoff & (~HPAGE_MASK >> PAGE_SHIFT))
|
||||
return -EINVAL;
|
||||
if (len & ~HPAGE_MASK)
|
||||
return -EINVAL;
|
||||
if (addr & ~HPAGE_MASK)
|
||||
|
@ -78,8 +75,7 @@ static inline int prepare_hugepage_range(unsigned long addr, unsigned long len,
|
|||
return 0;
|
||||
}
|
||||
#else
|
||||
int prepare_hugepage_range(unsigned long addr, unsigned long len,
|
||||
pgoff_t pgoff);
|
||||
int prepare_hugepage_range(unsigned long addr, unsigned long len);
|
||||
#endif
|
||||
|
||||
#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE
|
||||
|
@ -117,7 +113,7 @@ static inline unsigned long hugetlb_total_pages(void)
|
|||
#define hugetlb_report_meminfo(buf) 0
|
||||
#define hugetlb_report_node_meminfo(n, buf) 0
|
||||
#define follow_huge_pmd(mm, addr, pmd, write) NULL
|
||||
#define prepare_hugepage_range(addr,len,pgoff) (-EINVAL)
|
||||
#define prepare_hugepage_range(addr,len) (-EINVAL)
|
||||
#define pmd_huge(x) 0
|
||||
#define is_hugepage_only_range(mm, addr, len) 0
|
||||
#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue