Subject: Re: SIMH and DELQA module
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: Olaf Seibert <rhialto@polderland.nl>
List: port-vax
Date: 10/26/2002 16:23:32
On Sat 19 Oct 2002 at 14:57:40 -0700, Jason R Thorpe wrote:
> Ok, pkgsrc/emulators/simh is now at "simh-2.10.0b2nb1", which includes
> the Ethernet support.

When compiled on Alpha, it crashes (when run as root), see this
transcript. The first time I ran it as non-root, it failed a startup
test, presumably ethernet related. After running it as root, that worked
as non-root but it crashed again later on.

azenomei$ sudo simh-vax vax-netbsd.rc
Password:

VAX simulator V2.10-0
sim> boot cpu


KA655-B V5.3, VMB 2.7
Performing normal system tests.
40..39..38..37..36..35..34..33..32..31..30..29..28..27..26..25..
24..23..22..21..20..19..18..17..16..15..14..13..12..11..10..09..
08..07..06..05..04..03..
Tests completed.
>>>b
No default boot device has been specified.

Available devices.
-DUA0 (RA92)
-DUA1 (RD54)
-DUA2 (RD54)
-DUA3 (RX50)
-MUA0 (TK50)
-MUA1 (TK50)
-MUA2 (TK50)
-MUA3 (TK50)
-DLA0 (RL01)
-DLA1 (RL01)
-DLA2 (RL01)
-DLA3 (RL01)
-XQA0 (08-00-2B-AA-BB-CC)

Device? [XQA0]: dua0

(BOOT/R5:0 DUA0)



  2..
-DUA0
  1..0..


>> NetBSD/vax boot [Aug 19 2001 05:57:49] <<
>> Press any key to abort autoboot 4
nfs_open: must mount first.
open netbsd.vax: Device not configured
> boot netbsd
1171836+57000+194876+[85608+100942]=0x18921a
[ preserving 186550 bytes of netbsd a.out symbol table ]
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 1.5.2 (GENERIC) #7: Sun Aug 19 12:43:34 PDT 2001
    matt@cougar.local:/u1/kobj/GENERIC

MicroVAX 3800/3900
cpu: KA655, CVAX microcode rev 6 Firmware rev 83
total memory = 32708 KB
avail memory = 27304 KB
using 434 buffers containing 1736 KB of memory
mainbus0 (root)
ibus0 at mainbus0
uba0 at ibus0: Q22
dz0 at uba0 csr 160100 vec 304 ipl 15
mtc0 at uba0 csr 174500 vec 774 ipl 15
mscpbus0 at mtc0: version 5 model 3
mscpbus0: DMA burst size set to 4
mt0 at mscpbus0 drive 0: TK50
mt1 at mscpbus0 drive 1: TK50
mt2 at mscpbus0 drive 2: TK50
mt3 at mscpbus0 drive 3: TK50
uda0 at uba0 csr 172150 vec 770 ipl 15
mscpbus1 at uda0: version 3 model 3
mscpbus1: DMA burst size set to 4
ra0 at mscpbus1 drive 0: RA92
ra1 at mscpbus1 drive 1: RD54
ra2 at mscpbus1 drive 2: RD54
rx0 at mscpbus1 drive 3: RX50
Segmentation fault (core dumped)

So I recompiled with -ggdb (XXX the warnings in the xq* functions are
sloppy programming, writing &array instead of &array[0] or just array):

azenomei:/home/tmp/emulators/simh/work.alpha$ make
gcc -O2 -lm -lpcap -I . -ggdb VAX/vax_cpu1.c VAX/vax_cpu.c VAX/vax_fpa.c VAX/va
x_io.c  VAX/vax_mmu.c VAX/vax_stddev.c VAX/vax_sys.c  VAX/vax_sysdev.c  PDP11/p
dp11_rl.c PDP11/pdp11_rq.c PDP11/pdp11_ts.c  PDP11/pdp11_dz.c PDP11/pdp11_lp.c 
PDP11/pdp11_tq.c  PDP11/pdp11_pt.c PDP11/pdp11_xq.c scp.c scp_tty.c sim_ether.c
 sim_sock.c sim_tmxr.c -I VAX/ -I PDP11/ -DUSE_INT64 -o BIN/vax
PDP11/pdp11_xq.c:179: warning: initialization from incompatible pointer type
PDP11/pdp11_xq.c: In function `xq_process_mop':
PDP11/pdp11_xq.c:598: warning: initialization from incompatible pointer type
PDP11/pdp11_xq.c:599: warning: initialization from incompatible pointer type
PDP11/pdp11_xq.c:614: warning: passing arg 3 of `map_writeB' from incompatible 
pointer type
PDP11/pdp11_xq.c: In function `xq_process_xbdl':
PDP11/pdp11_xq.c:792: warning: passing arg 3 of `map_writeW' discards qualifier
s from pointer target type
PDP11/pdp11_xq.c:818: warning: passing arg 3 of `map_writeW' discards qualifier
s from pointer target type
PDP11/pdp11_xq.c: In function `xq_sw_reset':
PDP11/pdp11_xq.c:911: warning: passing arg 1 of `sim_cancel' from incompatible 
pointer type
PDP11/pdp11_xq.c: In function `xq_wr':
PDP11/pdp11_xq.c:981: warning: passing arg 1 of `sim_activate' from incompatibl
e pointer type
PDP11/pdp11_xq.c: In function `xq_svc':
PDP11/pdp11_xq.c:1107: warning: passing arg 1 of `sim_activate' from incompatib
le pointer type
sim_sock.c: In function `sim_accept_conn':
sim_sock.c:147: warning: passing arg 3 of `accept' from incompatible pointer ty
pe

Execution in gdb:

azenomei:/home/tmp/emulators/simh/work.alpha$ sudo gdb BIN/vax
GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "alpha-unknown-netbsd"...
(gdb) run vax-netbsd.rc
Starting program: /home/tmp/emulators/simh/work.alpha/BIN/vax vax-netbsd.rc

VAX simulator V2.10-0

...
ra0 at mscpbus1 drive 0: RA92
ra1 at mscpbus1 drive 1: RD54
ra2 at mscpbus1 drive 2: RD54
rx0 at mscpbus1 drive 3: RX50

Program received signal SIGSEGV, Segmentation fault.
0x16022fe80 in memset () from /usr/lib/libc.so.12
(gdb) bt
#0  0x16022fe80 in memset () from /usr/lib/libc.so.12
#1  0x12003c5f8 in eth_filter (dev=0x0, addr_count=1, addresses=0x1ffffe2a8)
    at sim_ether.c:275
#2  0x1200300bc in xq_process_setup () at PDP11/pdp11_xq.c:663
#3  0x120030584 in xq_process_xbdl () at PDP11/pdp11_xq.c:782
#4  0x120030a34 in xq_dispatch_xbdl () at PDP11/pdp11_xq.c:886
#5  0x120030d14 in xq_wr (data=48, PA=0, access=120) at PDP11/pdp11_xq.c:951
#6  0x120014844 in WriteQb (pa=0, val=48, mode=120) at VAX/vax_io.c:190
#7  0x1200149b8 in WriteIO (pa=536877354, val=0, lnt=120) at VAX/vax_io.c:230
#8  0x12001760c in WriteW (pa=48, val=0) at VAX/vax_mmu.c:359
#9  0x120016d78 in Write (va=2264787242, val=0, lnt=2, acc=16)
    at VAX/vax_mmu.c:230
#10 0x12000a7e0 in sim_instr () at VAX/vax_cpu.c:1066
#11 0x120036ae4 in run_cmd (flag=2, cptr=0x12011d4a8 "") at scp.c:1737
#12 0x120031880 in main (argc=-2992, argv=0x0) at scp.c:556
(gdb) 

In the call to eth_filter, xq.etherface is NULL. I see that xq_attach()
does not even re-set it if eth_open() fails and xq.etherface is freed
(XXX memory leak), so such a failure cannot be the cause of this.

In fact, setting a breakpoint in xq_attach shows it is not even called
at all. I did not give an attach command for it, because XQ shows up in
all "show device" commands already without it:

sim> show dev
...
XQ, address=20001920-2000192F, no vector, MAC=08-00-2B-AA-BB-CC,
type=DELQA, sanity=OFF
...
>>>show dev
Ethernet Adapter 0 (774440)
-XQA0 (08-00-2B-AA-BB-CC)

After some headscratching, I added "attach xq0 ne0" to my rc script, and
then it worked!

Conclusion: the XQ devices should not be emulated when not attached.
There are also some other improvements to be made to the source (marked
with XXX).

>         -- Jason R. Thorpe <thorpej@wasabisystems.com>
-Olaf.
-- 
___ Olaf 'Rhialto' Seibert - rhialto@       -- Woe betide the one who feels
\X/ polderland.nl  -- remorse without sin - Tom Poes, "Het boze oog", 4444.