Subject: mmap, siginfo
To: None <tech-kern@netbsd.org>
From: John R Towler <towl0008@tc.umn.edu>
List: tech-kern
Date: 02/17/2002 16:30:00
Difficulties apparently are manifest in the OS facilities desired in
the new, experimental port of cmucl to NetBSD/x86.  Wrt  the comments
below, the facilities desired are 

((a) the ability to map memory in chunks >= 128M 
or
(b) a means to show that it is not necessarily inefficient)

and 

(c) a siginfo structure which includes access to the address
	of the page fault for SIGSEGV.

I looked a little in the the relevant include files and man pages, and 
read a little in the suggested uvm papers.  Is (a) possible?  If not is that
because (b) can be shown?  Wrt (c), a siginfo is mentioned as in
progress on the sigaction man page.  I looked at the OpenBSD src
tree.  There is a siginfo.h which defines such a struct.  I suspect
that one might need a better sense of what is going on in the kernel
to correctly fill it.  How does one start?  I personally would like to 
get rid of the presupposition that OS entails arch, which manifests
itself often.


		John Towler

/* $CMUCL_TRUNK/src/lisp/NetBSD-os.c */

os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len)
{
  int flags = MAP_PRIVATE | MAP_ANONYMOUS;

  /*
   * NetBSD 1.5.2 seems to insist on each mmap being less than 128MB.
   * So we mmap in 64MB steps.  This is probably inefficient, but the
   * missing CR2 reporting in signal handlers already ensures that
   * NetBSD/x86 is not a suitable platform for CMU CL as it stands.
   */

...

static void sigsegv_handler(HANDLER_ARGS)
{

  /*
   * Since NetBSD on x86 currently provides no way to get the faulting
   * memory address (i.e. the contents of the CR2 register), the page
   * protection mechanism of the generational GC currently can't be
   * used (see gengc.c), hence we don't neet to do anything here.
   *
   * See OpenBSD-os.c for details of what should be here, once NetBSD
   * provides siginfo_t.
   */

  SAVE_CONTEXT();

  DPRINTF(0, (stderr, "sigsegv:\n"));
  interrupt_handle_now(signal, code, context);
}