I tried to run an OpenBSD kernel image (for Loongson) under QEMU-emulated
Fulong2E system (on AMD64 host). When I load the kernel from PMON, it starts,
but then the following exception occurs (0x1fe00138 is the address of Bonito
INTEN register):
PMON> boot -k /dev/fs/ext2@wd0/bsd
Loading file: /dev/fs/ext2@wd0/bsd (elf)
(elf)
0x80200000/4656352 + 0x80670ce0/578912(z) + 12144 syms
Kernel debugger symbols ELF hdr @ 0x806fe248
Found Generic Loongson2E, setting up.
Exception Cause=address error on load or ifetch, SR=0x24000002, PC=0x8059d284
CONTEXT=0x000ff000, XCONTEXT=0x000ff000
BADVADDR=0x900000001fe00138, ENTHI=0x800000001fe00000
ENTLO0=0x00000000, ENTLO1=0x00000000
zero at v0 v1 a0 a1 a2 a3
00000000 fffffffe 24000000 1fe00138 ffffffff 1fe00134 fffffff9 801ffec4
t0 t1 t2 t3 t4 t5 t6 t7
801ffec8 1fe00000 00080000 00000000 00020000 0001ffe0 80670000 80700000
s0 s1 s2 s3 s4 s5 s6 s7
ffffffff 00000000 00000019 806678c0 806f0000 80700000 80700000 00000063
t8 t9 k0 k1 gp sp s8 ra
80700000 80700000 00000000 00000000 806600e0 801fff00 1fffffff 8059d268
8059d284 8c670000 lw a3,0(v1) # addr=0x1fe00138
By inserting a few debug pmon_printf calls in the machdep.c file and
recompiling the kernel with a cross-compiler, I found that everything is
executing fine until consinit(), and the exception happens in that function.
After commenting out consinit() and the subsequent printf calls, the kernel
execution continues for a few more lines, and than stops at initmsgbuf
(msgbufbase, MSGBUFSIZE) line with the following execption:
PMON> boot /dev/fs/ext2@wd0/bsd
Loading file: /dev/fs/ext2@wd0/bsd (elf)
(elf)
0x80200000/4656336 + 0x80670cd0/578912(z) + 12136 syms/
Found Generic Loongson2E, setting up.
Exception Cause=address error on load or ifetch, SR=0x24000002, PC=0x802fc090
CONTEXT=0x00003800, XCONTEXT=0x00003800
BADVADDR=0x9800000000700000, ENTHI=0x8000000000700000
ENTLO0=0x00000000, ENTLO1=0x00000000
zero at v0 v1 a0 a1 a2 a3
00000000 80670000 80670000 00000000 00700000 00004000 80670000 00000016
t0 t1 t2 t3 t4 t5 t6 t7
bfd003f8 00000040 00080000 00000000 8009fbc4 0001ffe0 806f0000 806f6560
s0 s1 s2 s3 s4 s5 s6 s7
00700000 80670000 00000000 80670000 00000000 80700000 80700000 00000063
t8 t9 k0 k1 gp sp s8 ra
80700000 80700000 00000000 00000000 806600d0 801fff60 1fffffff 804c099c
initmsgbuf+0x30 dc830000 ld v1,0(a0) # addr=0x700000
There is probably nothing wrong with the OpenBSD kernel, but I just wanted to
ask if somebody had a clue about what was happening. I tried QEMU 0.14.0 and
0.14.1, and OpenBSD kernels from 4.8, 4.9 and current CVS version.
Interestingly, the Linux kernel from Lemote BBS runs fine in QEMU, even without
PMON present (with qemu -kernel option).
Thank you in advance,
Zeljko