Subject: COMPAT_LINUX: moving forward with NPTL machdep code
To: None <tech-kern@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: tech-kern
Date: 06/26/2006 10:06:33
Hello

It would be nice if we could move forward with NPTL emulation. So far only
amd64 implements the machdep code required. I would like to upgrade others 
architectures so that the #ifdef LINUX_NPTL could disapear.

The machdep code is limited to a pair of functions:
unsigned long linux_get_newtls __P((struct lwp *));
int linux_set_newtls __P((struct lwp *, unsigned long)); 

The corresponding code can be found in Linux kernel sources. 
Look for CLONE_SETTLS in linux/arch/<arch>/kernel/process.c:copy_thread()

Example for amd64, we find
if (clone_flags & CLONE_SETTLS)
	err = do_arch_prctl(p, ARCH_SET_FS, childregs->r8);

And you can find in NetBSD's src/sys/compat/linux/arch/amd64/linux_machdep.c
for the corresponding implementation of linux_{set|get}_newtls.


For other architectures:
- For powerpc, we just have to get and set process' register GPR6.
- For ARM, we just have to get and set process' register R3
- For MIPS, we just have to get and set process' register 7
- For alpha, it seems we just have to get and set process' register R20.

I can write a patch for those, but I cannot test it works. I need 
volunteers that have access to the hardware and can tell me that no
regression occurs.

More difficult:
- For i386, there is some black magic with LDT. I need help form a x86 hacker.
- For m68k, no match for SETTLS. Is NPTL implemented at all on m68k Linux?
Anyone knows?

-- 
Emmanuel Dreyfus
manu@netbsd.org