2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2009-03-26 22:23:52 +08:00
|
|
|
* This file handles the architecture dependent parts of process handling.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2012-07-20 17:15:04 +08:00
|
|
|
* Copyright IBM Corp. 1999, 2009
|
2009-03-26 22:23:52 +08:00
|
|
|
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
|
|
|
|
* Hartmut Penner <hp@de.ibm.com>,
|
|
|
|
* Denis Joseph Barrow,
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2016-05-07 18:15:34 +08:00
|
|
|
#include <linux/elf-randomize.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/sched.h>
|
2017-02-09 01:51:35 +08:00
|
|
|
#include <linux/sched/debug.h>
|
2017-02-09 01:51:36 +08:00
|
|
|
#include <linux/sched/task.h>
|
2017-02-09 01:51:37 +08:00
|
|
|
#include <linux/sched/task_stack.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
2011-10-30 22:17:13 +08:00
|
|
|
#include <linux/elfcore.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/smp.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/interrupt.h>
|
2008-04-17 13:46:25 +08:00
|
|
|
#include <linux/tick.h>
|
2011-01-12 16:55:28 +08:00
|
|
|
#include <linux/personality.h>
|
2009-01-14 21:14:36 +08:00
|
|
|
#include <linux/syscalls.h>
|
2009-09-23 04:58:42 +08:00
|
|
|
#include <linux/compat.h>
|
2011-01-05 19:47:25 +08:00
|
|
|
#include <linux/kprobes.h>
|
2011-01-12 16:55:28 +08:00
|
|
|
#include <linux/random.h>
|
2017-02-10 04:20:23 +08:00
|
|
|
#include <linux/export.h>
|
2015-09-29 23:53:22 +08:00
|
|
|
#include <linux/init_task.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/processor.h>
|
2012-07-20 17:15:08 +08:00
|
|
|
#include <asm/vtimer.h>
|
2012-09-14 19:45:24 +08:00
|
|
|
#include <asm/exec.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/irq.h>
|
2009-03-26 22:24:01 +08:00
|
|
|
#include <asm/nmi.h>
|
2011-01-05 19:48:09 +08:00
|
|
|
#include <asm/smp.h>
|
2012-03-29 01:30:02 +08:00
|
|
|
#include <asm/switch_to.h>
|
2012-07-31 16:52:05 +08:00
|
|
|
#include <asm/runtime_instr.h>
|
2008-04-17 13:46:26 +08:00
|
|
|
#include "entry.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-28 22:56:43 +08:00
|
|
|
asmlinkage void ret_from_fork(void) asm ("ret_from_fork");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-10-22 18:42:38 +08:00
|
|
|
extern void kernel_thread_starter(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Free current thread data structures etc..
|
|
|
|
*/
|
2016-05-21 08:00:20 +08:00
|
|
|
void exit_thread(struct task_struct *tsk)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-01-26 21:10:34 +08:00
|
|
|
if (tsk == current) {
|
2016-05-21 08:00:20 +08:00
|
|
|
exit_thread_runtime_instr();
|
2016-01-26 21:10:34 +08:00
|
|
|
exit_thread_gs();
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_thread(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_thread(struct task_struct *dead_task)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-09 23:47:00 +08:00
|
|
|
void arch_release_task_struct(struct task_struct *tsk)
|
|
|
|
{
|
2015-06-11 22:57:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
|
|
|
|
{
|
s390/kernel: lazy restore fpu registers
Improve the save and restore behavior of FPU register contents to use the
vector extension within the kernel.
The kernel does not use floating-point or vector registers and, therefore,
saving and restoring the FPU register contents are performed for handling
signals or switching processes only. To prepare for using vector
instructions and vector registers within the kernel, enhance the save
behavior and implement a lazy restore at return to user space from a
system call or interrupt.
To implement the lazy restore, the save_fpu_regs() sets a CPU information
flag, CIF_FPU, to indicate that the FPU registers must be restored.
Saving and setting CIF_FPU is performed in an atomic fashion to be
interrupt-safe. When the kernel wants to use the vector extension or
wants to change the FPU register state for a task during signal handling,
the save_fpu_regs() must be called first. The CIF_FPU flag is also set at
process switch. At return to user space, the FPU state is restored. In
particular, the FPU state includes the floating-point or vector register
contents, as well as, vector-enablement and floating-point control. The
FPU state restore and clearing CIF_FPU is also performed in an atomic
fashion.
For KVM, the restore of the FPU register state is performed when restoring
the general-purpose guest registers before the SIE instructions is started.
Because the path towards the SIE instruction is interruptible, the CIF_FPU
flag must be checked again right before going into SIE. If set, the guest
registers must be reloaded again by re-entering the outer SIE loop. This
is the same behavior as if the SIE critical section is interrupted.
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2015-06-10 18:53:42 +08:00
|
|
|
/*
|
|
|
|
* Save the floating-point or vector register state of the current
|
2015-09-29 16:04:41 +08:00
|
|
|
* task and set the CIF_FPU flag to lazy restore the FPU register
|
|
|
|
* state when returning to user space.
|
s390/kernel: lazy restore fpu registers
Improve the save and restore behavior of FPU register contents to use the
vector extension within the kernel.
The kernel does not use floating-point or vector registers and, therefore,
saving and restoring the FPU register contents are performed for handling
signals or switching processes only. To prepare for using vector
instructions and vector registers within the kernel, enhance the save
behavior and implement a lazy restore at return to user space from a
system call or interrupt.
To implement the lazy restore, the save_fpu_regs() sets a CPU information
flag, CIF_FPU, to indicate that the FPU registers must be restored.
Saving and setting CIF_FPU is performed in an atomic fashion to be
interrupt-safe. When the kernel wants to use the vector extension or
wants to change the FPU register state for a task during signal handling,
the save_fpu_regs() must be called first. The CIF_FPU flag is also set at
process switch. At return to user space, the FPU state is restored. In
particular, the FPU state includes the floating-point or vector register
contents, as well as, vector-enablement and floating-point control. The
FPU state restore and clearing CIF_FPU is also performed in an atomic
fashion.
For KVM, the restore of the FPU register state is performed when restoring
the general-purpose guest registers before the SIE instructions is started.
Because the path towards the SIE instruction is interruptible, the CIF_FPU
flag must be checked again right before going into SIE. If set, the guest
registers must be reloaded again by re-entering the outer SIE loop. This
is the same behavior as if the SIE critical section is interrupted.
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2015-06-10 18:53:42 +08:00
|
|
|
*/
|
2015-06-29 22:43:06 +08:00
|
|
|
save_fpu_regs();
|
2015-09-29 16:04:41 +08:00
|
|
|
|
2016-04-01 21:42:15 +08:00
|
|
|
memcpy(dst, src, arch_task_struct_size);
|
|
|
|
dst->thread.fpu.regs = dst->thread.fpu.fprs;
|
2015-06-11 22:57:20 +08:00
|
|
|
return 0;
|
2015-02-09 23:47:00 +08:00
|
|
|
}
|
|
|
|
|
2017-02-20 16:38:42 +08:00
|
|
|
int copy_thread_tls(unsigned long clone_flags, unsigned long new_stackp,
|
|
|
|
unsigned long arg, struct task_struct *p, unsigned long tls)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-03-26 22:23:52 +08:00
|
|
|
struct fake_frame
|
|
|
|
{
|
|
|
|
struct stack_frame sf;
|
|
|
|
struct pt_regs childregs;
|
|
|
|
} *frame;
|
|
|
|
|
|
|
|
frame = container_of(task_pt_regs(p), struct fake_frame, childregs);
|
|
|
|
p->thread.ksp = (unsigned long) frame;
|
2012-09-22 08:48:32 +08:00
|
|
|
/* Save access registers to new thread structure. */
|
|
|
|
save_access_regs(&p->thread.acrs[0]);
|
|
|
|
/* start new process with ar4 pointing to the correct address space */
|
|
|
|
p->thread.mm_segment = get_fs();
|
|
|
|
/* Don't copy debug registers */
|
|
|
|
memset(&p->thread.per_user, 0, sizeof(p->thread.per_user));
|
|
|
|
memset(&p->thread.per_event, 0, sizeof(p->thread.per_event));
|
|
|
|
clear_tsk_thread_flag(p, TIF_SINGLE_STEP);
|
|
|
|
/* Initialize per thread user and system timer values */
|
2016-11-08 19:15:59 +08:00
|
|
|
p->thread.user_timer = 0;
|
2017-03-01 16:18:34 +08:00
|
|
|
p->thread.guest_timer = 0;
|
2016-11-08 19:15:59 +08:00
|
|
|
p->thread.system_timer = 0;
|
2017-03-01 16:18:34 +08:00
|
|
|
p->thread.hardirq_timer = 0;
|
|
|
|
p->thread.softirq_timer = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-22 08:48:32 +08:00
|
|
|
frame->sf.back_chain = 0;
|
2009-03-26 22:23:52 +08:00
|
|
|
/* new return point is ret_from_fork */
|
|
|
|
frame->sf.gprs[8] = (unsigned long) ret_from_fork;
|
|
|
|
/* fake return stack for resume(), don't go back to schedule */
|
|
|
|
frame->sf.gprs[9] = (unsigned long) frame;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-22 08:48:32 +08:00
|
|
|
/* Store access registers to kernel stack of new process. */
|
2012-10-22 04:44:27 +08:00
|
|
|
if (unlikely(p->flags & PF_KTHREAD)) {
|
2012-09-22 08:48:32 +08:00
|
|
|
/* kernel thread */
|
|
|
|
memset(&frame->childregs, 0, sizeof(struct pt_regs));
|
2013-09-24 15:14:56 +08:00
|
|
|
frame->childregs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT |
|
2012-09-22 08:48:32 +08:00
|
|
|
PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
|
2016-01-18 19:49:44 +08:00
|
|
|
frame->childregs.psw.addr =
|
2012-09-22 08:48:32 +08:00
|
|
|
(unsigned long) kernel_thread_starter;
|
|
|
|
frame->childregs.gprs[9] = new_stackp; /* function */
|
|
|
|
frame->childregs.gprs[10] = arg;
|
|
|
|
frame->childregs.gprs[11] = (unsigned long) do_exit;
|
|
|
|
frame->childregs.orig_gpr2 = -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-22 04:44:27 +08:00
|
|
|
frame->childregs = *current_pt_regs();
|
2012-09-22 08:48:32 +08:00
|
|
|
frame->childregs.gprs[2] = 0; /* child returns 0 on fork. */
|
2014-04-15 18:55:07 +08:00
|
|
|
frame->childregs.flags = 0;
|
2012-10-22 04:44:27 +08:00
|
|
|
if (new_stackp)
|
|
|
|
frame->childregs.gprs[15] = new_stackp;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-07-31 16:52:05 +08:00
|
|
|
/* Don't copy runtime instrumentation info */
|
|
|
|
p->thread.ri_cb = NULL;
|
|
|
|
frame->childregs.psw.mask &= ~PSW_MASK_RI;
|
2016-01-26 21:10:34 +08:00
|
|
|
/* Don't copy guarded storage control block */
|
|
|
|
p->thread.gs_cb = NULL;
|
|
|
|
p->thread.gs_bc_cb = NULL;
|
2012-07-31 16:52:05 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Set a new TLS ? */
|
|
|
|
if (clone_flags & CLONE_SETTLS) {
|
2009-06-12 16:26:25 +08:00
|
|
|
if (is_compat_task()) {
|
2012-10-22 04:44:27 +08:00
|
|
|
p->thread.acrs[0] = (unsigned int)tls;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2012-10-22 04:44:27 +08:00
|
|
|
p->thread.acrs[0] = (unsigned int)(tls >> 32);
|
|
|
|
p->thread.acrs[1] = (unsigned int)tls;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2009-03-26 22:23:52 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:01:40 +08:00
|
|
|
asmlinkage void execve_tail(void)
|
|
|
|
{
|
2015-06-11 21:33:54 +08:00
|
|
|
current->thread.fpu.fpc = 0;
|
2015-07-06 21:02:37 +08:00
|
|
|
asm volatile("sfpc %0" : : "d" (0));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fill in the FPU structure for a core dump.
|
|
|
|
*/
|
|
|
|
int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs)
|
|
|
|
{
|
2015-06-29 22:43:06 +08:00
|
|
|
save_fpu_regs();
|
s390/kernel: lazy restore fpu registers
Improve the save and restore behavior of FPU register contents to use the
vector extension within the kernel.
The kernel does not use floating-point or vector registers and, therefore,
saving and restoring the FPU register contents are performed for handling
signals or switching processes only. To prepare for using vector
instructions and vector registers within the kernel, enhance the save
behavior and implement a lazy restore at return to user space from a
system call or interrupt.
To implement the lazy restore, the save_fpu_regs() sets a CPU information
flag, CIF_FPU, to indicate that the FPU registers must be restored.
Saving and setting CIF_FPU is performed in an atomic fashion to be
interrupt-safe. When the kernel wants to use the vector extension or
wants to change the FPU register state for a task during signal handling,
the save_fpu_regs() must be called first. The CIF_FPU flag is also set at
process switch. At return to user space, the FPU state is restored. In
particular, the FPU state includes the floating-point or vector register
contents, as well as, vector-enablement and floating-point control. The
FPU state restore and clearing CIF_FPU is also performed in an atomic
fashion.
For KVM, the restore of the FPU register state is performed when restoring
the general-purpose guest registers before the SIE instructions is started.
Because the path towards the SIE instruction is interruptible, the CIF_FPU
flag must be checked again right before going into SIE. If set, the guest
registers must be reloaded again by re-entering the outer SIE loop. This
is the same behavior as if the SIE critical section is interrupted.
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2015-06-10 18:53:42 +08:00
|
|
|
fpregs->fpc = current->thread.fpu.fpc;
|
|
|
|
fpregs->pad = 0;
|
2015-09-29 16:04:41 +08:00
|
|
|
if (MACHINE_HAS_VX)
|
s390/kernel: lazy restore fpu registers
Improve the save and restore behavior of FPU register contents to use the
vector extension within the kernel.
The kernel does not use floating-point or vector registers and, therefore,
saving and restoring the FPU register contents are performed for handling
signals or switching processes only. To prepare for using vector
instructions and vector registers within the kernel, enhance the save
behavior and implement a lazy restore at return to user space from a
system call or interrupt.
To implement the lazy restore, the save_fpu_regs() sets a CPU information
flag, CIF_FPU, to indicate that the FPU registers must be restored.
Saving and setting CIF_FPU is performed in an atomic fashion to be
interrupt-safe. When the kernel wants to use the vector extension or
wants to change the FPU register state for a task during signal handling,
the save_fpu_regs() must be called first. The CIF_FPU flag is also set at
process switch. At return to user space, the FPU state is restored. In
particular, the FPU state includes the floating-point or vector register
contents, as well as, vector-enablement and floating-point control. The
FPU state restore and clearing CIF_FPU is also performed in an atomic
fashion.
For KVM, the restore of the FPU register state is performed when restoring
the general-purpose guest registers before the SIE instructions is started.
Because the path towards the SIE instruction is interruptible, the CIF_FPU
flag must be checked again right before going into SIE. If set, the guest
registers must be reloaded again by re-entering the outer SIE loop. This
is the same behavior as if the SIE critical section is interrupted.
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2015-06-10 18:53:42 +08:00
|
|
|
convert_vx_to_fp((freg_t *)&fpregs->fprs,
|
|
|
|
current->thread.fpu.vxrs);
|
|
|
|
else
|
|
|
|
memcpy(&fpregs->fprs, current->thread.fpu.fprs,
|
|
|
|
sizeof(fpregs->fprs));
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2009-03-26 22:24:04 +08:00
|
|
|
EXPORT_SYMBOL(dump_fpu);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
unsigned long get_wchan(struct task_struct *p)
|
|
|
|
{
|
|
|
|
struct stack_frame *sf, *low, *high;
|
|
|
|
unsigned long return_address;
|
|
|
|
int count;
|
|
|
|
|
2006-01-12 17:05:50 +08:00
|
|
|
if (!p || p == current || p->state == TASK_RUNNING || !task_stack_page(p))
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2006-01-12 17:05:50 +08:00
|
|
|
low = task_stack_page(p);
|
|
|
|
high = (struct stack_frame *) task_pt_regs(p);
|
2016-01-18 20:12:19 +08:00
|
|
|
sf = (struct stack_frame *) p->thread.ksp;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (sf <= low || sf > high)
|
|
|
|
return 0;
|
|
|
|
for (count = 0; count < 16; count++) {
|
2016-01-18 20:12:19 +08:00
|
|
|
sf = (struct stack_frame *) sf->back_chain;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (sf <= low || sf > high)
|
|
|
|
return 0;
|
2016-01-18 20:12:19 +08:00
|
|
|
return_address = sf->gprs[8];
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!in_sched_functions(return_address))
|
|
|
|
return return_address;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2011-01-12 16:55:28 +08:00
|
|
|
|
|
|
|
unsigned long arch_align_stack(unsigned long sp)
|
|
|
|
{
|
|
|
|
if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
|
|
|
|
sp -= get_random_int() & ~PAGE_MASK;
|
|
|
|
return sp & ~0xf;
|
|
|
|
}
|
2011-01-12 16:55:30 +08:00
|
|
|
|
|
|
|
static inline unsigned long brk_rnd(void)
|
|
|
|
{
|
2015-11-10 19:30:28 +08:00
|
|
|
return (get_random_int() & BRK_RND_MASK) << PAGE_SHIFT;
|
2011-01-12 16:55:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long arch_randomize_brk(struct mm_struct *mm)
|
|
|
|
{
|
2013-12-17 20:41:31 +08:00
|
|
|
unsigned long ret;
|
2011-01-12 16:55:30 +08:00
|
|
|
|
2013-12-17 20:41:31 +08:00
|
|
|
ret = PAGE_ALIGN(mm->brk + brk_rnd());
|
|
|
|
return (ret > mm->brk) ? ret : mm->brk;
|
2011-01-12 16:55:30 +08:00
|
|
|
}
|
2017-02-17 15:13:28 +08:00
|
|
|
|
|
|
|
void set_fs_fixup(void)
|
|
|
|
{
|
|
|
|
struct pt_regs *regs = current_pt_regs();
|
|
|
|
static bool warned;
|
|
|
|
|
|
|
|
set_fs(USER_DS);
|
|
|
|
if (warned)
|
|
|
|
return;
|
|
|
|
WARN(1, "Unbalanced set_fs - int code: 0x%x\n", regs->int_code);
|
|
|
|
show_registers(regs);
|
|
|
|
warned = true;
|
|
|
|
}
|