sys_parisc.c (642073c306e66daca108cb630d169129e50a6ba3) | sys_parisc.c (3033cd4307681c60db6d08f398a64484b36e0b0f) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2 3/* 4 * PARISC specific syscalls 5 * 6 * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org> 7 * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> 8 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> --- 147 unchanged lines hidden (view full) --- 156 * A failed mmap() very likely causes application failure, 157 * so fall back to the bottom-up function here. This scenario 158 * can happen with large stack limits and large mmap() 159 * allocations. 160 */ 161 } 162 163 info.flags = 0; | 1// SPDX-License-Identifier: GPL-2.0-or-later 2 3/* 4 * PARISC specific syscalls 5 * 6 * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org> 7 * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> 8 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> --- 147 unchanged lines hidden (view full) --- 156 * A failed mmap() very likely causes application failure, 157 * so fall back to the bottom-up function here. This scenario 158 * can happen with large stack limits and large mmap() 159 * allocations. 160 */ 161 } 162 163 info.flags = 0; |
164 info.low_limit = mm->mmap_legacy_base; | 164 info.low_limit = mm->mmap_base; |
165 info.high_limit = mmap_upper_limit(NULL); 166 return vm_unmapped_area(&info); 167} 168 169unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, 170 unsigned long len, unsigned long pgoff, unsigned long flags) 171{ 172 return arch_get_unmapped_area_common(filp, 173 addr, len, pgoff, flags, UP); 174} 175 176unsigned long arch_get_unmapped_area_topdown(struct file *filp, 177 unsigned long addr, unsigned long len, unsigned long pgoff, 178 unsigned long flags) 179{ 180 return arch_get_unmapped_area_common(filp, 181 addr, len, pgoff, flags, DOWN); 182} 183 | 165 info.high_limit = mmap_upper_limit(NULL); 166 return vm_unmapped_area(&info); 167} 168 169unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, 170 unsigned long len, unsigned long pgoff, unsigned long flags) 171{ 172 return arch_get_unmapped_area_common(filp, 173 addr, len, pgoff, flags, UP); 174} 175 176unsigned long arch_get_unmapped_area_topdown(struct file *filp, 177 unsigned long addr, unsigned long len, unsigned long pgoff, 178 unsigned long flags) 179{ 180 return arch_get_unmapped_area_common(filp, 181 addr, len, pgoff, flags, DOWN); 182} 183 |
184static int mmap_is_legacy(void) 185{ 186 if (current->personality & ADDR_COMPAT_LAYOUT) 187 return 1; 188 189 /* parisc stack always grows up - so a unlimited stack should 190 * not be an indicator to use the legacy memory layout. 191 * if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) 192 * return 1; 193 */ 194 195 return sysctl_legacy_va_layout; 196} 197 198static unsigned long mmap_rnd(void) 199{ 200 unsigned long rnd = 0; 201 202 if (current->flags & PF_RANDOMIZE) 203 rnd = get_random_u32() & MMAP_RND_MASK; 204 205 return rnd << PAGE_SHIFT; 206} 207 208unsigned long arch_mmap_rnd(void) 209{ 210 return (get_random_u32() & MMAP_RND_MASK) << PAGE_SHIFT; 211} 212 213static unsigned long mmap_legacy_base(void) 214{ 215 return TASK_UNMAPPED_BASE + mmap_rnd(); 216} 217 218/* 219 * This function, called very early during the creation of a new 220 * process VM image, sets up which VM layout function to use: 221 */ 222void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) 223{ 224 mm->mmap_legacy_base = mmap_legacy_base(); 225 mm->mmap_base = mmap_upper_limit(rlim_stack); 226 227 if (mmap_is_legacy()) { 228 mm->mmap_base = mm->mmap_legacy_base; 229 mm->get_unmapped_area = arch_get_unmapped_area; 230 } else { 231 mm->get_unmapped_area = arch_get_unmapped_area_topdown; 232 } 233} 234 235 | |
236asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, 237 unsigned long prot, unsigned long flags, unsigned long fd, 238 unsigned long pgoff) 239{ 240 /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE 241 we have. */ 242 return ksys_mmap_pgoff(addr, len, prot, flags, fd, 243 pgoff >> (PAGE_SHIFT - 12)); --- 213 unchanged lines hidden --- | 184asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, 185 unsigned long prot, unsigned long flags, unsigned long fd, 186 unsigned long pgoff) 187{ 188 /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE 189 we have. */ 190 return ksys_mmap_pgoff(addr, len, prot, flags, fd, 191 pgoff >> (PAGE_SHIFT - 12)); --- 213 unchanged lines hidden --- |