aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAmerigo Wang <amwang@redhat.com>2009-05-11 22:05:28 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-12 05:13:45 -0400
commit9d62dcdfa6f6fc843f7d9b494bcd48f00b94f883 (patch)
treec319c1053b2b72b4d5eb29f87995f0e93c3ada51 /arch
parent087fa4e964e04371a67f340e1f6ac92c5db5e0a6 (diff)
x86: merge process.c a bit
Merge arch_align_stack() and arch_randomize_brk(), since they are the same. Tested on x86_64. [ Impact: cleanup ] Signed-off-by: Amerigo Wang <amwang@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/process.c14
-rw-r--r--arch/x86/kernel/process_32.c13
-rw-r--r--arch/x86/kernel/process_64.c13
3 files changed, 14 insertions, 26 deletions
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index ca989158e847..2b9a8d0fb474 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -8,6 +8,7 @@
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/pm.h> 9#include <linux/pm.h>
10#include <linux/clockchips.h> 10#include <linux/clockchips.h>
11#include <linux/random.h>
11#include <trace/power.h> 12#include <trace/power.h>
12#include <asm/system.h> 13#include <asm/system.h>
13#include <asm/apic.h> 14#include <asm/apic.h>
@@ -613,3 +614,16 @@ static int __init idle_setup(char *str)
613} 614}
614early_param("idle", idle_setup); 615early_param("idle", idle_setup);
615 616
617unsigned long arch_align_stack(unsigned long sp)
618{
619 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
620 sp -= get_random_int() % 8192;
621 return sp & ~0xf;
622}
623
624unsigned long arch_randomize_brk(struct mm_struct *mm)
625{
626 unsigned long range_end = mm->brk + 0x02000000;
627 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
628}
629
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 76f8f84043a2..a3bb049ad082 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -33,7 +33,6 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/kallsyms.h> 34#include <linux/kallsyms.h>
35#include <linux/ptrace.h> 35#include <linux/ptrace.h>
36#include <linux/random.h>
37#include <linux/personality.h> 36#include <linux/personality.h>
38#include <linux/tick.h> 37#include <linux/tick.h>
39#include <linux/percpu.h> 38#include <linux/percpu.h>
@@ -497,15 +496,3 @@ unsigned long get_wchan(struct task_struct *p)
497 return 0; 496 return 0;
498} 497}
499 498
500unsigned long arch_align_stack(unsigned long sp)
501{
502 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
503 sp -= get_random_int() % 8192;
504 return sp & ~0xf;
505}
506
507unsigned long arch_randomize_brk(struct mm_struct *mm)
508{
509 unsigned long range_end = mm->brk + 0x02000000;
510 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
511}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b751a41392b1..34386f72bdcf 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -32,7 +32,6 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/ptrace.h> 34#include <linux/ptrace.h>
35#include <linux/random.h>
36#include <linux/notifier.h> 35#include <linux/notifier.h>
37#include <linux/kprobes.h> 36#include <linux/kprobes.h>
38#include <linux/kdebug.h> 37#include <linux/kdebug.h>
@@ -660,15 +659,3 @@ long sys_arch_prctl(int code, unsigned long addr)
660 return do_arch_prctl(current, code, addr); 659 return do_arch_prctl(current, code, addr);
661} 660}
662 661
663unsigned long arch_align_stack(unsigned long sp)
664{
665 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
666 sp -= get_random_int() % 8192;
667 return sp & ~0xf;
668}
669
670unsigned long arch_randomize_brk(struct mm_struct *mm)
671{
672 unsigned long range_end = mm->brk + 0x02000000;
673 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
674}