Re: kernel vm question

From: Jacques Fourie (jacques.fourie_at_gmail.com)
Date: 01/27/05

  • Next message: Andrew Konstantinov: "Re: Cannot start adsl!"
    Date: Thu, 27 Jan 2005 18:48:56 +0200
    To: Jacques Fourie <jf@trispen.com>, freebsd-hackers@freebsd.org
    
    

    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 <das@freebsd.org> 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"
    >
    _______________________________________________
    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"


  • Next message: Andrew Konstantinov: "Re: Cannot start adsl!"

    Relevant Pages

    • Re: Validate a pointer
      ... >> page occurs, the kernel trap handler loads that page, sets up the ... > On systems that page-out memory to some type of device, on each page fault ... > the kernel would need to know what to do to handle the page fault. ... > the swap space, from an executable binary image if a code segment, from a ...
      (comp.unix.programmer)
    • RE: FreeBSD 4.11 P13 Crash
      ... It happened again even with a new CPU and new PowerSupply. ... IPFilter, ... page fault while in kernel mode ... Okay this time my kernel was recompiled so there are no ...
      (freebsd-hackers)
    • Re: Panic: Fatal trap 12: page fault while in kernel mode
      ... page fault while in kernel mode ... page fault while in kernel mode ... > MP Config Base Table Entries: ... > # PCI Ethernet NICs that use the common MII bus controller code. ...
      (freebsd-current)
    • panics with 5.2.1 on single processor on dual motherboard
      ... The kernel currently has SMP, ... GNU gdb 5.2.1 ... page fault while in kernel mode ... acpi0: Overriding SCI Interrupt from IRQ 9 to IRQ 20 ...
      (freebsd-current)
    • fatal trap 12
      ... Until the kernel build and reboot occured, ... fatal trap 12: page fault ... fault virtual address: 0xc ...
      (freebsd-current)