diff --git a/ostd/src/arch/riscv/qemu.rs b/ostd/src/arch/riscv/qemu.rs index 8071777d2..94d604398 100644 --- a/ostd/src/arch/riscv/qemu.rs +++ b/ostd/src/arch/riscv/qemu.rs @@ -14,9 +14,17 @@ pub enum QemuExitCode { /// Exit QEMU with the given exit code. pub fn exit_qemu(exit_code: QemuExitCode) -> ! { log::debug!("exit qemu with exit code {exit_code:?}"); - match exit_code { + let error_code = match exit_code { QemuExitCode::Success => sbi_rt::system_reset(sbi_rt::Shutdown, sbi_rt::NoReason), QemuExitCode::Failed => sbi_rt::system_reset(sbi_rt::Shutdown, sbi_rt::SystemFailure), }; - unreachable!("qemu does not exit"); + + log::error!( + "SBI system_reset cannot shut down the underlying machine, error code: {:#?}", + error_code + ); + + loop { + riscv::asm::wfi(); + } }