From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 27 16:49:01 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5AFDD16A4CE for ; Thu, 27 Jan 2005 16:49:01 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C2F143D5A for ; Thu, 27 Jan 2005 16:49:00 +0000 (GMT) (envelope-from jacques.fourie@gmail.com) Received: by rproxy.gmail.com with SMTP id f1so287447rne for ; Thu, 27 Jan 2005 08:48:57 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=D0kPglKzkflgQxXirok0uQSYdkhWHDiHKds7zH4xOcwLDR1CALhxBy5JKvfYyXUhVkChQXUb1OkHzjZ78Lx/ILq2MNWBKePkzqlDzIcLkAXLiIEhbEKgBahMVe9VMeJryMV2JDv0yKcIEWW6y1P6iaHbH2xAguGkz74bMAg2tBE= Received: by 10.38.153.44 with SMTP id a44mr12825rne; Thu, 27 Jan 2005 08:48:56 -0800 (PST) Received: by 10.38.165.21 with HTTP; Thu, 27 Jan 2005 08:48:56 -0800 (PST) Message-ID: Date: Thu, 27 Jan 2005 18:48:56 +0200 From: Jacques Fourie To: Jacques Fourie , freebsd-hackers@freebsd.org In-Reply-To: <20050127160914.GA72454@VARK.MIT.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <41F90140.3020705@trispen.com> <20050127160914.GA72454@VARK.MIT.EDU> Subject: Re: kernel vm question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jacques Fourie List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2005 16:49:01 -0000 Hi, Yes, I am trying to patch a piece of code in the kernel. The strange thing is that this code works without a problem on FreeBSD 4.8 - has the VM system changed to such an extent between 4.8 and 4.9 that the pages in the kernel code segment are not writeable anymore? Thanks for the bit about the compiler optimization - at least I understand that part now :) regards, jacques On Thu, 27 Jan 2005 11:09:14 -0500, David Schultz wrote: > 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. > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >