Page 1 of 1

Help! Exception 14, Page Fault

Posted: Sun Jan 20, 2013 9:14 am
by Miky95
Following this tutorial: http://www.lowlevel.eu/wiki/Teil_9_-_Paging
When you run a program in user mode jumps me except 14 (Page Fault). I am not able to implement the last part of the tutorial, could anyone help? The error occurs when I run a task in user mode.

Re: Help! Exception 14, Page Fault

Posted: Sun Jan 20, 2013 9:33 am
by Griwes
What does #PF error code tell you...?

Re: Help! Exception 14, Page Fault

Posted: Sun Jan 20, 2013 9:55 am
by Miky95
Failure paging. Since everything is padded as Kernel, then when I go to user mode is being accessed at jumping Kernel Page Fault. But I fix this? I am unable to implement the last part of the tutorial, which is correcting this error.

Re: Help! Exception 14, Page Fault

Posted: Sun Jan 20, 2013 4:07 pm
by Brendan
Hi,
Miky95 wrote:
Griwes wrote:What does #PF error code tell you...?
Failure paging. Since everything is padded as Kernel, then when I go to user mode is being accessed at jumping Kernel Page Fault. But I fix this? I am unable to implement the last part of the tutorial, which is correcting this error.
When a page fault occurs the CPU puts important information on the exception handler's stack and in CR2. The information on the exception handler's stack is the return CS:EIP (the address of the instruction that caused the page fault) and an error code (if the fault was caused by a "not present" page, writing to a read only page, CPL=3 code trying to access a "supervisor" page, etc). The value in CR2 is the address that the code attempted to access.

If you gather all the information that the CPU is trying to tell you, then you might end up with a description of the problem like "the code at 0x0008:0x1234 attempts to write to address 0x12345678, which is a not present page".

If the page fault's error code (on the page fault exception handler's stack) says the page isn't present, then the problem is that the page isn't present (e.g. you've used a dodgy pointer or didn't map a page where you should have). Alternatively, if the page fault's error code says that "user" (CPL=3) code attempted to access "supervisor" (CPL=0) pages then the problem is that "user" code attempted to access "supervisor" pages (e.g. you've used a dodgy pointer, or didn't set the "user/supervisor" flag in a page table entry or page directory entry).


Cheers,

Brendan