2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2009-03-26 14:23:52 +00:00
|
|
|
* This file handles the architecture dependent parts of process handling.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2012-07-20 09:15:04 +00:00
|
|
|
* Copyright IBM Corp. 1999, 2009
|
2009-03-26 14:23:52 +00:00
|
|
|
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
|
|
|
|
* Hartmut Penner <hp@de.ibm.com>,
|
|
|
|
* Denis Joseph Barrow,
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-07 10:15:34 +00:00
|
|
|
#include <linux/elf-randomize.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
2011-10-30 14:17:13 +00:00
|
|
|
#include <linux/elfcore.h>
|
2005-04-16 22:20:36 +00: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 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/interrupt.h>
|
2008-04-17 05:46:25 +00:00
|
|
|
#include <linux/tick.h>
|
2011-01-12 08:55:28 +00:00
|
|
|
#include <linux/personality.h>
|
2009-01-14 13:14:36 +00:00
|
|
|
#include <linux/syscalls.h>
|
2009-09-22 20:58:42 +00:00
|
|
|
#include <linux/compat.h>
|
2011-01-05 11:47:25 +00:00
|
|
|
#include <linux/kprobes.h>
|
2011-01-12 08:55:28 +00:00
|
|
|
#include <linux/random.h>
|
2017-02-09 20:20:23 +00:00
|
|
|
#include <linux/export.h>
|
2015-09-29 15:53:22 +00:00
|
|
|
#include <linux/init_task.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/processor.h>
|
2012-07-20 09:15:08 +00:00
|
|
|
#include <asm/vtimer.h>
|
2012-09-14 11:45:24 +00:00
|
|
|
#include <asm/exec.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/irq.h>
|
2009-03-26 14:24:01 +00:00
|
|
|
#include <asm/nmi.h>
|
2011-01-05 11:48:09 +00:00
|
|
|
#include <asm/smp.h>
|
2012-03-28 17:30:02 +00:00
|
|
|
#include <asm/switch_to.h>
|
2012-07-31 08:52:05 +00:00
|
|
|
#include <asm/runtime_instr.h>
|
2008-04-17 05:46:26 +00:00
|
|
|
#include "entry.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-28 14:56:43 +00:00
|
|
|
asmlinkage void ret_from_fork(void) asm ("ret_from_fork");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return saved PC of a blocked thread. used in kernel/sched.
|
|
|
|
* resume in entry.S does not create a new stack frame, it
|
|
|
|
* just stores the registers %r6-%r15 to the frame given by
|
|
|
|
* schedule. We want to return the address of the caller of
|
|
|
|
* schedule, so we have to walk the backchain one time to
|
|
|
|
* find the frame schedule() store its return address.
|
|
|
|
*/
|
|
|
|
unsigned long thread_saved_pc(struct task_struct *tsk)
|
|
|
|
{
|
2006-01-14 21:20:57 +00:00
|
|
|
struct stack_frame *sf, *low, *high;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-14 21:20:57 +00:00
|
|
|
if (!tsk || !task_stack_page(tsk))
|
|
|
|
return 0;
|
|
|
|
low = task_stack_page(tsk);
|
|
|
|
high = (struct stack_frame *) task_pt_regs(tsk);
|
2016-01-18 12:12:19 +00:00
|
|
|
sf = (struct stack_frame *) tsk->thread.ksp;
|
2006-01-14 21:20:57 +00:00
|
|
|
if (sf <= low || sf > high)
|
|
|
|
return 0;
|
2016-01-18 12:12:19 +00:00
|
|
|
sf = (struct stack_frame *) sf->back_chain;
|
2006-01-14 21:20:57 +00:00
|
|
|
if (sf <= low || sf > high)
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
return sf->gprs[8];
|
|
|
|
}
|
|
|
|
|
2014-10-22 10:42:38 +00:00
|
|
|
extern void kernel_thread_starter(void);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Free current thread data structures etc..
|
|
|
|
*/
|
2016-05-21 00:00:20 +00:00
|
|
|
void exit_thread(struct task_struct *tsk)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2016-05-21 00:00:20 +00:00
|
|
|
if (tsk == current)
|
|
|
|
exit_thread_runtime_instr();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_thread(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_thread(struct task_struct *dead_task)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-09 15:47:00 +00:00
|
|
|
void arch_release_task_struct(struct task_struct *tsk)
|
|
|
|
{
|
2015-06-11 14:57:20 +00: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 10:53:42 +00:00
|
|
|
/*
|
|
|
|
* Save the floating-point or vector register state of the current
|
2015-09-29 08:04:41 +00: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 10:53:42 +00:00
|
|
|
*/
|
2015-06-29 14:43:06 +00:00
|
|
|
save_fpu_regs();
|
2015-09-29 08:04:41 +00:00
|
|
|
|
2016-04-01 13:42:15 +00:00
|
|
|
memcpy(dst, src, arch_task_struct_size);
|
|
|
|
dst->thread.fpu.regs = dst->thread.fpu.fprs;
|
2015-06-11 14:57:20 +00:00
|
|
|
return 0;
|
2015-02-09 15:47:00 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 08:38:42 +00: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-16 22:20:36 +00:00
|
|
|
{
|
2009-03-26 14:23:52 +00: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 00:48:32 +00: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 11:15:59 +00:00
|
|
|
p->thread.user_timer = 0;
|
|
|
|
p->thread.system_timer = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-09-22 00:48:32 +00:00
|
|
|
frame->sf.back_chain = 0;
|
2009-03-26 14:23:52 +00: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-16 22:20:36 +00:00
|
|
|
|
2012-09-22 00:48:32 +00:00
|
|
|
/* Store access registers to kernel stack of new process. */
|
2012-10-21 20:44:27 +00:00
|
|
|
if (unlikely(p->flags & PF_KTHREAD)) {
|
2012-09-22 00:48:32 +00:00
|
|
|
/* kernel thread */
|
|
|
|
memset(&frame->childregs, 0, sizeof(struct pt_regs));
|
2013-09-24 07:14:56 +00:00
|
|
|
frame->childregs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT |
|
2012-09-22 00:48:32 +00:00
|
|
|
PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
|
2016-01-18 11:49:44 +00:00
|
|
|
frame->childregs.psw.addr =
|
2012-09-22 00:48:32 +00: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-21 20:44:27 +00:00
|
|
|
frame->childregs = *current_pt_regs();
|
2012-09-22 00:48:32 +00:00
|
|
|
frame->childregs.gprs[2] = 0; /* child returns 0 on fork. */
|
2014-04-15 10:55:07 +00:00
|
|
|
frame->childregs.flags = 0;
|
2012-10-21 20:44:27 +00:00
|
|
|
if (new_stackp)
|
|
|
|
frame->childregs.gprs[15] = new_stackp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-07-31 08:52:05 +00:00
|
|
|
/* Don't copy runtime instrumentation info */
|
|
|
|
p->thread.ri_cb = NULL;
|
|
|
|
frame->childregs.psw.mask &= ~PSW_MASK_RI;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Set a new TLS ? */
|
|
|
|
if (clone_flags & CLONE_SETTLS) {
|
2009-06-12 08:26:25 +00:00
|
|
|
if (is_compat_task()) {
|
2012-10-21 20:44:27 +00:00
|
|
|
p->thread.acrs[0] = (unsigned int)tls;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2012-10-21 20:44:27 +00:00
|
|
|
p->thread.acrs[0] = (unsigned int)(tls >> 32);
|
|
|
|
p->thread.acrs[1] = (unsigned int)tls;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-26 14:23:52 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 14:01:40 +00:00
|
|
|
asmlinkage void execve_tail(void)
|
|
|
|
{
|
2015-06-11 13:33:54 +00:00
|
|
|
current->thread.fpu.fpc = 0;
|
2015-07-06 13:02:37 +00:00
|
|
|
asm volatile("sfpc %0" : : "d" (0));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fill in the FPU structure for a core dump.
|
|
|
|
*/
|
|
|
|
int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs)
|
|
|
|
{
|
2015-06-29 14:43:06 +00: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 10:53:42 +00:00
|
|
|
fpregs->fpc = current->thread.fpu.fpc;
|
|
|
|
fpregs->pad = 0;
|
2015-09-29 08:04:41 +00: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 10:53:42 +00: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-16 22:20:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2009-03-26 14:24:04 +00:00
|
|
|
EXPORT_SYMBOL(dump_fpu);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
unsigned long get_wchan(struct task_struct *p)
|
|
|
|
{
|
|
|
|
struct stack_frame *sf, *low, *high;
|
|
|
|
unsigned long return_address;
|
|
|
|
int count;
|
|
|
|
|
2006-01-12 09:05:50 +00:00
|
|
|
if (!p || p == current || p->state == TASK_RUNNING || !task_stack_page(p))
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2006-01-12 09:05:50 +00:00
|
|
|
low = task_stack_page(p);
|
|
|
|
high = (struct stack_frame *) task_pt_regs(p);
|
2016-01-18 12:12:19 +00:00
|
|
|
sf = (struct stack_frame *) p->thread.ksp;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (sf <= low || sf > high)
|
|
|
|
return 0;
|
|
|
|
for (count = 0; count < 16; count++) {
|
2016-01-18 12:12:19 +00:00
|
|
|
sf = (struct stack_frame *) sf->back_chain;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (sf <= low || sf > high)
|
|
|
|
return 0;
|
2016-01-18 12:12:19 +00:00
|
|
|
return_address = sf->gprs[8];
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!in_sched_functions(return_address))
|
|
|
|
return return_address;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2011-01-12 08:55:28 +00: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 08:55:30 +00:00
|
|
|
|
|
|
|
static inline unsigned long brk_rnd(void)
|
|
|
|
{
|
2015-11-10 11:30:28 +00:00
|
|
|
return (get_random_int() & BRK_RND_MASK) << PAGE_SHIFT;
|
2011-01-12 08:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long arch_randomize_brk(struct mm_struct *mm)
|
|
|
|
{
|
2013-12-17 12:41:31 +00:00
|
|
|
unsigned long ret;
|
2011-01-12 08:55:30 +00:00
|
|
|
|
2013-12-17 12:41:31 +00:00
|
|
|
ret = PAGE_ALIGN(mm->brk + brk_rnd());
|
|
|
|
return (ret > mm->brk) ? ret : mm->brk;
|
2011-01-12 08:55:30 +00:00
|
|
|
}
|
2017-02-17 07:13:28 +00: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;
|
|
|
|
}
|