Subject: Re: Linux clone() emulation arguments
To: Emmanuel Dreyfus <>
From: Jason R Thorpe <>
List: tech-kern
Date: 06/03/2001 07:33:41
On Sun, Jun 03, 2001 at 11:30:42AM +0200, Emmanuel Dreyfus wrote:

 > I don't understand how our Linux emulation of clone() works.
 > In the Linux kernel, it is implemented as:
 > i386: 
 > int sys_clone(struct pt_regs regs) 
 > PowerPC:
 > int sys_clone(int p1, int p2, int p3, int p4, int p5, int p6, struct
 > pt_regs *regs) 
 > m68k:
 > int m68k_clone(struct pt_regs *regs)
 > called by an assembly language glue (sys_clone)
 > alpha:
 > int alpha_clone(unsigned long clone_flags, unsigned long usp, struct
 > switch_stack * swstack)
 > called by an assembly language glue (sys_clone)

These are all machdep versions called by machdep syscall entry code.  The
API for all of these is the same from the userland perspective.

 > In the NetBSD emulation subsystem, we have this for all Linux ports
 > int linux_sys_clone(int flags, void *stack)
 > Question: how does this work? How do we get the correct arguments?
 > I'm currently hunting bugs in kernel thread emulations, with bad stacks
 > pointers that cause segmentation faults, and I suspect this may be my
 > problem. For instance I'm not sure the new stack address or the thread
 > entry point are correctly passed to linux_sys_clone() on the PowerPC.

Hm .. some printfs in cpu_fork() should be able to tell you pretty

        -- Jason R. Thorpe <>