Skip to content

mkernel misaligned pointer dereference on trapframe #6

Description

@stemnic

Things seems to have changed in two years and now the trap frame does not seem to be aligned for some reason

-----------------------
 rustyvisor
-----------------------
[INFO] logger was initialized
[INFO] processor is in m-mode running with hartid: 2147483676
[INFO] Initing heap implementation: 0x0000000082322000 -> 0x0000000082332000 size: 0x0000000000010000
[rustsbi-dtb] Hart count: cluster0 with 1 cores
[INFO] jump to hypervisor while chainging CPU mode from M to HS
[INFO] Current mepc addr 0x80100580
[INFO] hypervisor started
[INFO] environment call from HS-mode at 0x000000008010adba
abort: line 174, file hypervisor/src/mkernel.rs: misaligned pointer dereference: address must be a multiple of 0x8 but is 0x8000001c

#[no_mangle]
pub extern "C" fn rust_mtrap_handler(
mepc: usize, // a0
mtval: usize, // a1
mcause: usize, // a2
mstatus: usize, // a3
frame: *mut TrapFrame, // a4
) -> usize {
log::debug!("trapped to M-mode!");
log::debug!("Machine trap cause {:#x}", mcause);
log::debug!("Machine trap mepc {:#x}", mepc);
log::debug!("Machine trap mstatus {:#x}", mstatus);

match cause_code {
9 => {
log::info!("environment call from HS-mode at 0x{:016x}", mepc);
let hypervisor_frame = unsafe{*frame.clone()};
let a1 = hypervisor_frame.regs[11];
let a0 = hypervisor_frame.regs[10];
let mut result = 0;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions