Subject: COMPAT_LINUX
To: None <port-m68k@netbsd.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: port-m68k
Date: 12/16/1998 20:03:48
Hello,

I've committed Linux emulation support on m68k ports.
Some functions are missing, but some Linux/m68k programs,
statically and dynamically linked, run fine on my x68k (MC68030 + MC68882).

It is, however, not tested on other platforms.  Please test it.

If you want to use the function, add and enable

	options 	COMPAT_LINUX
	options 	EXEC_ELF32

to your configuration file and rebuild a kernel.
Some backward compatibility options

	options 	COMPAT_43
	options 	COMPAT_09,COMPAT_12

enable full function of the linux compat. but (I hope) they are optional.
The DEBUG option

	options 	DEBUG

is recommended for sanity checking.

To run Linux binaries, place the Linux/m68k files
(executables, libraries, etc.) as if the "/emul/linux" were
the root directory.
The compat_linux(8) manpage is written for i386 but has good hints.

You can use ktrace(1) and kdump(1) to trace linux binaries
(the outout is a little incorrect, though).
You need to recompile kdump to see symbolic syscall name of linux.


Note:
	The implementation of Linux sigreturn functions
	(linux_sys_sigreturn() and linux_sys_rt_sigreturn()) is kludgy.
	If the functions require extra space on kernel stack for RTE,
	they move the frame (struct trapframe) and re-enter syscall()
	like longjmp().
	See linux_machdep.c and linux_sig_machdep.S for details.

	I have three ideas to implement the linux sigreturn functions:

	 1. (The one above)
	 2. Check if the syscall is sigreturn or rt_sigreturn
	    of Linux emulation and allocate extra space if necessary
	    at the trap #0 entry in locore.s.
	 3. Do syscall finish processing and stack manipulation
	    at the end of sigreturn functions.

	2. introduces extra overhead to all system calls including
	NetBSD native ones.  Implementation of 3. requires more changes
	in port-specific parts --- I think Linux emulation is not so
	worthy as to do this, at least for now. :-)

BUGS:
	Linux/m68k binaries are not useful, as far as I know.
	Do you know anything interesting?

Enjoy,
--
ITOH, Yasufumi <yasufu-i@is.aist-nara.ac.jp>, <itohy@netbsd.org>