Skip to content

refactor(bootloader): replace RecursivePageTable with identity OffsetPageTable - #15

Merged
imtsuki merged 2 commits into
masterfrom
refactor/bootloader-paging
Nov 13, 2026
Merged

imtsuki merged 2 commits into
masterfrom
refactor/bootloader-paging

Conversation

@imtsuki

@imtsuki imtsuki commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Replaces RecursivePageTable in xv7-bootloader-uefi with an offline BootPageTable backed by OffsetPageTable::new(p4, VirtAddr::zero()) over UEFI's identity mapping (154 insertions(+), 220 deletions(-)):

  • Drop RecursivePageTable & PML4[511]: Builds 4 KiB and 2 MiB higher-half mappings via OffsetPageTable (offset = 0) without polluting PML4[511] or forming an unsound &mut PageTable at 0xFFFF_FFFF_FFFF_F000. Also removes the leftover table[511] recursive entry in AddressSpace::new() and updates the virtual memory map docs in xv7-boot.
  • Switch CR3 Only After exit_boot_services(): Relocates the PIE kernel via OffsetPageTable::translate_addr before switching page tables, uses .ignore() while constructing the offline table (zero invlpg flushes), and loads CR3 once after exit_boot_services() returns.
  • Zero-Initialize Allocated Frames & Skip RESERVED 1 TiB Hole: Zeroes newly allocated page-table, kernel-stack, and ELF segment pages (alloc_zeroed_pages), and filters out MemoryType::RESERVED holes (such as QEMU AMD's [0xfd00000000..=0xffffffffff] 1 TiB aperture) while covering all usable/firmware RAM, GOP framebuffer, and < 4 GiB MMIO.

Verification

  • make build (dev & release) + cargo check with frame-allocator-buddy
  • Booted in QEMU (debug & release) and verified Ring 3 /init interactive shell execution

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T23:40:54.873885Z b08b0b9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@imtsuki imtsuki changed the title refactor(bootloader): replace RecursivePageTable with offline BootPageTable refactor(bootloader): replace RecursivePageTable with identity OffsetPageTable Nov 13, 2026
@imtsuki
imtsuki merged commit 6ef9bfa into master Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant