mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
sparc: share process creation helpers between sparc and sparc64
As promised in the previous patch, this moves the process creation helpers into a common process.c file that is shared between sparc and sparc64. It allows us to get rid of quite a bit custom assembler and the to remove the separe 32bit specific sparc_do_fork() call. One thing to note, is that when clone() was called with a separate stack for the child the assembler would align it. But copy_thread() has always been doing that too so that line wasn't needed and can thus simply be removed. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Acked-by: David S. Miller <davem@davemloft.net> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "David S. Miller" <davem@davemloft.net> Cc: Guo Ren <guoren@kernel.org> Cc: linux-csky@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: sparclinux@vger.kernel.org Link: https://lore.kernel.org/r/20200512171527.570109-3-christian.brauner@ubuntu.com
This commit is contained in:
@@ -572,100 +572,6 @@ barf:
|
||||
force_sig(SIGSEGV);
|
||||
}
|
||||
|
||||
asmlinkage long sparc_fork(struct pt_regs *regs)
|
||||
{
|
||||
unsigned long orig_i1 = regs->u_regs[UREG_I1];
|
||||
long ret;
|
||||
struct kernel_clone_args args = {
|
||||
.exit_signal = SIGCHLD,
|
||||
/* Reuse the parent's stack for the child. */
|
||||
.stack = regs->u_regs[UREG_FP],
|
||||
};
|
||||
|
||||
ret = _do_fork(&args);
|
||||
|
||||
/* If we get an error and potentially restart the system
|
||||
* call, we're screwed because copy_thread_tls() clobbered
|
||||
* the parent's %o1. So detect that case and restore it
|
||||
* here.
|
||||
*/
|
||||
if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
|
||||
regs->u_regs[UREG_I1] = orig_i1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
asmlinkage long sparc_vfork(struct pt_regs *regs)
|
||||
{
|
||||
unsigned long orig_i1 = regs->u_regs[UREG_I1];
|
||||
long ret;
|
||||
|
||||
struct kernel_clone_args args = {
|
||||
.flags = CLONE_VFORK | CLONE_VM,
|
||||
.exit_signal = SIGCHLD,
|
||||
/* Reuse the parent's stack for the child. */
|
||||
.stack = regs->u_regs[UREG_FP],
|
||||
};
|
||||
|
||||
ret = _do_fork(&args);
|
||||
|
||||
/* If we get an error and potentially restart the system
|
||||
* call, we're screwed because copy_thread_tls() clobbered
|
||||
* the parent's %o1. So detect that case and restore it
|
||||
* here.
|
||||
*/
|
||||
if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
|
||||
regs->u_regs[UREG_I1] = orig_i1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
asmlinkage long sparc_clone(struct pt_regs *regs)
|
||||
{
|
||||
unsigned long orig_i1 = regs->u_regs[UREG_I1];
|
||||
unsigned int flags = lower_32_bits(regs->u_regs[UREG_I0]);
|
||||
long ret;
|
||||
|
||||
struct kernel_clone_args args = {
|
||||
.flags = (flags & ~CSIGNAL),
|
||||
.exit_signal = (flags & CSIGNAL),
|
||||
.tls = regs->u_regs[UREG_I3],
|
||||
};
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
if (test_thread_flag(TIF_32BIT)) {
|
||||
args.pidfd = compat_ptr(regs->u_regs[UREG_I2]);
|
||||
args.child_tid = compat_ptr(regs->u_regs[UREG_I4]);
|
||||
args.parent_tid = compat_ptr(regs->u_regs[UREG_I2]);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
args.pidfd = (int __user *)regs->u_regs[UREG_I2];
|
||||
args.child_tid = (int __user *)regs->u_regs[UREG_I4];
|
||||
args.parent_tid = (int __user *)regs->u_regs[UREG_I2];
|
||||
}
|
||||
|
||||
/* Did userspace setup a separate stack for the child or are we
|
||||
* copying the parent's?
|
||||
*/
|
||||
if (regs->u_regs[UREG_I1])
|
||||
args.stack = regs->u_regs[UREG_I1];
|
||||
else
|
||||
args.stack = regs->u_regs[UREG_FP];
|
||||
|
||||
ret = _do_fork(&args);
|
||||
|
||||
/* If we get an error and potentially restart the system
|
||||
* call, we're screwed because copy_thread_tls() clobbered
|
||||
* the parent's %o1. So detect that case and restore it
|
||||
* here.
|
||||
*/
|
||||
if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
|
||||
regs->u_regs[UREG_I1] = orig_i1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Copy a Sparc thread. The fork() return value conventions
|
||||
* under SunOS are nothing short of bletcherous:
|
||||
* Parent --> %o0 == childs pid, %o1 == 0
|
||||
|
||||
Reference in New Issue
Block a user