Re: kernel vm question

From: David Schultz (das_at_FreeBSD.ORG)
Date: 01/27/05

  • Next message: Jacques Fourie: "Re: kernel vm question"
    Date: Thu, 27 Jan 2005 11:09:14 -0500
    To: Jacques Fourie <jf@trispen.com>
    
    

    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"


  • Next message: Jacques Fourie: "Re: kernel vm question"

    Relevant Pages

    • kernel vm question
      ... static int test_modevent ... is the full kernel module source and a dmesg of the hardware in question. ... CPU: IntelXeonCPU 2.66GHz ... pci0: <PCI bus> on pcib0 ...
      (freebsd-hackers)
    • some /proc understandings
      ... struct proc_dir_entry *myfile_file; ... off, int count, int *eof, void *data) ... from another kernel module?? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: memory leak (definition?)
      ... malloc *requires* a correct declaration in scope because it does not return an int, which is what the compiler will assume. ... On some systems ints and pointers are returned in different registers and in others int is smaller than a pointer, so it is not just a theoretical possibility for it to go wrong without the declaration, but a very real situation on modern hardware. ... I am using a 3rd party kernel module that I really do not trust, and it exhibits strange behavior when I use their free functions. ... Rather than trying to figure out the proper usage of their library ...
      (comp.lang.c)
    • kernel module function arguments
      ... I am experimenting a kernel module: ... static int dummy_init{ ... // USERSPACE CODE START ... As a result my kernel module intercept vsyscall call (calling ...
      (comp.os.linux.development.system)
    • kernel module programming
      ... I'm trying to write a kernel module to basically just print out data ... structures of various syscall messages, but now it seems that I am ... I'm trying to do a proper scan of the getdirentries syscall ... static int hide_file_check ...
      (comp.unix.bsd.freebsd.misc)