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.
Hi All,
If there is one page fault, the page fault handler will get the error code
osdevwiki wrote:
31 4 0
+-----+-...-+-----+-----+-----+-----+-----+-----+
| Reserved | I/D | RSVD| U/S | W/R | P |
+-----+-...-+-----+-----+-----+-----+-----+-----+
P: When set, the fault was caused by a protection violation.
When not set, it was caused by a non-present page.
W/R: When set, write access caused the fault; otherwise read access.
U/S: When set, the fault occurred in user mode; otherwise in supervisor mode.
RSVD: When set, one or more page directory entries contain reserved bits which are set to 1.
This only applies when the PSE or PAE flags in CR4 are set to 1.
I/D: When set, the fault was caused by an instruction fetch.
This only applies when the No-Execute bit is supported and enabled.
I am a very curious about how the instruction fetch page fault is generated? I would really appreciate it if someone could give me a example.
And also how this kind of page fault will be handled? Thanks for your time!
loki2441 wrote:I am a very curious about how the instruction fetch page fault is generated? I would really appreciate it if someone could give me a example.
It's generated the same as any other page fault (e.g. the access wasn't allowed by the page's attributes). An example would be attempting to execute code in a page that has the "execute disable" bit set.
loki2441 wrote:And also how this kind of page fault will be handled?
It'd be handled the same as any other page fault. Specifically:
determine if the access should have been allowed:
If it should've been allowed, fix stuff so that the access will work (e.g. load the page from swap space or memory mapped file) and return (retry the instruction that caused the exception)
If it shouldn't be allowed (e.g. the code that was running crashed), pass control to some sort of crash handler (which might do "blue screen of death", or terminate the process, or send a signal to the process, or do a core dump, or whatever).
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.