|
@@ -89,32 +89,43 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
|
|
struct mm_struct *mm = current->mm;
|
|
struct mm_struct *mm = current->mm;
|
|
struct vm_area_struct *vma;
|
|
struct vm_area_struct *vma;
|
|
struct vm_unmapped_area_info info;
|
|
struct vm_unmapped_area_info info;
|
|
|
|
+ int rc;
|
|
|
|
|
|
- if (len > mm->context.asce_limit - mmap_min_addr)
|
|
|
|
|
|
+ if (len > TASK_SIZE - mmap_min_addr)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
if (flags & MAP_FIXED)
|
|
if (flags & MAP_FIXED)
|
|
- return addr;
|
|
|
|
|
|
+ goto check_asce_limit;
|
|
|
|
|
|
if (addr) {
|
|
if (addr) {
|
|
addr = PAGE_ALIGN(addr);
|
|
addr = PAGE_ALIGN(addr);
|
|
vma = find_vma(mm, addr);
|
|
vma = find_vma(mm, addr);
|
|
- if (mm->context.asce_limit - len >= addr &&
|
|
|
|
- addr >= mmap_min_addr &&
|
|
|
|
|
|
+ if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
|
|
(!vma || addr + len <= vma->vm_start))
|
|
(!vma || addr + len <= vma->vm_start))
|
|
- return addr;
|
|
|
|
|
|
+ goto check_asce_limit;
|
|
}
|
|
}
|
|
|
|
|
|
info.flags = 0;
|
|
info.flags = 0;
|
|
info.length = len;
|
|
info.length = len;
|
|
info.low_limit = mm->mmap_base;
|
|
info.low_limit = mm->mmap_base;
|
|
- info.high_limit = mm->context.asce_limit;
|
|
|
|
|
|
+ info.high_limit = TASK_SIZE;
|
|
if (filp || (flags & MAP_SHARED))
|
|
if (filp || (flags & MAP_SHARED))
|
|
info.align_mask = MMAP_ALIGN_MASK << PAGE_SHIFT;
|
|
info.align_mask = MMAP_ALIGN_MASK << PAGE_SHIFT;
|
|
else
|
|
else
|
|
info.align_mask = 0;
|
|
info.align_mask = 0;
|
|
info.align_offset = pgoff << PAGE_SHIFT;
|
|
info.align_offset = pgoff << PAGE_SHIFT;
|
|
- return vm_unmapped_area(&info);
|
|
|
|
|
|
+ addr = vm_unmapped_area(&info);
|
|
|
|
+ if (addr & ~PAGE_MASK)
|
|
|
|
+ return addr;
|
|
|
|
+
|
|
|
|
+check_asce_limit:
|
|
|
|
+ if (addr + len > current->mm->context.asce_limit) {
|
|
|
|
+ rc = crst_table_upgrade(mm);
|
|
|
|
+ if (rc)
|
|
|
|
+ return (unsigned long) rc;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return addr;
|
|
}
|
|
}
|
|
|
|
|
|
unsigned long
|
|
unsigned long
|
|
@@ -126,22 +137,22 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
|
|
struct mm_struct *mm = current->mm;
|
|
struct mm_struct *mm = current->mm;
|
|
unsigned long addr = addr0;
|
|
unsigned long addr = addr0;
|
|
struct vm_unmapped_area_info info;
|
|
struct vm_unmapped_area_info info;
|
|
|
|
+ int rc;
|
|
|
|
|
|
/* requested length too big for entire address space */
|
|
/* requested length too big for entire address space */
|
|
- if (len > mm->context.asce_limit - mmap_min_addr)
|
|
|
|
|
|
+ if (len > TASK_SIZE - mmap_min_addr)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
if (flags & MAP_FIXED)
|
|
if (flags & MAP_FIXED)
|
|
- return addr;
|
|
|
|
|
|
+ goto check_asce_limit;
|
|
|
|
|
|
/* requesting a specific address */
|
|
/* requesting a specific address */
|
|
if (addr) {
|
|
if (addr) {
|
|
addr = PAGE_ALIGN(addr);
|
|
addr = PAGE_ALIGN(addr);
|
|
vma = find_vma(mm, addr);
|
|
vma = find_vma(mm, addr);
|
|
- if (mm->context.asce_limit - len >= addr &&
|
|
|
|
- addr >= mmap_min_addr &&
|
|
|
|
|
|
+ if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
|
|
(!vma || addr + len <= vma->vm_start))
|
|
(!vma || addr + len <= vma->vm_start))
|
|
- return addr;
|
|
|
|
|
|
+ goto check_asce_limit;
|
|
}
|
|
}
|
|
|
|
|
|
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
|
|
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
|
|
@@ -165,58 +176,22 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
|
|
VM_BUG_ON(addr != -ENOMEM);
|
|
VM_BUG_ON(addr != -ENOMEM);
|
|
info.flags = 0;
|
|
info.flags = 0;
|
|
info.low_limit = TASK_UNMAPPED_BASE;
|
|
info.low_limit = TASK_UNMAPPED_BASE;
|
|
- info.high_limit = mm->context.asce_limit;
|
|
|
|
|
|
+ info.high_limit = TASK_SIZE;
|
|
addr = vm_unmapped_area(&info);
|
|
addr = vm_unmapped_area(&info);
|
|
|
|
+ if (addr & ~PAGE_MASK)
|
|
|
|
+ return addr;
|
|
}
|
|
}
|
|
|
|
|
|
- return addr;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static unsigned long
|
|
|
|
-s390_get_unmapped_area(struct file *filp, unsigned long addr,
|
|
|
|
- unsigned long len, unsigned long pgoff, unsigned long flags)
|
|
|
|
-{
|
|
|
|
- struct mm_struct *mm = current->mm;
|
|
|
|
- unsigned long area;
|
|
|
|
- int rc;
|
|
|
|
-
|
|
|
|
- area = arch_get_unmapped_area(filp, addr, len, pgoff, flags);
|
|
|
|
- if (!(area & ~PAGE_MASK))
|
|
|
|
- return area;
|
|
|
|
- if (area == -ENOMEM && !is_compat_task() &&
|
|
|
|
- current->mm->context.asce_limit < TASK_SIZE_MAX) {
|
|
|
|
- /* Upgrade the page table to 4 levels and retry. */
|
|
|
|
|
|
+check_asce_limit:
|
|
|
|
+ if (addr + len > current->mm->context.asce_limit) {
|
|
rc = crst_table_upgrade(mm);
|
|
rc = crst_table_upgrade(mm);
|
|
if (rc)
|
|
if (rc)
|
|
return (unsigned long) rc;
|
|
return (unsigned long) rc;
|
|
- area = arch_get_unmapped_area(filp, addr, len, pgoff, flags);
|
|
|
|
}
|
|
}
|
|
- return area;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static unsigned long
|
|
|
|
-s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr,
|
|
|
|
- const unsigned long len, const unsigned long pgoff,
|
|
|
|
- const unsigned long flags)
|
|
|
|
-{
|
|
|
|
- struct mm_struct *mm = current->mm;
|
|
|
|
- unsigned long area;
|
|
|
|
- int rc;
|
|
|
|
|
|
|
|
- area = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags);
|
|
|
|
- if (!(area & ~PAGE_MASK))
|
|
|
|
- return area;
|
|
|
|
- if (area == -ENOMEM && !is_compat_task() &&
|
|
|
|
- current->mm->context.asce_limit < TASK_SIZE_MAX) {
|
|
|
|
- /* Upgrade the page table to 4 levels and retry. */
|
|
|
|
- rc = crst_table_upgrade(mm);
|
|
|
|
- if (rc)
|
|
|
|
- return (unsigned long) rc;
|
|
|
|
- area = arch_get_unmapped_area_topdown(filp, addr, len,
|
|
|
|
- pgoff, flags);
|
|
|
|
- }
|
|
|
|
- return area;
|
|
|
|
|
|
+ return addr;
|
|
}
|
|
}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* This function, called very early during the creation of a new
|
|
* This function, called very early during the creation of a new
|
|
* process VM image, sets up which VM layout function to use:
|
|
* process VM image, sets up which VM layout function to use:
|
|
@@ -234,9 +209,9 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
|
|
*/
|
|
*/
|
|
if (mmap_is_legacy()) {
|
|
if (mmap_is_legacy()) {
|
|
mm->mmap_base = mmap_base_legacy(random_factor);
|
|
mm->mmap_base = mmap_base_legacy(random_factor);
|
|
- mm->get_unmapped_area = s390_get_unmapped_area;
|
|
|
|
|
|
+ mm->get_unmapped_area = arch_get_unmapped_area;
|
|
} else {
|
|
} else {
|
|
mm->mmap_base = mmap_base(random_factor);
|
|
mm->mmap_base = mmap_base(random_factor);
|
|
- mm->get_unmapped_area = s390_get_unmapped_area_topdown;
|
|
|
|
|
|
+ mm->get_unmapped_area = arch_get_unmapped_area_topdown;
|
|
}
|
|
}
|
|
}
|
|
}
|