Help! Exception 14, Page Fault

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Miky95
Posts: 2
Joined: Thu Sep 15, 2011 9:25 am

Help! Exception 14, Page Fault

Post 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.
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: Help! Exception 14, Page Fault

Post by Griwes »

What does #PF error code tell you...?
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
Miky95
Posts: 2
Joined: Thu Sep 15, 2011 9:25 am

Re: Help! Exception 14, Page Fault

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Help! Exception 14, Page Fault

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply