feat(hal): enable riscv64 Sv39 MMU with an identity page table - #146
Merged
Conversation
The riscv64 boot ran with paging off (satp = 0). Build a minimal Sv39 identity map and turn it on, mirroring the aarch64 #142 approach. Sv39's root (L2) table maps 1 GiB gigapages; _start populates a BSS-resident, 4 KiB-aligned root table (__riscv_root_pt) with two identity leaf PTEs (flags V|R|W|X|A|D = 0xCF): L2[0] -> 0x0000_0000..0x4000_0000 device MMIO (CLINT 0x0200_0000, PLIC 0x0C00_0000, NS16550 0x1000_0000) L2[2] -> 0x8000_0000..0xC000_0000 RAM (OpenSBI + kernel at 0x8020_0000) then sets satp = MODE_SV39 | (root >> 12) with sfence.vma before/after. Verified: 'qemu-system-riscv64 -M virt -bios default' boots with paging ON all the way to the halt loop (UART/PLIC/timer all reached through the identity map), with zero S-mode page faults under 'qemu -d int' (the remaining illegal-insn traps are pre-existing OpenSBI-firmware HPM probing, unrelated). x86_64/aarch64 unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The riscv64 boot ran with paging off (
satp=0). Build a minimal Sv39 identity map and enable it (mirrors aarch64 #142).Sv39 root (L2) table maps 1 GiB gigapages;
_startpopulates a BSS-resident 4 KiB-aligned__riscv_root_ptwith two identity leaf PTEs (flags V|R|W|X|A|D = 0xCF):then
satp = MODE_SV39 | (root >> 12)withsfence.vmabefore/after.Verified (
qemu-system-riscv64 -M virt -bios default): boots with paging ON to the halt loop (UART/PLIC/timer all reached through the identity map), zero S-mode page faults underqemu -d int(remaining illegal-insn traps are pre-existing OpenSBI HPM probing, unrelated). x86_64/aarch64 unaffected.