sparc64: Fix mapping of 64k pages with MAP_FIXED
authorNitin Gupta <nitin.m.gupta@oracle.com>
Mon, 15 May 2017 23:28:17 +0000 (16:28 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 May 2017 19:07:01 +0000 (12:07 -0700)
An incorrect huge page alignment check caused
mmap failure for 64K pages when MAP_FIXED is used
with address not aligned to HPAGE_SIZE.

Orabug: 25885991

Fixes: dcd1912d21a0 ("sparc64: Add 64K page size support")
Signed-off-by: Nitin Gupta <nitin.m.gupta@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/include/asm/hugetlb.h

index dcbf985ab243201250222a824fc1146320522e65..d1f837dc77a4d0c975f94e5bbd315b347001d01a 100644 (file)
@@ -24,9 +24,11 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 static inline int prepare_hugepage_range(struct file *file,
                        unsigned long addr, unsigned long len)
 {
-       if (len & ~HPAGE_MASK)
+       struct hstate *h = hstate_file(file);
+
+       if (len & ~huge_page_mask(h))
                return -EINVAL;
-       if (addr & ~HPAGE_MASK)
+       if (addr & ~huge_page_mask(h))
                return -EINVAL;
        return 0;
 }