Subject: Linux clone() emulation arguments
To: None <>
From: Emmanuel Dreyfus <>
List: tech-kern
Date: 06/03/2001 11:30:42
I don't understand how our Linux emulation of clone() works.

In the Linux kernel, it is implemented as:
int sys_clone(struct pt_regs regs) 

int sys_clone(int p1, int p2, int p3, int p4, int p5, int p6, struct
pt_regs *regs) 

int m68k_clone(struct pt_regs *regs)
called by an assembly language glue (sys_clone)

int alpha_clone(unsigned long clone_flags, unsigned long usp, struct
switch_stack * swstack)
called by an assembly language glue (sys_clone)

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.

Emmanuel Dreyfus