aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/kernel/process.c
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2014-01-31 16:19:52 -0500
committerHelge Deller <deller@gmx.de>2014-02-02 15:00:13 -0500
commit9dabf60dc4abe6e06bebcc2ee46b4d76ec8741f2 (patch)
tree93b98d806b1941b91ac3de04b7bd730103d3fab8 /arch/parisc/kernel/process.c
parentf5a408d53edef3af07ac7697b8bc54a755628450 (diff)
parisc: add flexible mmap memory layout support
Add support for the flexible mmap memory layout (as described in http://lwn.net/Articles/91829). This is especially very interesting on parisc since we currently only support 32bit userspace (even with a 64bit Linux kernel). Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'arch/parisc/kernel/process.c')
-rw-r--r--arch/parisc/kernel/process.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 55f92b614182..0bbbf0d3f608 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -13,7 +13,7 @@
13 * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org> 13 * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org>
14 * Copyright (C) 2001 Alan Modra <amodra at parisc-linux.org> 14 * Copyright (C) 2001 Alan Modra <amodra at parisc-linux.org>
15 * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org> 15 * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org>
16 * Copyright (C) 2001-2007 Helge Deller <deller at parisc-linux.org> 16 * Copyright (C) 2001-2014 Helge Deller <deller@gmx.de>
17 * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org> 17 * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org>
18 * 18 *
19 * 19 *
@@ -49,6 +49,7 @@
49#include <linux/kallsyms.h> 49#include <linux/kallsyms.h>
50#include <linux/uaccess.h> 50#include <linux/uaccess.h>
51#include <linux/rcupdate.h> 51#include <linux/rcupdate.h>
52#include <linux/random.h>
52 53
53#include <asm/io.h> 54#include <asm/io.h>
54#include <asm/asm-offsets.h> 55#include <asm/asm-offsets.h>
@@ -286,3 +287,21 @@ void *dereference_function_descriptor(void *ptr)
286 return ptr; 287 return ptr;
287} 288}
288#endif 289#endif
290
291static inline unsigned long brk_rnd(void)
292{
293 /* 8MB for 32bit, 1GB for 64bit */
294 if (is_32bit_task())
295 return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
296 else
297 return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
298}
299
300unsigned long arch_randomize_brk(struct mm_struct *mm)
301{
302 unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
303
304 if (ret < mm->brk)
305 return mm->brk;
306 return ret;
307}