Date: Thu, 27 Jan 2005 11:09:14 -0500 From: David Schultz <das@FreeBSD.ORG> To: Jacques Fourie <jf@trispen.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: kernel vm question Message-ID: <20050127160914.GA72454@VARK.MIT.EDU> In-Reply-To: <41F90140.3020705@trispen.com> References: <41F90140.3020705@trispen.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 27, 2005, Jacques Fourie wrote: > Hi, > > I have a kernel module with the following entry point : > > static int test_modevent(module_t mod, int type, void *unused) > { > int s; > unsigned char *p = NULL; > unsigned char v = 0x55; > > switch (type) > { > case MOD_LOAD: > p = (unsigned char *)ip_output; > > s = splhigh(); > > v = p[0]; /* Page fault without this line */ > p[0] = v; [...] > If I remove the line "Page fault without this line" line, I get a page > fault when loading this module. This crash seems to be hardware as well > as version specific - I can not reproduce the crash on 4.8 but on one > particular piece of hardware it crashes consistently on 4.9 and 4.10. When the line is there, the compiler is probably smart enough to realize that 'x=y; y=x' is (usually) a no-op, so it optimizes away both statements. Otherwise, you get a page fault because you're trying to write to a non-writable page (namely, one in the kernel's code segment). If you're trying to do what I think you're trying to do, you need to poke around in the VM system and adjust the protection bits in the page you want to write to.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050127160914.GA72454>