Trap -> page fault but error code == 0 ?

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
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Trap -> page fault but error code == 0 ?

Post by JulienDarc »

Hello,

I understand that having an error ==0 when having a page fault exception, when in kernel space, is not a dangerous thing.
http://wiki.osdev.org/Exceptions#Page_Fault

The cpu just means : "hey OS, map that address for me and we are done; nothing dangerous happened."

This situation seems pretty clear but I have no one else to ask/confirm but you.

Am I right ? Did I overlook something ?

Thanks
Last edited by JulienDarc on Mon Apr 06, 2015 3:27 am, edited 1 time in total.
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: Trap -> page fault but error code == 0 ?

Post by Techel »

That's right. A page fault by reading from unmapped memory.
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Trap -> page fault but error code == 0 ?

Post by JulienDarc »

Thanks Roflo 8)
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Trap -> page fault but error code == 0 ?

Post by iansjack »

It's not necessarily a dangerous thing as long as you handle it. In other words, just the same as any other page fault.

But normally, although it obviously depends upon the design of your kernel, any page fault in kernel space is a sign that something unexpected has happened.
JulienDarc
Member
Member
Posts: 97
Joined: Tue Mar 10, 2015 10:08 am

Re: Trap -> page fault but error code == 0 ?

Post by JulienDarc »

Yes thanks a lot iansjack,

i am currently writing the routine to handle that.

Now that it is clear that there is nothing potentially malicious, i feel safer :)

OS development is a very rewarding process, that is amazing.
It helps improving the code on the application side. Should have started it earlier !

But I digress now,

Bye

Julien
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Trap -> page fault but error code == 0 ?

Post by xenos »

I would say if it is unexpected, then it is also potentially dangerous, because it shows there must be a bug in your code which causes this unexpected behavior. It's quite possible that this bug will do no harm, but it may just as well crash your kernel - in any case, your kernel will not do what you expect, so you should in any case be alerted and figure out the reason for the page fault.

But if you expect a page fault, because you design your kernel in such a way that you map pages on demand, and this demand is indicated by a page fault, then of course it is not dangerous.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Post Reply