Handling page faults via traps on x86 (32-bit): Implementation Details
Posted: Fri Feb 27, 2026 12:26 pm
I'm having a bit of difficulty understanding the working of traps in x86, specifically trap 14 (page fault). I've already done some research, but none of the posts online go into enough detail for implementation.
Here are my questions:
Here are my questions:
- Which register is the address pushed to?
- Is this address virtual or physical?
- How does one "resolve" the page fault? For example, if it found that the page for address "X" was set to read only, what does the CPU do when the trap returns? I'd presume it just retries the request (i.e. if my trap fault handler did nothing about that, I'd be in an infinite loop).
- If the request is just retried, how do we "cancel" it? Is the only way to loop infinitely in a panic?
- Does the trap (specifically for page faults) have to "return" anything?