Subject: VM question
To: None <tech-kern@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: tech-kern
Date: 11/30/2001 23:06:21
For COMPAT_IRIX, I need to map in user memory an ELF psection. I
borrowed the code to do this from sys/kern/exec_elf32.c, but I don't
understand everything in the code I copied.

It seems to work (well, I'm not sure it works, at least it does not
crash my kernel), except if I'm running ktrace on the program. If I'm
using ktrace, I crash.

My question about this: isn't there any simplier way of mapping a memory
area to user space? The code I now have seems really complex to me, I'm
certainly missing something simplier.

It's in sys/compat/irix/irix_syssgi.c:irix_syssgi_mapelf()

Next question: how can it crash with ktrace and go fine without? The
various debug message show similar values for the different variable
involved, whether I run ktrace or not:

Running without ktrace:
irix_syssgi_mapelf(): fd = 3, *ph = 0x7fffe828, count = 2
irix_mapelf(): psize > 0; NEW_VMCMD2
psize = 0x35000, addr = 0xfb60000
vp = 0x8ae39688, offset = 0x0
pht->p_align = 0x4000
irix_syssgi_mapelf(): mapping i = 0, j = 0, *pht = 0xc0086780

Running with ktrace:
irix_syssgi_mapelf(): fd = 3, *ph = 0x7fffe820, count = 2
irix_mapelf(): psize > 0; NEW_VMCMD2
psize = 0x35000, addr = 0xfb60000
vp = 0x8ae39688, offset = 0x0
pht->p_align = 0x4000
trap: TLB miss (load or instr. fetch) in kernel mode
status=0xff03, cause=0x8, epc=0x88101c88, vaddr=0x8
pid=211 cmd=sd-o32 usp=0x7fffe788 ksp=0xc61fbdb8
Stopped in pid 211 (sd-o32) at  0x88101c88:     lw      v1,8(t0)

-- 
Emmanuel Dreyfus
manu@netbsd.org