Skip to content

Commit 3b4d07d

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm/hash: Handle mmap_min_addr correctly in get_unmapped_area topdown search
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: fba2369 ("mm: use vm_unmapped_area() on powerpc architecture") Reviewed-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 5330367 commit 3b4d07d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/powerpc/mm/slice.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/export.h>
3333
#include <linux/hugetlb.h>
3434
#include <linux/sched/mm.h>
35+
#include <linux/security.h>
3536
#include <asm/mman.h>
3637
#include <asm/mmu.h>
3738
#include <asm/copro.h>
@@ -377,6 +378,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
377378
int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT);
378379
unsigned long addr, found, prev;
379380
struct vm_unmapped_area_info info;
381+
unsigned long min_addr = max(PAGE_SIZE, mmap_min_addr);
380382

381383
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
382384
info.length = len;
@@ -393,7 +395,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
393395
if (high_limit > DEFAULT_MAP_WINDOW)
394396
addr += mm->context.slb_addr_limit - DEFAULT_MAP_WINDOW;
395397

396-
while (addr > PAGE_SIZE) {
398+
while (addr > min_addr) {
397399
info.high_limit = addr;
398400
if (!slice_scan_available(addr - 1, available, 0, &addr))
399401
continue;
@@ -405,8 +407,8 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
405407
* Check if we need to reduce the range, or if we can
406408
* extend it to cover the previous available slice.
407409
*/
408-
if (addr < PAGE_SIZE)
409-
addr = PAGE_SIZE;
410+
if (addr < min_addr)
411+
addr = min_addr;
410412
else if (slice_scan_available(addr - 1, available, 0, &prev)) {
411413
addr = prev;
412414
goto prev_slice;
@@ -528,7 +530,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
528530
addr = _ALIGN_UP(addr, page_size);
529531
slice_dbg(" aligned addr=%lx\n", addr);
530532
/* Ignore hint if it's too large or overlaps a VMA */
531-
if (addr > high_limit - len ||
533+
if (addr > high_limit - len || addr < mmap_min_addr ||
532534
!slice_area_is_free(mm, addr, len))
533535
addr = 0;
534536
}

0 commit comments

Comments
 (0)