p35: High-half kernel migration, hardware paging enablement, and flat user segments#356
Open
2023cs50578 wants to merge 4 commits intocodenet:p31-umallocfrom
Open
p35: High-half kernel migration, hardware paging enablement, and flat user segments#3562023cs50578 wants to merge 4 commits intocodenet:p31-umallocfrom
2023cs50578 wants to merge 4 commits intocodenet:p31-umallocfrom
Conversation
776a5a6 to
24f1ecc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
This branch performs the critical architectural migration of the kernel to the high-half of the virtual address space (
0x80000000). It enables the MMU hardware paging inentry.S, completely dismantles the legacy segmentation isolation model, and wires the page directory lifecycle into the process execution path.Core Architectural Changes
memlayout.h&kernel.ld: ShiftedKERNBASEto0x80000000and updated the linker script to link the kernel at0x80100000while loading at physical0x100000.entry.S&mmu.h: Implemented the bootstrap sequence to loadentrypgdirintocr3, enabledCR4.PSEandCR0.PG|WP, and executed the jump to the high-half virtual addresses.vm.c(switchuvm): Eliminated segment-based memory isolation. User segments (SEG_UCODE/SEG_UDATA) are now set to a flat0base with a4GBlimit. Added thelcr3(V2P(p->pgdir))call to enforce isolation strictly via the hardware page directories.exec.c: Rewrote the legacy segment-expanding ELF loader to use the proper paging utilities (allocuvm,loaduvm,clearpteu). Note: Forced a local#define PGSIZE 4096override to prevent the global 1MB macro from misaligning the user stack.proc.c: Wired the active page directory lifecycle into process management (setupkvminuserinit,copyuvminfork,freevminwait).Boot-Path & Hybrid State Fixes
kinitSplit (main.c,kalloc.c,defs.h): Split the physical memory allocator intokinit1andkinit2. Because the globalPGSIZEremains 1MB,setupkvmconsumes ~65MB to build the initial page tables. Expandedentrypgdirto cover a 128MB bootstrap mapping and passed128MBtokinit1to provide sufficient runway for the allocator before the fullkpgdiris activated.mp.c): RestoredP2V()wrapping for BIOS/MP structures (EBDA, MP Config Table) to prevent kernel page-faults post-migration, askpgdirno longer maintains an identity mapping in the lower half.