From owner-freebsd-hackers Wed Oct 21 07:03:54 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA21365 for freebsd-hackers-outgoing; Wed, 21 Oct 1998 07:03:54 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id HAA21313 for ; Wed, 21 Oct 1998 07:03:18 -0700 (PDT) (envelope-from luigi@labinfo.iet.unipi.it) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id IAA09732; Wed, 21 Oct 1998 08:44:44 +0100 From: Luigi Rizzo Message-Id: <199810210744.IAA09732@labinfo.iet.unipi.it> Subject: Handling page faults in user space ? To: hackers@FreeBSD.ORG Date: Wed, 21 Oct 1998 08:44:43 +0100 (MET) X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, i was wondering how to handle page faults/segment violations in user space. Looking at mmap, signal and friends it looks like it is almost possible. E.g. take the following program segment: int *p = 0xdeadbeef ; sig_t handle_sigsegv(int i) { fprintf(stderr, "got sigsegv\n"); mmap(p, 0x1000, PROT_READ, MAP_ANON, -1, 0); } main() { int a; signal(SIGSEGV, handle_sigsegv); a = *p ; /* this results in a SIGSEGV being posted */ fprintf(stderr, "ahhh....\n"); } causes first a fault and then the faulting instruction is restarted and produces the right output. What is missing is how to know, in the signal handler, the fault virtual address and maybe IP associated to the faulting instruction. Ideas anyone ? thanks luigi -----------------------------+-------------------------------------- Luigi Rizzo | Dip. di Ingegneria dell'Informazione email: luigi@iet.unipi.it | Universita' di Pisa tel: +39-50-568533 | via Diotisalvi 2, 56126 PISA (Italy) fax: +39-50-568522 | http://www.iet.unipi.it/~luigi/ _____________________________|______________________________________ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message