分页(多页)场景下跨页地址访问映射机制咨询
How x86 Paging Handles Unmapped Virtual Addresses
Great question—this cuts right to how x86 paging operates at its core, so let’s break it down plainly:
Short Answer
Your program P1 will NOT automatically map to the second page if it accesses an address beyond the first page’s upper limit. Instead, the CPU will immediately trigger a page fault interrupt (#PF, interrupt number 14).
Detailed Explanation
Here’s why this works the way it does:
- x86 paging is an explicit mapping system, not an implicit or auto-filling one. Every virtual address your program uses must have a corresponding, valid entry in the page tables (starting with the page directory pointed to by
CR3). - When you registered two non-contiguous pages in the page directory, you only created mappings for those specific virtual address ranges. Any virtual address outside those ranges has no valid entry in the page tables.
- When P1 tries to access an unmapped address:
- The CPU checks the relevant page directory entry (and page table entry, if using 2-level paging) for that virtual address.
- Since there’s no valid entry (either the entry is missing, or the Present bit
Pis set to 0), the CPU raises a page fault. - The kernel’s page fault handler will then handle this—usually by either allocating a new physical page and setting up the mapping, or terminating the program if the access is invalid.
There’s no logic in the CPU that assumes "if you have a mapping for page X, you must want page X+1 mapped to the next physical page". Every single virtual-to-physical mapping has to be explicitly configured in the page tables.
内容的提问来源于stack exchange,提问作者Leosa99 _
相关产品推荐
相关产品推荐

