ECE344 Fall 2026 (Sec 1) Lec 10 - Page Tables
Overview
Jon Eyolfson explains how RISC-V SV39 multi-level page tables reduce the memory cost of sparse per-process address spaces: instead of a 1 GB flat table for a 39-bit virtual address, a translation typically needs only three 4 KB tables. He traces the address-indexing and page-walk process, then connects it to page alignment, xv6 allocation, page faults, lazy allocation, and copy-on-write.
Key takeaways
- A flat SV39 page table needs 2^27 entries; at 8 bytes each, that is 1 GB per process even when most virtual pages are unused.
- Three levels of 512-entry tables reduce the storage needed for a single mapped page to 12 KB, because unmapped regions can be excluded by invalid upper-level entries.
- SV39 uses a 12-bit page offset and three 9-bit VPN indices; the page walk replaces the VPN with the final PPN while preserving the offset.
- Multi-level page tables save memory for sparse mappings but add page-table memory accesses, making translation caching important.
- Page faults enable both lazy allocation and copy-on-write: the kernel can create a page on first access or copy a shared page only when a process writes.
- Page validity applies to a full 4,096-byte page, so an invalid pointer access can escape detection when it lands within an already mapped page.
Chapters
- Test One covers material through the first half of the next lecture on virtual memory; Jon Eyolfson recommends archived ECE344 and 2025 ECE353 midterms for practice.
- The test emphasizes operating-systems concepts and interpreting or fixing supplied code rather than writing large programs from scratch.
- Students should also understand Labs 1 and 2; the lecture notes that the course has not yet introduced threads or concurrency.
- A 39-bit virtual address with 4,096-byte pages has a 12-bit offset and a 27-bit virtual page number, requiring 2^27 entries in a flat table.
- At 8 bytes per page-table entry, a flat table occupies 2^30 bytes, or 1 GB, for each process.
- Programs such as `cat` use only a small fraction of their address spaces, so most flat-table entries would merely mark unmapped addresses as invalid.
- A 4,096-byte page holds 512 entries when each page-table entry is 8 bytes: 4,096 รท 8 = 512 = 2^9.
- Using those 9 bits as an index makes a single page-sized table cover only a 21-bit address space, or 2 MB, which is too small for typical processes.
- The RISC-V SATP register identifies the root page table by its physical page number; on x86, the corresponding register is CR3.
- With 4,096-byte pages, page-aligned addresses have their low 12 bits set to zero, so the page number and offset can be handled separately.
- A physical page number (PPN) identifies a physical page without its offset; a virtual page number (VPN) identifies the process's virtual page to translate.
- An 8-byte-aligned page-table entry begins at an address divisible by 8, which can be checked by confirming its lowest three binary bits are zero.
- SV39 divides the 27-bit VPN into L2, L1, and L0 indices of 9 bits each, with every level containing up to 512 entries.
- SATP points to the root L2 table; a valid L2 entry points to an L1 table, an L1 entry points to an L0 table, and the L0 entry supplies the final PPN.
- Each index selects an entry in its level's page-table array, allowing the page-table structure to grow only where virtual addresses are mapped.
- A single virtual-page translation in a three-level table needs only three page-sized tables, or 12 KB, instead of a 1 GB flat table.
- An invalid entry stops the page walk early: an invalid L2 entry can exclude a 1 GB region, while an invalid L1 entry can exclude a 2 MB region.
- The tradeoff is more memory accesses during translation, three page-table reads rather than one for a flat table, so a cache such as a translation lookaside buffer is needed to address the latency.
- A page table is an array of 512 64-bit entries, totaling exactly 4,096 bytes; L2 and L1 entries point to lower-level tables, while L0 entries provide final mappings.
- In the described RISC-V PTE scheme, a valid entry with no read, write, or execute permissions indicates a next-level table; permission bits identify a leaf mapping.
- A leaf at L1 can map a 2 MB huge page, and a leaf at L2 can map a 1 GB page, avoiding lower-level tables for large contiguous regions.
- The xv6 helpers `pte2pa` and `PX` extract a physical address from a PTE and an index for a page-table level, respectively.
- The kernel's physical-memory allocator organizes free frames as a linked list, using a page itself to store its next pointer while that page is free.
- Allocation removes a page from the free-list head; deallocation returns it to the list.
- A newly allocated page table is zeroed so that all of its entries initially represent invalid mappings.
- For a 30-bit virtual address and 4,096-byte pages, the VPN has 18 bits; a flat table of 8-byte entries would require 2 MB per process.
- A two-level design uses 9-bit L1 and L0 indices; mapping just one virtual page requires one page for each table, or 8 KB.
- For virtual address `0x3FFFF008`, both indices are 511 and the offset is `0x008`; with the demonstrated L0 PPN `0xCAFE`, the translated physical address is `0xCAFE008`.
- A page-table entry can point to the same lower-level table as another entry, making distinct virtual addresses map to the same physical pages, an alias that can cause unintended shared writes.
- If a page-table walk reaches an invalid entry, the MMU raises a page fault; the kernel can reject an illegal access, resulting in a segmentation-fault signal.
- The kernel can also handle a fault by allocating and mapping a page on first access, then restarting the instruction so the process need not observe the fault.
- Copy-on-write lets processes created by `fork` initially share a physical page; when one writes, the kernel handles the fault by copying the page and giving that process an independent mapping.
- The lecture's MMU simulator models 16 physical frames and provides allocation, `map`, and `translate` operations that show each level of an SV39 page-table walk.
- A valid PTE maps an entire 4,096-byte page, not an individual byte: changing the offset does not change the page-table lookup, and an out-of-bounds access can go unnoticed if it remains on a mapped page.
Transcript excerpt
2:08 Alrighty, welcome back to operating systems. So, test one quick spiel. Again, it's within a week. Oh, no. Uh yeah, it will cover up to virtual memory. So, the next half of next lecture. Up to and including not the second half of that lecture. If you want study materials or practice questions or everything, go to my website, go in the archive. 344 is your course. You can look at the midterms there. Those midterms go to week six, so there'll be stuff that you haven't covered. If you read the question, can't understand it, do not try and answer it because you don't know it yet. So, don't worry about it. You can also look at uh 353. That's the exact same course as
2:59 this one, but for N size students. They need a special number. Don't ask me why. If you look at 2025, they have a test one similar to yours. Covers the first four weeks instead of six, so more like it. Yeah. No multi-threading. We don't know what the word thread means yet. We don't know what concurrency is yet. We are safe. Yeah. So, next lecture first half is going to be the last one. So, it'll be virtual memory, so this is all reiterating, talking about more virtual memory stuff. Concepts will probably end at this lecture, but next lecture also helps reinforce it. Might have a few conceptual questions. And you should also know lab one and lab two. So,
3:47 unlike last year's LLM's better, I have to put questions on there to make sure you have some semblance of what the hell you did and just didn't let an LLM rip and have no idea what was going on. Yeah. >> I don't know if you're allowed to tell us, but I was wondering how much of it
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Jon Eyolfson.