Subject: LKMs support for compat_linux(8)
To: NetBSD amd64 <port-amd64@netbsd.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: port-amd64
Date: 10/04/2007 14:24:58
--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


Hi,

I just finished to add support for compat_linux(8) using the lkm(4)
framework.

njoly@lanfeust [~]> uname -a
NetBSD lanfeust.sis.pasteur.fr 4.99.31 NetBSD 4.99.31 (GENERIC) #10: Thu Oct  4 13:45:21 CEST 2007  njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/GENERIC amd64

njoly@lanfeust [~]> /emul/linux/bin/uname -a
zsh: exec format error: /emul/linux/bin/uname
njoly@lanfeust [~]> sudo modload /usr/lkm/compat_linux.o
Module loaded as ID 0
njoly@lanfeust [~]> sudo modload /usr/lkm/exec_linux_elf.o
Module loaded as ID 1
njoly@lanfeust [~]> /emul/linux/bin/uname -a
Linux lanfeust.sis.pasteur.fr 2.4.18 #0 Wed Feb 20 20:00:02 CET 2002 x86_64 x86_64 x86_64 GNU/Linux
njoly@lanfeust [~]> modstat
Type    Id   Offset Loadaddr         Size Info             Rev Module Name
COMPAT    0       - ffffffff80ba2000 0050 ffffffff80bb3260   2 compat_linux
EXEC      1       - ffffffff80bb6000 0004 ffffffff80bb6b40   2 exec_linux_elf

The attached patch does mostly the following :

- Add needed COMPAT_OSSAUDIO to GENERIC kernel config.

- Add missing includes to mostly all compat linux files, needed by
  `linux_syscallargs.h'.

- Allow compat_linux and exec_linux_elf builds.

Does this looks ok ? I plan to do mostly the same for compat_linux32.

Thanks.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="netbsd-amd64linuxlkm.diff"

Index: distrib/sets/lists/base/md.amd64
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/base/md.amd64,v
retrieving revision 1.13
diff -u -p -r1.13 md.amd64
--- distrib/sets/lists/base/md.amd64	14 Jan 2007 04:45:18 -0000	1.13
+++ distrib/sets/lists/base/md.amd64	4 Oct 2007 11:48:59 -0000
@@ -5,6 +5,8 @@
 ./usr/lib/libx86_64.so				base-sys-shlib
 ./usr/lib/libx86_64.so.0			base-sys-shlib
 ./usr/lib/libx86_64.so.0.0			base-sys-shlib
+./usr/lkm/compat_linux.o			base-sys-lkm
+./usr/lkm/exec_linux_elf.o			base-sys-lkm
 ./usr/mdec/biosboot				base-obsolete		obsolete
 ./usr/mdec/biosboot.sym				base-obsolete		obsolete
 ./usr/mdec/biosboot_com0.sym			base-obsolete		obsolete
Index: sys/arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.165
diff -u -p -r1.165 GENERIC
--- sys/arch/amd64/conf/GENERIC	4 Oct 2007 00:00:01 -0000	1.165
+++ sys/arch/amd64/conf/GENERIC	4 Oct 2007 11:49:37 -0000
@@ -110,6 +110,7 @@ options 	COMPAT_40	# NetBSD 4.0 compatib
 options 	COMPAT_43	# and 4.3BSD
 #options 	COMPAT_386BSD_MBRPART # recognize old partition ID
 
+options 	COMPAT_OSSAUDIO
 options 	COMPAT_NETBSD32
 #options 	COMPAT_LINUX
 #options 	COMPAT_LINUX32	# req. COMPAT_LINUX and COMPAT_NETBSD32
Index: sys/compat/linux/arch/amd64/linux_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/amd64/linux_machdep.c,v
retrieving revision 1.24
diff -u -p -r1.24 linux_machdep.c
--- sys/compat/linux/arch/amd64/linux_machdep.c	3 Oct 2007 10:54:16 -0000	1.24
+++ sys/compat/linux/arch/amd64/linux_machdep.c	4 Oct 2007 11:49:48 -0000
@@ -72,6 +72,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_machde
 #include <compat/linux/common/linux_ioctl.h>
 #include <compat/linux/common/linux_prctl.h>
 #include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 #include <compat/linux/linux_syscall.h>
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_blkio.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_blkio.c,v
retrieving revision 1.14
diff -u -p -r1.14 linux_blkio.c
--- sys/compat/linux/common/linux_blkio.c	4 Mar 2007 06:01:22 -0000	1.14
+++ sys/compat/linux/common/linux_blkio.c	4 Oct 2007 11:49:48 -0000
@@ -54,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_blkio.
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_blkio.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_cdrom.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_cdrom.c,v
retrieving revision 1.23
diff -u -p -r1.23 linux_cdrom.c
--- sys/compat/linux/common/linux_cdrom.c	30 Jun 2007 22:18:17 -0000	1.23
+++ sys/compat/linux/common/linux_cdrom.c	4 Oct 2007 11:49:48 -0000
@@ -53,6 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_cdrom.
 #include <compat/linux/common/linux_ioctl.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 #include <compat/linux/common/linux_cdrom.h>
 
 #include <compat/linux/linux_syscallargs.h>
Index: sys/compat/linux/common/linux_exec.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_exec.c,v
retrieving revision 1.95
diff -u -p -r1.95 linux_exec.c
--- sys/compat/linux/common/linux_exec.c	22 Apr 2007 08:29:57 -0000	1.95
+++ sys/compat/linux/common/linux_exec.c	4 Oct 2007 11:49:48 -0000
@@ -68,6 +68,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_exec.c
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_exec.h>
 #include <compat/linux/common/linux_futex.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 #include <compat/linux/linux_syscall.h>
Index: sys/compat/linux/common/linux_fdio.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_fdio.c,v
retrieving revision 1.10
diff -u -p -r1.10 linux_fdio.c
--- sys/compat/linux/common/linux_fdio.c	4 Mar 2007 06:01:23 -0000	1.10
+++ sys/compat/linux/common/linux_fdio.c	4 Oct 2007 11:49:48 -0000
@@ -58,6 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_fdio.c
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_fdio.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_file.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_file.c,v
retrieving revision 1.83
diff -u -p -r1.83 linux_file.c
--- sys/compat/linux/common/linux_file.c	12 May 2007 23:02:49 -0000	1.83
+++ sys/compat/linux/common/linux_file.c	4 Oct 2007 11:49:48 -0000
@@ -70,6 +70,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_file.c
 #include <compat/linux/common/linux_fcntl.h>
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_file64.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_file64.c,v
retrieving revision 1.39
diff -u -p -r1.39 linux_file64.c
--- sys/compat/linux/common/linux_file64.c	12 May 2007 23:02:49 -0000	1.39
+++ sys/compat/linux/common/linux_file64.c	4 Oct 2007 11:49:49 -0000
@@ -69,6 +69,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_file64
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_dirent.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_futex.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_futex.c,v
retrieving revision 1.7
diff -u -p -r1.7 linux_futex.c
--- sys/compat/linux/common/linux_futex.c	24 Jul 2006 19:01:49 -0000	1.7
+++ sys/compat/linux/common/linux_futex.c	4 Oct 2007 11:49:49 -0000
@@ -34,7 +34,7 @@
 #include <sys/cdefs.h>
 __KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.7 2006/07/24 19:01:49 manu Exp $");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/time.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
@@ -42,8 +42,13 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.
 #include <sys/queue.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
+#include <sys/kernel.h>
 
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_futex.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 #include <compat/linux/linux_syscallargs.h>
 
 struct futex;
Index: sys/compat/linux/common/linux_hdio.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_hdio.c,v
retrieving revision 1.13
diff -u -p -r1.13 linux_hdio.c
--- sys/compat/linux/common/linux_hdio.c	1 Jul 2007 09:54:16 -0000	1.13
+++ sys/compat/linux/common/linux_hdio.c	4 Oct 2007 11:49:49 -0000
@@ -58,6 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_hdio.c
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_hdio.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_ioctl.c,v
retrieving revision 1.48
diff -u -p -r1.48 linux_ioctl.c
--- sys/compat/linux/common/linux_ioctl.c	16 Jun 2007 19:54:02 -0000	1.48
+++ sys/compat/linux/common/linux_ioctl.c	4 Oct 2007 11:49:49 -0000
@@ -62,6 +62,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_ioctl.
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_ioctl.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_misc.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_misc.c,v
retrieving revision 1.183
diff -u -p -r1.183 linux_misc.c
--- sys/compat/linux/common/linux_misc.c	17 Jul 2007 17:42:08 -0000	1.183
+++ sys/compat/linux/common/linux_misc.c	4 Oct 2007 11:49:49 -0000
@@ -113,6 +113,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_misc.c
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_misc_notalpha.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_misc_notalpha.c,v
retrieving revision 1.94
diff -u -p -r1.94 linux_misc_notalpha.c
--- sys/compat/linux/common/linux_misc_notalpha.c	9 Jul 2007 21:10:46 -0000	1.94
+++ sys/compat/linux/common/linux_misc_notalpha.c	4 Oct 2007 11:49:49 -0000
@@ -66,6 +66,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_misc_n
 #include <compat/linux/common/linux_mmap.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_mtio.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_mtio.c,v
retrieving revision 1.4
diff -u -p -r1.4 linux_mtio.c
--- sys/compat/linux/common/linux_mtio.c	4 Mar 2007 06:01:24 -0000	1.4
+++ sys/compat/linux/common/linux_mtio.c	4 Oct 2007 11:49:49 -0000
@@ -44,6 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_mtio.c
 #include <compat/linux/common/linux_ioctl.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_mtio.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_pipe.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_pipe.c,v
retrieving revision 1.58
diff -u -p -r1.58 linux_pipe.c
--- sys/compat/linux/common/linux_pipe.c	9 Feb 2007 21:55:19 -0000	1.58
+++ sys/compat/linux/common/linux_pipe.c	4 Oct 2007 11:49:49 -0000
@@ -52,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_pipe.c
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_mmap.h>
 #include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_sched.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_sched.c,v
retrieving revision 1.42
diff -u -p -r1.42 linux_sched.c
--- sys/compat/linux/common/linux_sched.c	15 Feb 2007 20:32:48 -0000	1.42
+++ sys/compat/linux/common/linux_sched.c	4 Oct 2007 11:49:49 -0000
@@ -61,6 +61,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sched.
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_machdep.h> /* For LINUX_NPTL */
 #include <compat/linux/common/linux_emuldata.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_sg.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_sg.c,v
retrieving revision 1.10
diff -u -p -r1.10 linux_sg.c
--- sys/compat/linux/common/linux_sg.c	4 Mar 2007 06:01:24 -0000	1.10
+++ sys/compat/linux/common/linux_sg.c	4 Oct 2007 11:49:49 -0000
@@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v
 #include <compat/linux/common/linux_ioctl.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_sg.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_sig_notalpha.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_sig_notalpha.c,v
retrieving revision 1.33
diff -u -p -r1.33 linux_sig_notalpha.c
--- sys/compat/linux/common/linux_sig_notalpha.c	9 Feb 2007 21:55:19 -0000	1.33
+++ sys/compat/linux/common/linux_sig_notalpha.c	4 Oct 2007 11:49:49 -0000
@@ -57,6 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sig_no
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_sigaction.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_sigaction.c,v
retrieving revision 1.30
diff -u -p -r1.30 linux_sigaction.c
--- sys/compat/linux/common/linux_sigaction.c	9 Feb 2007 21:55:19 -0000	1.30
+++ sys/compat/linux/common/linux_sigaction.c	4 Oct 2007 11:49:49 -0000
@@ -57,6 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sigact
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_signal.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_signal.c,v
retrieving revision 1.54
diff -u -p -r1.54 linux_signal.c
--- sys/compat/linux/common/linux_signal.c	4 Mar 2007 06:01:24 -0000	1.54
+++ sys/compat/linux/common/linux_signal.c	4 Oct 2007 11:49:49 -0000
@@ -81,6 +81,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_signal
 #include <compat/linux/common/linux_siginfo.h>
 #include <compat/linux/common/linux_sigevent.h>
 #include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_socket.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_socket.c,v
retrieving revision 1.79
diff -u -p -r1.79 linux_socket.c
--- sys/compat/linux/common/linux_socket.c	29 Aug 2007 22:33:42 -0000	1.79
+++ sys/compat/linux/common/linux_socket.c	4 Oct 2007 11:49:49 -0000
@@ -98,6 +98,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socket
 #include <compat/linux/common/linux_socketcall.h>
 #endif
 #include <compat/linux/common/linux_sockio.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_sysctl.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_sysctl.c,v
retrieving revision 1.31
diff -u -p -r1.31 linux_sysctl.c
--- sys/compat/linux/common/linux_sysctl.c	15 Aug 2007 12:07:30 -0000	1.31
+++ sys/compat/linux/common/linux_sysctl.c	4 Oct 2007 11:49:50 -0000
@@ -54,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_sysctl
 
 #include <compat/linux/common/linux_types.h>
 #include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 #include <compat/linux/common/linux_sysctl.h>
Index: sys/compat/linux/common/linux_termios.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_termios.c,v
retrieving revision 1.31
diff -u -p -r1.31 linux_termios.c
--- sys/compat/linux/common/linux_termios.c	13 May 2007 16:04:00 -0000	1.31
+++ sys/compat/linux/common/linux_termios.c	4 Oct 2007 11:49:50 -0000
@@ -59,6 +59,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_termio
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_termios.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_time.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_time.c,v
retrieving revision 1.18
diff -u -p -r1.18 linux_time.c
--- sys/compat/linux/common/linux_time.c	13 May 2007 11:04:11 -0000	1.18
+++ sys/compat/linux/common/linux_time.c	4 Oct 2007 11:49:50 -0000
@@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_time.c
 #include <compat/linux/common/linux_signal.h>
 #include <compat/linux/common/linux_machdep.h>
 #include <compat/linux/common/linux_sched.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #include <compat/linux/linux_syscallargs.h>
 
Index: sys/compat/linux/common/linux_uselib.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_uselib.c,v
retrieving revision 1.22
diff -u -p -r1.22 linux_uselib.c
--- sys/compat/linux/common/linux_uselib.c	30 Apr 2007 09:20:19 -0000	1.22
+++ sys/compat/linux/common/linux_uselib.c	4 Oct 2007 11:49:50 -0000
@@ -61,6 +61,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_uselib
 #include <compat/linux/common/linux_util.h>
 #include <compat/linux/common/linux_exec.h>
 #include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_ipc.h>
+#include <compat/linux/common/linux_sem.h>
 
 #ifndef EXEC_AOUT
 /* define EXEC_AOUT to get prototype from linux_syscall.h */
Index: sys/lkm/compat/Makefile
===================================================================
RCS file: /cvsroot/src/sys/lkm/compat/Makefile,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile
--- sys/lkm/compat/Makefile	11 Dec 2005 12:24:47 -0000	1.22
+++ sys/lkm/compat/Makefile	4 Oct 2007 11:49:52 -0000
@@ -8,6 +8,10 @@ SUBDIR+=	netbsd32 sunos32 svr4 svr4_32
 SUBDIR+=	freebsd linux svr4 pecoff
 .endif
 
+.if (${MACHINE} == "amd64")
+SUBDIR+=	linux
+.endif
+
 # These are untested, but do compile.  Once they are tested,
 # move them above.
 
Index: sys/lkm/compat/linux/Makefile
===================================================================
RCS file: /cvsroot/src/sys/lkm/compat/linux/Makefile,v
retrieving revision 1.32
diff -u -p -r1.32 Makefile
--- sys/lkm/compat/linux/Makefile	22 Apr 2007 08:30:01 -0000	1.32
+++ sys/lkm/compat/linux/Makefile	4 Oct 2007 11:49:52 -0000
@@ -37,6 +37,15 @@ SRCS+=	linux_syscall.c linux_trap.c
 SRCS+=	linux_sigcode.S
 .endif
 
+.if ${MACHINE} == "amd64"
+.PATH:	$S/compat/linux/arch/${MACHINE}
+.PATH:	$S/arch/${MACHINE}/${MACHINE}
+.PATH:	$S/arch/x86/x86
+SRCS+=	linux_file64.c linux_futex.c linux_misc_notalpha.c linux_sig_notalpha.c
+SRCS+=	linux_syscall.c linux_trap.c
+SRCS+=	linux_sigcode.S
+.endif
+
 .if ${MACHINE_ARCH} == "m68k"
 SRCS+=	linux_ipccall.c linux_llseek.c linux_misc_notalpha.c		\
 	linux_oldselect.c linux_sig_notalpha.c 	\
Index: sys/lkm/exec/Makefile
===================================================================
RCS file: /cvsroot/src/sys/lkm/exec/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- sys/lkm/exec/Makefile	24 Mar 2002 15:01:57 -0000	1.14
+++ sys/lkm/exec/Makefile	4 Oct 2007 11:49:53 -0000
@@ -1,5 +1,9 @@
 #	$NetBSD: Makefile,v 1.14 2002/03/24 15:01:57 kent Exp $
 
+.if ${MACHINE} == "amd64"
+SUBDIR+=	linux_elf
+.endif
+
 .if ${MACHINE} == "i386"
 SUBDIR+=	freebsd_aout freebsd_elf linux_elf svr4_elf pecoff
 .endif
Index: sys/lkm/exec/linux_elf/Makefile
===================================================================
RCS file: /cvsroot/src/sys/lkm/exec/linux_elf/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- sys/lkm/exec/linux_elf/Makefile	12 May 2007 10:45:01 -0000	1.9
+++ sys/lkm/exec/linux_elf/Makefile	4 Oct 2007 11:49:53 -0000
@@ -3,6 +3,7 @@
 .include "../Makefile.inc"
 
 .PATH:	$S/compat/linux/common
+.PATH:	$S/compat/linux/arch/${MACHINE}
 .PATH:	$S/compat/linux/arch/${MACHINE_ARCH}
 
 CPPFLAGS+=	-nostdinc -D_KERNEL -DEXEC_ELF32 -DEXEC_ELF64
@@ -11,13 +12,15 @@ KMOD=	exec_linux_elf
 
 SRCS=	lkminit_exec.c
 
-.if ${MACHINE} == "i386"
+.if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
 SRCS+=	linux_exec_machdep.c
 .endif
 
-.if ${MACHINE} == "alpha" || ${MACHINE} == "sparc64"
+.if ${MACHINE} == "alpha" || ${MACHINE} == "amd64" || ${MACHINE} == "sparc64"
+CPPFLAGS+=	-DELFSIZE=64
 SRCS+=	linux_exec_elf64.c
 .else
+CPPFLAGS+=	-DELFSIZE=32
 SRCS+=	linux_exec_elf32.c
 .endif
 
Index: sys/lkm/exec/linux_elf/lkminit_exec.c
===================================================================
RCS file: /cvsroot/src/sys/lkm/exec/linux_elf/lkminit_exec.c,v
retrieving revision 1.10
diff -u -p -r1.10 lkminit_exec.c
--- sys/lkm/exec/linux_elf/lkminit_exec.c	11 Dec 2005 12:24:48 -0000	1.10
+++ sys/lkm/exec/linux_elf/lkminit_exec.c	4 Oct 2007 11:49:53 -0000
@@ -48,7 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: lkminit_exec
 #include <sys/signalvar.h>
 
 #include <machine/elf_machdep.h>
-#define ELFSIZE	32
 #include <sys/exec_elf.h>
 
 #include <compat/linux/common/linux_exec.h>
@@ -56,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: lkminit_exec
 int exec_linux_elf_lkmentry __P((struct lkm_table *, int, int));
 
 static struct execsw exec_linux_elf =
-	/* Linux Elf32 */
+	/* Linux Elf */
 	{ sizeof (Elf_Ehdr),
 	  ELFNAME2(exec,makecmds),
 	  { ELFNAME2(linux,probe) },
@@ -65,7 +64,7 @@ static struct execsw exec_linux_elf =
 	  LINUX_ELF_AUX_ARGSIZ,
 	  ELFNAME2(linux,copyargs),
 	  NULL,
-	  coredump_elf32,	/* XXX ELF64? */
+	  ELFNAMEEND(coredump),
 	  linux_exec_setup_stack };
 
 /*

--wac7ysb48OaltWcw--