-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Labels
bugSomething isn't workingSomething isn't workinginefficiencyBetter implementation is desiredBetter implementation is desired
Description
The issue
- Running riscv32 userland with riscv64 kernel is broken
Steps to reproduce
- Use those firmware/kernel/rootfs: rv32_umode.zip
- Run
rvvm fw_jump.bin -k linux_6.8 -i rootfs_rv32.ext2 -nojit
- The userland will crash almost immediately with random unhandled pagefaults inside the kernel or segfaults in userspace
Investigation
- RV32 U-mode RVJIT is most likely broken. It doesn't sign-extend the dirty 32-bit registers upon spilling them into hart ctx. So just disable it for now and fix later.
- Interpreter properly sign-extends writes into rv32 registers to full 64-bit register by intermediate cast to
sxlen_t
:
Line 422 in 9929fdd
static forceinline void riscv_write_reg(rvvm_hart_t* vm, regid_t reg, sxlen_t data) - Interpreter load/stores are computing effective virtual address as
xlen_t
which is unsigned 32-bit in rv32. It's okay for bare or SV32 MMU, but apparently rv32 U-mode uses an SV39/48 MMU so the upper VA half is not properly sign-extended. Eitherriscv_mmu
should manually sign-extend rv32 addresses on SV39, or switch to sxlen_t addresses in interpreter and making Bare/SV32 modes work with this. - The CSR subsystem is likely broken. Applying a 32-bit CSR mask when running in rv32 mode allows to see buildroot MOTD, but most other userspace parts are still crashing.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinginefficiencyBetter implementation is desiredBetter implementation is desired