Date: Wed, 21 Oct 1998 08:44:43 +0100 (MET) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: hackers@FreeBSD.ORG Subject: Handling page faults in user space ? Message-ID: <199810210744.IAA09732@labinfo.iet.unipi.it>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810210744.IAA09732>