bao-project / bao-demos

A guide on how to build and use a set of Bao guest configurations for various platforms
Other
33 stars 37 forks source link

Questions about the implementation of the QEMU H extension #18

Closed KuangjuX closed 1 year ago

KuangjuX commented 1 year ago

Hello! I'm writing a RISC -V hypervisor using RISC -V H extension 1.0, its current repository is here. My current environment is QEMU 7.2.0 and the firmware is RustSBI-QEMU.

I see that your Bao Hypervisor in this project can already run Linux, so I ask you this question, hoping to get your answer.

I have encountered some problems, when the hypervisor is switched from HS mode to VS mode, the two-phase page table translation is no problem and works. But when the guest switches from VS mode to VU mode, strange things happen, Instruction Guest Page Fault occurs when the guest executes sret and jumps to the first instruction of the user program. I can make sure that my guest can run correctly without the H extension enabled. May I ask if this is an implementation bug of QEMU 7.2.0, looking forward to your answer!

Thanks!

KuangjuX commented 1 year ago

I'm sorry to find that this is my problem. It's not a problem with qemu. Because I didn't set all the memory to RWX when mapping memory for the guest in HS mode, this caused the guest to be unable to execute when allocating memory for the application and executing it. , thus triggering an exception.