2025-12-30Genre: POSSEDay 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.
A Computer Engineering student who loves FOSS and is learning about privacy, the Internet and languages writing about the things he does.