devlog 12-19
{ It turns out that implementing a high-half mapping is no simple task either, requiring attention to numerous details, For instance, kalloc must be modified to determine whether it allocates high or low address. For high address, one must also ensure register writer use low addresses. Additionally, functions like kfree within it need to be modified.
Before enabling sv39 paging, the kalloc.c file requires significant modification. The kalloc function must be split into two separate logic sets: one for use before paging is enabled, which allocates necessary pages and returns low addresses; and another for use after paging is enabled, which returns virtual high addresses.
Not only that, but freerange will also be divided into two systems, following the same principle as above. However, before enabling pagination, the number of pages will no longer be fully allocated but instead distrubuted in portions.
{ 0x8000_0000 _divide _kernel_end _kernel_end+16p PHYSTOP |--------------|------------------------|------------------------|----------------------------| | .text/.rodata (RX/R) | early 16 pages | runtime free pages | | (permission split here) | (boot-only) | (freelist) | |--------------|------------------------|------------------------|----------------------------| [still inside kernel image: data/bss/stack (RW)] } }