I just added some tracing code to arch/i386/mm/fault.c:do_page_fault() and it worked on the first try. I love it when that happens!
I’m trying to figure out why a user space program that accesses the area where the kernel is supposedly mapped (above PAGE_OFFSET,
e.g. 0xC0000004) gets killed. I know (vis-a-vis the tracing code
mentioned above) that it gets a page fault, sees that it’s above PAGE_OFFSET and a user space fault, and then sends a SIGSEGV. What I am not absolutely convinced about is why the fault happens in the first place. The options are that it gets a fault because the kernel is mapped, but the protection on the ptes is such that only code running in ring 0 (i.e. the kernel) can access them, or that the kernel is not mapped while we are running in user space, and is only mapped in when we context switch to kernel space. The former makes a lot more sense, but I haven’t yet hunted down the code that does it.
This question came up in the context of our reading group at work that is reading Mel Gorman’s Understanding the Linux VM book. The books is not great for our needs (too many details, not enough overview and concepts), but provides great context for the discussions.
Leave a Reply