OS in 1,000 lines: Exception in RISC-V64
This is a companion note to OS in 1,000 lines: Exception originally for RISC-V32.
When kernel_entry calls handle_trap, a0 would be the first parameter to handle_trap, which would be interpreted as a pointer to a trap_frame pointer.
In RISC-V64, kernel_entry should still be aligned to 4 bytes. Supervisor Trap Vector Base Address (stvec) Register
When the program faults, the sepc points to the line
__asm__ __volatile__("unimp");
which may not be 4-byte aligned, but if one does llvm-objdump -d kernel.elf, the address of kernel_entry is indeed 4-byte aligned.