Page fault traps in the linuxulator

Peter S. Housel housel at acm.org
Fri May 14 09:52:50 PDT 2004


In 5.2-CURRENT I'm running some Linux code (a garbage collector) that needs
to trap page faults. There are a couple of problems with the i386 code that
builds linux signal context:

/* ... */
 frame.sf_sc.sc_err    = regs->tf_err;
 frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code);

The first problem is that the sc_cr2 field of the linux sigcontext is not
initialized with the faulting address (obtained at page fault time from the
cr2 register).  The second problem is that sc_err is being initialized
incorrectly, because in trap_pfault the original tf_err field provided by
the processor has already been overwritten:

 /* kludge to pass faulting virtual address to sendsig */
 frame->tf_err = eva;

The trap handler has worked this way since trap.c revision 1.25 (soon to be
having its tenth anniversary).  Surely there is some better way to pass eva
to sendsig so thtat the 3-bit err field is not lost.  (It would be nice if
said field were available in the FreeBSD sigcontext, too, but that would
likely involve an ABI change.)

-Peter-



More information about the freebsd-emulation mailing list