This project explores virtual memory in the RISC-V architecture, focusing on how paging and memory isolation are handled using hierarchical page tables and the SATP mechanism.
The assignment gives hands-on experience with:
- Creating and configuring page tables
- Working with different privilege modes (Machine, Supervisor, and User)
- Using the
satpregister for paging - Verifying address translations on execution
Modern computer systems use virtual memory to efficiently manage physical memory and isolate processes. RISC-V supports this using Sv39 paging, a hierarchical page table scheme that allows for 39-bit virtual addressing.
In this assignment, we simulate virtual memory behavior by:
- Switching privilege levels
- Setting up the page table
- Configuring the SATP register
- Entering user mode
- Observing virtual-to-physical address translation
Begin by changing the privilege level of execution using the appropriate CSRs (mstatus, mepc, etc.).
Set up the page table entries in memory, following the Sv39 hierarchical format. Ensure proper alignment and permission bits are configured based on the desired mappings.
Write the appropriate configuration into the satp register:
- Set mode to Sv39
- Assign the physical address of the root page table
- Update other required fields (ASID, etc.)
After configuring the page table and satp, switch the privilege level to User Mode and start execution.
Check the memory dumps or Spike logs to confirm that physical addresses are being replaced with their corresponding virtual addresses — indicating successful paging.
- RISC-V privilege modes: M-mode, S-mode, U-mode
- CSR manipulation (
mstatus,satp,mepc, etc.) - Page table setup (Sv39)
- Virtual-to-physical address mapping
- SATP configuration and paging enablement
- riscv64-unknown-elf-gcc -nostartfiles -T linker.ld va_template.S
- riscv64-unknown-elf-objdump -D a.out > dump
R. Meghana — 3rd Year B.Tech CSE, IIT Madras
This project was done as part of coursework on RISC-V architecture and memory management.

