KL-OS: Page Table

2025-12-30Genre: POSSE

Day 9 was about memory management and virtual addressing.

The structure of the virtual address is defined by the RISC-V paging mechanism called Sv32. It uses a two level page table where the 32 bit virtual address is divided into a first-level page table index, a second level and a page offset. The tables are named VPN[1] and VPN[0] respectively.

First the macros for the construction of the page table are defined. Then the function to map pages map_page is made which is utilized in process creation. For that we also add an element called page_table on the struct of process. And to make everything work we define the starting address of the kernel space __kernel__base in the linker script just after boot.

To utilize the above setup of page tables and switch them, we specify the first-level page table in satp (Supervisor Address Translation and Protection) register.

I still need to understand more about this. I am not satisfied with the explanation from the resource.


Webmentions

Have you written a response to this? Let me know the URL, Or, you can send your response via mail:iac@scientiac.space