Skip to content

Commit fbfef90

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm: Switch some TASK_SIZE checks to use mm_context addr_limit
Signed-off-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 82228e3 commit fbfef90

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

arch/powerpc/mm/hugetlbpage-radix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
5252

5353
if (len & ~huge_page_mask(h))
5454
return -EINVAL;
55-
if (len > TASK_SIZE)
55+
if (len > mm->context.addr_limit)
5656
return -ENOMEM;
5757

5858
if (flags & MAP_FIXED) {
@@ -64,7 +64,7 @@ radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
6464
if (addr) {
6565
addr = ALIGN(addr, huge_page_size(h));
6666
vma = find_vma(mm, addr);
67-
if (TASK_SIZE - len >= addr &&
67+
if (mm->context.addr_limit - len >= addr &&
6868
(!vma || addr + len <= vma->vm_start))
6969
return addr;
7070
}

arch/powerpc/mm/mmap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ radix__arch_get_unmapped_area(struct file *filp, unsigned long addr,
9797
struct vm_area_struct *vma;
9898
struct vm_unmapped_area_info info;
9999

100-
if (len > TASK_SIZE - mmap_min_addr)
100+
if (len > mm->context.addr_limit - mmap_min_addr)
101101
return -ENOMEM;
102102

103103
if (flags & MAP_FIXED)
@@ -106,15 +106,15 @@ radix__arch_get_unmapped_area(struct file *filp, unsigned long addr,
106106
if (addr) {
107107
addr = PAGE_ALIGN(addr);
108108
vma = find_vma(mm, addr);
109-
if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
109+
if (mm->context.addr_limit - len >= addr && addr >= mmap_min_addr &&
110110
(!vma || addr + len <= vma->vm_start))
111111
return addr;
112112
}
113113

114114
info.flags = 0;
115115
info.length = len;
116116
info.low_limit = mm->mmap_base;
117-
info.high_limit = TASK_SIZE;
117+
info.high_limit = mm->context.addr_limit;
118118
info.align_mask = 0;
119119
return vm_unmapped_area(&info);
120120
}
@@ -132,7 +132,7 @@ radix__arch_get_unmapped_area_topdown(struct file *filp,
132132
struct vm_unmapped_area_info info;
133133

134134
/* requested length too big for entire address space */
135-
if (len > TASK_SIZE - mmap_min_addr)
135+
if (len > mm->context.addr_limit - mmap_min_addr)
136136
return -ENOMEM;
137137

138138
if (flags & MAP_FIXED)
@@ -142,7 +142,7 @@ radix__arch_get_unmapped_area_topdown(struct file *filp,
142142
if (addr) {
143143
addr = PAGE_ALIGN(addr);
144144
vma = find_vma(mm, addr);
145-
if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
145+
if (mm->context.addr_limit - len >= addr && addr >= mmap_min_addr &&
146146
(!vma || addr + len <= vma->vm_start))
147147
return addr;
148148
}
@@ -164,7 +164,7 @@ radix__arch_get_unmapped_area_topdown(struct file *filp,
164164
VM_BUG_ON(addr != -ENOMEM);
165165
info.flags = 0;
166166
info.low_limit = TASK_UNMAPPED_BASE;
167-
info.high_limit = TASK_SIZE;
167+
info.high_limit = mm->context.addr_limit;
168168
addr = vm_unmapped_area(&info);
169169
}
170170

arch/powerpc/mm/slice.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
277277
info.align_offset = 0;
278278

279279
addr = TASK_UNMAPPED_BASE;
280-
while (addr < TASK_SIZE) {
280+
while (addr < mm->context.addr_limit) {
281281
info.low_limit = addr;
282282
if (!slice_scan_available(addr, available, 1, &addr))
283283
continue;
@@ -289,8 +289,8 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
289289
* Check if we need to reduce the range, or if we can
290290
* extend it to cover the next available slice.
291291
*/
292-
if (addr >= TASK_SIZE)
293-
addr = TASK_SIZE;
292+
if (addr >= mm->context.addr_limit)
293+
addr = mm->context.addr_limit;
294294
else if (slice_scan_available(addr, available, 1, &next_end)) {
295295
addr = next_end;
296296
goto next_slice;

arch/powerpc/mm/subpage-prot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ long sys_subpage_prot(unsigned long addr, unsigned long len, u32 __user *map)
197197

198198
/* Check parameters */
199199
if ((addr & ~PAGE_MASK) || (len & ~PAGE_MASK) ||
200-
addr >= TASK_SIZE || len >= TASK_SIZE || addr + len > TASK_SIZE)
200+
addr >= mm->context.addr_limit || len >= mm->context.addr_limit ||
201+
addr + len > mm->context.addr_limit)
201202
return -EINVAL;
202203

203204
if (is_hugepage_only_range(mm, addr, len))

0 commit comments

Comments
 (0)