Subject: Linux emul broken for us
To: None <port-i386@NetBSD.ORG>
From: Brian C. Grayson <bgrayson@ece.utexas.edu>
List: port-i386
Date: 12/19/1996 11:32:13
  First of all:  NetBSD-i386, running -current.

  Linux emulation used to be working on our machines -- a kernel
from early October can run a Linux version of Adobe Acrobat,
among other things, with no problem.  However, for the past few
weeks, I haven't been able to get a -current kernel to work.  I
know I must have done something stupid, and have not been able to
find my problem so far.

  More details:
  I wrote helloworld and compiled it on a Linux machine.  If I
boot with the October kernel, ktrace says:
   305 ktrace   RET   ktrace 0
   305 ktrace   CALL  execve(0xf7bfd4e7,0xf7bfd434,0xf7bfd43c)
   305 ktrace   NAMI  "./hello"
   305 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
   305 ktrace   NAMI  "/emul/linux"
   305 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
   305 hello    EMUL  "linux"
   305 hello    RET   oldolduname 0
   ...
and things work fine.

  With a -current kernel (same machine), ktrace says:
   289 ktrace   RET   ktrace 0
   289 ktrace   CALL  execve(0xf7bfd4e7,0xf7bfd434,0xf7bfd43c)
   289 ktrace   NAMI  "./hello"
   289 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
   289 ktrace   NAMI  "/emul/linux"
   289 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
   289 ktrace   RET   execve -1 errno 8 Exec format error
   ...
and then tries to run /bin/sh on it, which fails.

  I added zillions of debugging to exec_elf32.c, and found that
the failure that causes the ENOEXEC stems from load_file in
exec_elf32.c:384, in the VOP_ACCESS check.

  COMPAT_LINUX and EXEC_ELF32 are in our config, and COMPAT_SVR4
is _not_.  The `file' output on hello is:
  hello: ELF 32-bit LSB executable, Intel 80386, version 1
and the execute bits are set properly.  The file is on an
NFS-mounted directory, but copying it to /tmp doesn't make any
difference.

  I double-checked our kern tree with ftp.netbsd.org, and there
are no major differences.  The latest test kernel was compiled
this morning, from last night's sup.  /emul/linux is fully
populated, and earlier kernels can do linux emulation fine on the
same machine, as mentioned above.  I've also wiped out all kernel
.o files and rebuilt it from scratch a few times, also.

  Unfortunately, I'll be out of town for a week, possibly without
E-mail access and definitely without access to the machine in
question (except over the net -- testing out kernels from 1000
miles away seems a little dangerous!).  However, I wanted to
send this in while it was still fresh in my mind.

  My config is included below.  Many thanks in advance for
pointers!


# MARVIN -- NetBSD-1.0a for marvin
#  Lines marked by ## are ones that are in GENERIC by default, but we
#    don't want them in our kernel.  BCG
#
#

include "arch/i386/conf/std.i386"

makeoptions	CC="cc -Werror -fno-strength-reduce"

options		I486_CPU
options		I586_CPU
options		MATH_EMULATE	# floating point emulation

options		DUMMY_NOPS	# speed hack; recommended
options		XSERVER,UCONSOLE
options		INSECURE	# insecure; allow /dev/mem writing for X

maxusers	32		# estimated number of users
options		TIMEZONE=0	# time zone to adjust RTC time by
options		DST=0		# daylight savings time used by RTC

options		DDB		# in-kernel debugger
#makeoptions	DEBUG="-g"	# compile full symbol table
options		DIAGNOSTIC	# internal consistency checks
options		KTRACE		# system call tracing, a la ktrace(1)

options		SYSVMSG		# System V-like message queues
options		SYSVSEM		# System V-like semaphores
options		SYSVSHM		# System V-like memory sharing
#options	SHMMAXPGS=1024	# 1024 pages is the default


options		COMPAT_NOMID	# compatibility with 386BSD, BSDI, NetBSD 0.8,
options		COMPAT_09	# NetBSD 0.9,
options		COMPAT_10	# NetBSD 1.0,
options		COMPAT_11	# NetBSD 1.1,
options		COMPAT_12	# NetBSD 1.2,
options		COMPAT_43	# and 4.3BSD
options		TCP_COMPAT_42	# TCP bug compatibility with 4.2BSD

##options		COMPAT_SVR4	# binary compatibility with SVR4
##options		COMPAT_IBCS2	# binary compatibility with SCO and ISC
options		COMPAT_LINUX	# binary compatibility with Linux
options		COMPAT_FREEBSD	# binary compatibility with FreeBSD

options 	EXEC_ELF32      # 32-bit ELF executables (SVR4, Linux)

options		USER_LDT	# user-settable LDT; used by WINE
options		LKM		# loadable kernel modules

options		FFS		# UFS
options		QUOTA		# UFS quotas
##options		LFS		# log-structured file system
options		MFS		# memory file system

options		NFSCLIENT	# Network File System client
options		NFSSERVER	# Network File System server

options		CD9660		# ISO 9660 + Rock Ridge file system
options		MSDOSFS		# MS-DOS file system
options		FDESC		# /dev/fd
options		FIFO		# FIFOs; RECOMMENDED
options		KERNFS		# /kern
options		NULLFS		# loopback file system
options		PORTAL		# ?
options		PROCFS		# /proc
options		UMAPFS		# NULLFS + uid and gid remapping
options		UNION		# union file system

##options	GATEWAY		# packet forwarding
options		INET		# IP + ICMP + TCP + UDP
options		NS		# XNS
##options		ISO,TPIP	# OSI
##options		EON		# OSI tunneling over IP
##options		CCITT,LLC,HDLC	# X.25


options         P5CNT           # Pentium hardware performance counters
options		PCVT_NETBSD=121 # PCVT virtual consoles

config		netbsd	swap generic
options		GENERIC

mainbus0 at root

isa*	at mainbus0
eisa0	at mainbus0
pci0	at mainbus0 bus ?

ppb*	at pci? dev ? function ?	# PCI-PCI bridges
pci*	at ppb? bus ?

npx0	at isa? port 0xf0 irq 13	# math coprocessor

#pc0	at isa? port 0x60 irq 1		# generic PC console device
vt0	at isa? port 0x60 irq 1 

com0	at isa? port 0x3f8 irq 4	# standard PC serial ports
com1	at isa? port 0x2f8 irq 3
com2	at isa? port 0x3e8 irq 5
#com3	at isa? port 0x2e8 irq 9
#ast0	at isa? port 0x1a0 irq 5	# AST 4-port serial cards
#com*	at ast? slave ?
#boca0	at isa? port 0x100 irq 5	# BOCA 8-port serial cards
#com*	at boca? slave ?
#rtfps0	at isa? port 0x1230 irq 10	# RT 4-port serial cards
#com*	at rtfps? slave ?

#cy0	at isa? ...

lpt0	at isa? port 0x378 irq 7	# standard PC parallel ports
##lpt1	at isa? port 0x278		# BCG:  we don't have anything here.
##lpt2	at isa? port 0x3bc

##lms0	at isa? port 0x23c irq 5	# Logitech bus mouse
##lms1	at isa? port 0x238 irq 5
##mms0	at isa? port 0x23c irq 5	# Microsoft InPort mouse
##mms1	at isa? port 0x238 irq 5
#pms0	at isa? port 0x60 irq 12	# PS/2 auxiliary port mouse

##aha0	at isa? port 0x330 irq ? drq ?	# Adaptec 154[02] SCSI controllers
##aha1	at isa? port 0x334 irq ? drq ?	# Adaptec 154[02] SCSI controllers
##scsibus* at aha?
##ahb*	at eisa? slot ?			# Adaptec 174[024] SCSI controllers
##scsibus* at ahb?
##ahc*	at pci? dev ? function ?	# Adaptec 2940 SCSI controllers
##scsibus* at ahc?
##ahe0	at isa? port 0x1c00 irq ?	# Adaptec 284x SCSI controllers
##scsibus* at ahe?
##aic0	at isa? port 0x340 irq 12	# Adaptec 152[02] SCSI controllers
##scsibus* at aic?
##bt0	at isa? port 0x330 irq ? drq ?	# BusLogic [57]4X SCSI controllers
##bt1	at isa? port 0x334 irq ? drq ?	# BusLogic [57]4X SCSI controllers
##bt2	at isa? port ? irq ?
##scsibus* at bt?
ncr*	at pci? dev ? function ?	# NCR 538XX SCSI controllers
scsibus* at ncr?
##sea0	at isa? iomem 0xc8000 irq 5
##scsibus* at sea?
##uha0	at isa? port 0x330 irq ? drq ?	# UltraStor [13]4f SCSI controllers
##uha1	at isa? port 0x334 irq ? drq ?	# UltraStor [13]4f SCSI controllers
##uha2	at isa? port ? irq ?		# UltraStor 24f SCSI controllers
##scsibus* at uha?

sd*	at scsibus? target ? lun ?	# SCSI disk drives
st*	at scsibus? target ? lun ?	# SCSI tape drives
cd*	at scsibus? target ? lun ?	# SCSI CD-ROM drives
ch*	at scsibus? target ? lun ?	# SCSI autochangers

fdc0	at isa? port 0x3f0 irq 6 drq 2	# standard PC floppy controllers
#fdc1	at isa? port 0x370 irq ? drq ?
fd*	at fdc? drive ?

##  bgrayson:  enabling the mcd driver, to test.
mcd0	at isa? port 0x300 irq 10	# Mitsumi CD-ROM drives

wdc0	at isa? port 0x1f0 irq 14	# ST506, ESDI, and IDE controllers
#wdc1	at isa? port 0x170 irq ?
wd*	at wdc? drive ?

##wt0	at isa? port 0x300 irq 5 drq 1	# Archive and Wangtek QIC tape drives

ed0	at isa? port 0x280 iomem 0xd0000 irq 9	# WD/SMC, 3C503, and NE[12]000
##ed1	at isa? port 0x250 iomem 0xd8000 irq 9	#   ethernet cards
##ed2	at isa? port 0x300 iomem 0xcc000 irq 10
#eg0	at isa? ...				# 3C505 ethernet cards
##el0	at isa? port 0x300 irq 9		# 3C501 ethernet cards
##ep0	at isa? port ? irq ?			# 3C509 ethernet cards
##ie0	at isa? port 0x360 iomem 0xd0000 irq 7	# StarLAN, 3C507, and Etherexpress
#le0	at isa? port 0x320 irq 10 drq 7		# IsoLan, NE2100, and DEPCA
##le*	at pci? dev ? function ?		# PCnet-PCI based ethernet cards
##de*	at pci? dev ? function ?		# DC21X4X-based ethernet cards
##ep*	at pci? dev ? function ?		# 3C590 ethernet cards

##pss0	at isa? port 0x220 irq 7 drq 6  # Personal Sound System
##sp0	at pss0 port 0x530 irq 10 drq 0	# 	sound port driver

sb0	at isa? port 0x220 irq 7 drq 1	# SoundBlaster
##wss0	at isa? port 0x530 irq 10 drq 0	# Windows Sound System
##pas0	at isa? port 0x220 irq 7 drq 1	# ProAudio Spectrum
##gus0	at isa? port 0x220 irq 7 drq 1 flags 6 # Gravis Ultra Sound (flags is record drq for full-duplex)
#spkr0	at isa? ...

pseudo-device	loop	1		# network loopback
pseudo-device	bpfilter 8		# packet filter
pseudo-device	sl	2		# CSLIP
##pseudo-device	ppp	2		# PPP
pseudo-device	tun	2		# network tunneling over tty

pseudo-device	pty	64		# pseudo-terminals
pseudo-device	tb	1		# tablet line discipline
pseudo-device	vnd	4		# paging to files
##pseudo-device	ccd	4		# concatenated disk devices