Date: Wed, 26 Sep 2001 17:20:31 +0100 From: Nick Barnes <Nick.Barnes@pobox.com> To: freebsd-hackers@freebsd.org Subject: distinguising read faults and write faults Message-ID: <52872.1001521231@thrush.ravenbrook.com>
next in thread | raw e-mail | index | archive | help
I am in the process of porting an incremental garbage collector to FreeBSD on x86. This garbage collector uses read barriers and write barriers for incrementality. The details are irrelevant; the key part is that I want to protect parts of memory and handle faults on the protected pages. On FreeBSD, I will be using mmap(MAP_ANON) to obtain memory, and mprotect() to raise the barriers, with a signal handler to handle barrier hits. I have worked out that I need to handle SIGBUS (not SIGSEGV, which surprised me), and that ucontext->mcontext.mc_trapno will be 12 (T_PAGEFLT, not T_PROTFLT, which surprised me). However, I don't see any way of distinguishing between read faults and write faults. This information doesn't appear to be anywhere in the ucontext or the siginfo. Is there any way of distingushing read faults from write faults (other than by decoding the instruction at mc_eip)? Matching code for Linux below: Nick Barnes /* distinguishing read faults from write faults on Linux */ static void sigHandle(int sig, struct sigcontext context) { if(context.trapno == 14) { /* page fault */ int write = ((context.err & 0x2) != 0); /* write */ ... 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?52872.1001521231>