Subject: Linux clone() emulation arguments
To: None <tech-kern@netbsd.org>
From: Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
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:
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)

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
p99dreyf@criens.u-psud.fr