Skip to content

p34: Add page table cloning and ELF loading utilities#353

Open
s-p-1 wants to merge 3 commits intocodenet:p31-umallocfrom
s-p-1:p34-uvm-copy-load
Open

p34: Add page table cloning and ELF loading utilities#353
s-p-1 wants to merge 3 commits intocodenet:p31-umallocfrom
s-p-1:p34-uvm-copy-load

Conversation

@s-p-1
Copy link
Copy Markdown
Contributor

@s-p-1 s-p-1 commented Apr 22, 2026

Objective

This branch completes the core vm.c utility suite by adding copyuvm, loaduvm, and clearpteu. These functions provide the necessary logic for process duplication (fork) and binary loading (exec) once the OS transitions to a full paging model.

Changes Made

  • vm.c: Added copyuvm for deep-copying page directories and physical memory, loaduvm for reading ELF segments from disk into mapped pages, and clearpteu for stack protection.
  • vm.c (Bug Fix): Updated the bounds check in allocuvm to use PHYSTOP instead of KERNBASE. In the current segmentation variant where KERNBASE=0, the original xv6 check would erroneously reject all memory allocation.
  • defs.h: Added the respective prototypes for the new functions.

Integration Note: The Address 0 Collision

During development, a "Shadow Paging" integration was tested by wiring these functions into proc.c. However, because the kernel currently maps I/O space at virtual address 0 (kmap[0]) and the user initcode also targets address 0, a "remap" panic occurs.

To maintain a stable, bootable kernel, these functions are currently included as structural scaffolding. They maintain strict parity with xv6-public and are ready to be utilized as soon as a subsequent branch shifts the kernel to the high-half (0x80000000), resolving the address collision.

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