o8vm/octox

No PMP entry is configured, so the boot process will fail with illegal instruction

hobo0xcc opened this issue · 2 comments

According to qemu/qemu@d102f19, QEMU will raise an illegal instruction exception when it executes an mret instruction but no PMP entry is configured.
So the following code in start function fixes the bug (in my case).

    let pmpaddr0 = (!0_usize) >> 10;
    asm!("csrw pmpaddr0, {}", in(reg) pmpaddr0);
    let mut pmpcfg0 = 0_usize;
    pmpcfg0 |= 3 << 3;
    pmpcfg0 |= 1 << 2;
    pmpcfg0 |= 1 << 1;
    pmpcfg0 |= 1 << 0;
    asm!("csrw pmpcfg0, {}", in(reg) pmpcfg0);

Older version of QEMU doesn't check whether PMP entry is configured correctly.

o8vm commented

I did not know this. Thank you very much. I'll give it a try! 🥳

o8vm commented

This issue has probably been addressed in this commit.