提交 c7e220ef 编写于 作者: A Aneesh Kumar K.V 提交者: Greg Kroah-Hartman

powerpc/mm/hash: Handle mmap_min_addr correctly in get_unmapped_area topdown search

commit 3b4d07d2674f6b4a9281031f99d1f7efd325b16d upstream.

When doing top-down search the low_limit is not PAGE_SIZE but rather
max(PAGE_SIZE, mmap_min_addr). This handle cases in which mmap_min_addr >
PAGE_SIZE.

Fixes: fba2369e ("mm: use vm_unmapped_area() on powerpc architecture")
Reviewed-by: NLaurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a78c3898
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/hugetlb.h> #include <linux/hugetlb.h>
#include <linux/security.h>
#include <asm/mman.h> #include <asm/mman.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/copro.h> #include <asm/copro.h>
...@@ -376,6 +377,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, ...@@ -376,6 +377,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT);
unsigned long addr, found, prev; unsigned long addr, found, prev;
struct vm_unmapped_area_info info; struct vm_unmapped_area_info info;
unsigned long min_addr = max(PAGE_SIZE, mmap_min_addr);
info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.flags = VM_UNMAPPED_AREA_TOPDOWN;
info.length = len; info.length = len;
...@@ -392,7 +394,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, ...@@ -392,7 +394,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
if (high_limit > DEFAULT_MAP_WINDOW) if (high_limit > DEFAULT_MAP_WINDOW)
addr += mm->context.slb_addr_limit - DEFAULT_MAP_WINDOW; addr += mm->context.slb_addr_limit - DEFAULT_MAP_WINDOW;
while (addr > PAGE_SIZE) { while (addr > min_addr) {
info.high_limit = addr; info.high_limit = addr;
if (!slice_scan_available(addr - 1, available, 0, &addr)) if (!slice_scan_available(addr - 1, available, 0, &addr))
continue; continue;
...@@ -404,8 +406,8 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm, ...@@ -404,8 +406,8 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
* Check if we need to reduce the range, or if we can * Check if we need to reduce the range, or if we can
* extend it to cover the previous available slice. * extend it to cover the previous available slice.
*/ */
if (addr < PAGE_SIZE) if (addr < min_addr)
addr = PAGE_SIZE; addr = min_addr;
else if (slice_scan_available(addr - 1, available, 0, &prev)) { else if (slice_scan_available(addr - 1, available, 0, &prev)) {
addr = prev; addr = prev;
goto prev_slice; goto prev_slice;
...@@ -527,7 +529,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, ...@@ -527,7 +529,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
addr = _ALIGN_UP(addr, page_size); addr = _ALIGN_UP(addr, page_size);
slice_dbg(" aligned addr=%lx\n", addr); slice_dbg(" aligned addr=%lx\n", addr);
/* Ignore hint if it's too large or overlaps a VMA */ /* Ignore hint if it's too large or overlaps a VMA */
if (addr > high_limit - len || if (addr > high_limit - len || addr < mmap_min_addr ||
!slice_area_is_free(mm, addr, len)) !slice_area_is_free(mm, addr, len))
addr = 0; addr = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册