[Devel] Re: [RFC][v7][PATCH 8/9]: Define clone2() syscall
Arnd Bergmann
arnd at arndb.de
Thu Sep 24 14:43:59 PDT 2009
On Thursday 24 September 2009, Sukadev Bhattiprolu wrote:
> +asmlinkage long
> +sys_clone2(struct clone_struct __user *ucs, pid_t __user *pids)
> +{
> + int rc;
> + struct clone_struct kcs;
> + unsigned long clone_flags;
> + int __user *parent_tid_ptr;
> + int __user *child_tid_ptr;
> + unsigned long __user child_stack_base;
> + struct pt_regs *regs;
> +
> + rc = copy_from_user(&ucs, &kcs, sizeof(kcs));
> + if (rc)
> + return -EFAULT;
> +
> + /*
> + * TODO: Convert clone_flags to 64-bit
> + */
> + clone_flags = (unsigned long)kcs.flags;
> + child_stack_base = (unsigned long)kcs.child_stack;
> + parent_tid_ptr = &ucs.parent_tid;
> + child_tid_ptr = &ucs.child_tid;
> + regs = task_pt_regs(current);
> +
> + if (!child_stack_base)
> + child_stack_base = user_stack_pointer(regs);
> +
> + return do_fork_with_pids(clone_flags, child_stack_base, regs, 0,
> + parent_tid_ptr, child_tid_ptr, kcs.nr_pids, pids);
> +}
> +
The function looks ok, but you have put it into arch/x86/kernel/process_32.c,
which is specific to x86-32. Since the code in this form is generic, why
not just put it into kernel/fork.c? You should probably enclose it within
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK to make sure that user_stack_pointer()
is implemented, but then it would be immediately usable by the nine architectures
implementing that. The other architectures can then decide between adding
their private version of sys_clone2 with an open-coded user_stack_pointer
implementation or alternatively implement the tracehooks.
Arnd <><
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list