Commit graph

323036 commits

Author SHA1 Message Date
Al Viro
8af4efac26 bury _TIF_RESTORE_SIGMASK
never used...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:12 -04:00
Al Viro
87b0e714de unicore32: unobfuscate _TIF_WORK_MASK
bits 3..7 in flags are never set there, so this 0xff is pointless

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:12 -04:00
Al Viro
ac19fe5bf1 mips: NOTIFY_RESUME is not needed in TIF masks
If it's set, SIGPENDING is also set.  And SIGPENDING is present in
the masks...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:11 -04:00
Al Viro
45111b5398 mips: merge the identical "return from syscall" per-ABI code
No need to keep 4 copies of that stuff; merged and taken to
entry.S, unused public symbols there killed off.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:11 -04:00
Al Viro
f925725d91 mips: unobfuscate _TIF..._MASK
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:11 -04:00
Al Viro
bfc83647bb mips: prevent hitting do_notify_resume() with !user_mode(regs)
too late to do anything there...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:10 -04:00
Al Viro
cf880248c5 ia64: can't reach do_signal() when returning to kernel mode
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:10 -04:00
Al Viro
af445f45ed score: fix bogus restarts on sigreturn()
we *really* don't want to have restart logics hit when we are returning from
sigreturn() - random replacement of %r4 with -4 just because a signal had
been noticed from timer interrupt that came when %r4 happened to contain
-514 is not nice at all.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:10 -04:00
Al Viro
6fdb6fbecb mn10300: get rid of calling do_notify_resume() when returning to kernel mode
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:09 -04:00
Al Viro
13d112ed32 xtensa: can't get to do_notify_resume() when user_mode(regs) is not true
asm glue checks that

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 09:58:09 -04:00
Al Viro
5687580bcb c6x: switch to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:59:09 -04:00
Mark Salter
680a14535c c6x: switch to generic sys_execve
Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:59:09 -04:00
Mark Salter
39fcf44099 c6x: switch to generic kernel_execve
Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:59:08 -04:00
Mark Salter
46f15067c0 c6x: add ret_from_kernel_thread(), simplify kernel_thread()
Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:59:08 -04:00
Al Viro
61b7fbc3f4 mn10300: convert to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:54:29 -04:00
Al Viro
6e75421014 mn10300: switch to generic kernel_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:53:59 -04:00
Al Viro
8f1597e959 mn10300: switch to generic sys_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:53:58 -04:00
Al Viro
255461c53a mn10300: split ret_from_fork, simplify kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:53:24 -04:00
Al Viro
49ed3398b7 frv: switch to generic kernel_thread() 2012-10-01 00:53:11 -04:00
Al Viro
019f96a345 frv: switch to generic kernel_execve
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:53:11 -04:00
Al Viro
460dabab73 frv: switch to generic sys_execve()
current_pt_regs() here is simply __frame

Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:53:10 -04:00
Al Viro
02ce496f15 frv: split ret_from_fork, simplify kernel_thread() a lot
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:53:10 -04:00
Al Viro
d878d6dace m68k: switch to generic sys_execve()/kernel_execve()
The tricky part here is that task_pt_regs() on m68k works *only* for
process inside do_signal().  However, we need something much simpler -
pt_regs of a process inside do_signal() may be at different offsets
from the stack bottom, depending on the way we'd entered the kernel,
but for a task inside sys_execve() it *is* at constant offset.
Moreover, for a kernel thread about to become a userland process the
same location is also fine - setting sp to that will leave the kernel
stack pointer at the very bottom of the kernel stack when we finally
switch to userland.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:44:44 -04:00
Al Viro
533e6903be m68k: split ret_from_fork(), simplify kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:44:44 -04:00
Greg Ungerer
0973c687e0 m68k: always set stack frame format for ColdFire on thread start
The stack frame "format" field needs to be explicitly set on thread creation
on ColdFire. For a normal long word aligned user stack pointer the frame
format is 0x4.

We were doing this for non-MMU ColdFire, but not for the case with MMU enabled.
So fix it so we always do it if targeting ColdFire.

The old code happend to rely on the stack frame format being inhereted from
the process calling exec. Furture changes means that may not always work,
so we really do want to set it explicitly.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-01 00:44:43 -04:00
Al Viro
be6abfa769 powerpc: switch to generic sys_execve()/kernel_execve()
the only non-obvious part is that current_pt_regs() is really needed
here - task_pt_regs() is NULL for kernel threads; it's OK for ptrace
uses (the thing task_pt_regs() is intended for), but not for us.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 23:35:51 -04:00
Al Viro
58254e1002 powerpc: split ret_from_fork
... and get rid of in-kernel syscalls in kernel_thread()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 23:31:19 -04:00
Al Viro
f322220d61 s390: convert to generic kernel_execve()
same situation as with alpha and arm - only massage needed

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 23:03:04 -04:00
Al Viro
f9a7e025df s390: switch to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 23:03:03 -04:00
Al Viro
37fe5d41f6 s390: fold kernel_thread_helper() into ret_from_fork()
... and don't bother with syscall return path in case of kernel
threads.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 23:03:03 -04:00
Al Viro
65f22a906e s390: fold execve_tail() into start_thread(), convert to generic sys_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 23:03:02 -04:00
Al Viro
1f02ab4a23 um: switch to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:53:32 -04:00
Al Viro
6783eaa2e1 x86, um/x86: switch to generic sys_execve and kernel_execve
32bit wrapper is lost on that; 64bit one is *not*, since
we need to arrange for full pt_regs on stack when we call
sys_execve() and we need to load callee-saved ones from
there afterwards.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:53:32 -04:00
Al Viro
7076aada10 x86: split ret_from_fork
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:53:31 -04:00
Al Viro
44f4b56b54 alpha: introduce ret_from_kernel_execve(), switch to generic kernel_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:53:31 -04:00
Al Viro
cba1ec7e88 alpha: switch to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:53:18 -04:00
Al Viro
756144f8ea alpha: switch to generic sys_execve()
get rid of sys_execve() wrapper, while we are at it

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:21:37 -04:00
Al Viro
a63c97a000 arm: get rid of execve wrapper, switch to generic execve() implementation
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:21:37 -04:00
Al Viro
bfd170d565 arm: optimized current_pt_regs()
... no need to read current_thread_info()->task only to
feed it to task_thread_page() immediately afterwards.
Moreover, not using current_thread_info() at all ends
up with better assembler - we need a location very close
to the top of kernel stack page and it's actually better
to do or with 0x1fff, followed be subtracting a small
constant than and with ~0x1fff, followed by adding a large
one.  Both & and | would be a couple of insns (mvn lsr/mvn lsl
for |, a pair of bic for &), but the following addition
would cost a pair of add while the subtraction ends up
as a single sub.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:21:37 -04:00
Al Viro
583d632fb3 arm: introduce ret_from_kernel_execve(), switch to generic kernel_execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:21:36 -04:00
Al Viro
9e14f828ee arm: split ret_from_fork, simplify kernel_thread() [based on patch by rmk]
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:21:36 -04:00
Al Viro
38b983b346 generic sys_execve()
Selected by __ARCH_WANT_SYS_EXECVE in unistd.h.  Requires
	* working current_pt_regs()
	* *NOT* doing a syscall-in-kernel kind of kernel_execve()
implementation.  Using generic kernel_execve() is fine.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 22:20:51 -04:00
Al Viro
282124d186 generic kernel_execve()
based mostly on arm and alpha versions.  Architectures can define
__ARCH_WANT_KERNEL_EXECVE and use it, provided that
	* they have working current_pt_regs(), even for kernel threads.
	* kernel_thread-spawned threads do have space for pt_regs
in the normal location.  Normally that's as simple as switching to
generic kernel_thread() and making sure that kernel threads do *not*
go through return from syscall path; call the payload from equivalent
of ret_from_fork if we are in a kernel thread (or just have separate
ret_from_kernel_thread and make copy_thread() use it instead of
ret_from_fork in kernel thread case).
	* they have ret_from_kernel_execve(); it is called after
successful do_execve() done by kernel_execve() and gets normal
pt_regs location passed to it as argument.  It's essentially
a longjmp() analog - it should set sp, etc. to the situation
expected at the return for syscall and go there.  Eventually
the need for that sucker will disappear, but that'll take some
surgery on kernel_thread() payloads.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 13:36:39 -04:00
Al Viro
a3460a5974 new helper: current_pt_regs()
Normally (and that's the default) it's just task_pt_regs(current).
However, if an architecture can optimize that, it can do so by
making a macro of its own available from asm/ptrace.h.  More
importantly, some architectures have task_pt_regs() working only
for traced tasks blocked on signal delivery.  current_pt_regs()
needs to work for *all* processes, so before those architectures
start using stuff relying on current_pt_regs() they'll need a
properly working variant.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 13:36:39 -04:00
Al Viro
2aa3a7f866 preparation for generic kernel_thread()
Let architectures select GENERIC_KERNEL_THREAD and have their copy_thread()
treat NULL regs as "it came from kernel_thread(), sp argument contains
the function new thread will be calling and stack_size - the argument for
that function".  Switching the architectures begins shortly...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-30 13:35:55 -04:00
Al Viro
a4d94ff8aa um: kill thread->forking
we only use that to tell copy_thread() done by syscall from that
done by kernel_thread().  However, it's easier to do simply by
checking PF_KTHREAD in thread flags.

Merge sys_clone() guts for 32bit and 64bit, while we are at it...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-20 10:49:09 -04:00
Al Viro
8e2c85aa6c um: let signal_delivered() do SIGTRAP on singlestepping into handler
... rather than duplicating that in sigframe setup code (and doing that
inconsistently, at that)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-20 09:53:01 -04:00
Al Viro
344569aef3 um: don't leak floating point state and segment registers on execve()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-20 09:53:01 -04:00
Al Viro
ab286b21aa um: take cleaning singlestep to start_thread()
... assuming it's needed to be done at all

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-20 09:53:00 -04:00
Al Viro
1cedd6925a don't bother exporting kernel_execve()
most of the architectures don't and there's not a single
caller outside of core kernel.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-09-20 09:51:28 -04:00