riscv-software-src / riscv-pk

RISC-V Proxy Kernel
Other
570 stars 304 forks source link

Is pk preventing me from accessing certain address in simulation by Spike? #289

Open Z-KN opened 1 year ago

Z-KN commented 1 year ago

When I write assembly code and C code for the same functionality that are simulated by spike, it turns out that assembly code can access MMIO device address but C code cannot. The source code is at https://github.com/riscv-software-src/riscv-isa-sim/issues/1238.

I wonder if it is pk, that runs the RISCV program in a user mode, that prevents accesses of PMP and paticular address like external device's memory and registers. If it is, can I modify source code of pk to enable the access?

aswaterman commented 1 year ago

Correct, PK has a demand-paged virtual memory system, and so the addresses in the program don’t directly correspond to physical addresses. And only main memory can be accessed from the user program; there is no means to access MMIO.

If this restriction is a problem for your use case, you shouldn’t use PK.