Skip to content

Commit

Permalink
[update] modify to delegate unknown sbi calls to M-mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alignof committed Dec 30, 2024
1 parent d538a27 commit 62d490a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/trap/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::hstrap_exit;
use crate::guest;
use crate::h_extension::{csrs::vstvec, HvException};
use crate::HYPERVISOR_DATA;
use sbi_handler::sbi_call;

use core::arch::asm;
use riscv::register::{
Expand Down Expand Up @@ -57,10 +58,7 @@ fn sbi_vs_mode_handler(context: &mut guest::context::Context) {
sbi_spec::pmu::EID_PMU => sbi_pmu_handler(func_id, arguments),
sbi_spec::rfnc::EID_RFNC => sbi_rfnc_handler(func_id, arguments),
EID_FWFT => sbi_fwft_handler(func_id, arguments),
_ => panic!(
"Unsupported SBI call, eid: {:#x}, fid: {:#x}",
ext_id, func_id
),
_ => sbi_call(ext_id, func_id, arguments),
};

context.set_xreg(10, sbiret.error as u64);
Expand Down
6 changes: 5 additions & 1 deletion src/trap/exception/page_fault_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ pub fn load_guest_page_fault() {
DeviceEmulateError::InvalidAddress
| DeviceEmulateError::InvalidContextId
| DeviceEmulateError::ReservedRegister,
) => hs_forward_exception(),
) => {
drop(hypervisor_data);
hs_forward_exception();
}
}
}

Expand Down Expand Up @@ -74,5 +77,6 @@ pub fn store_guest_page_fault() {
}
}

drop(hypervisor_data);
hs_forward_exception();
}
2 changes: 1 addition & 1 deletion src/trap/exception/sbi_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sbi_rt::{ConfigFlags, StartFlags, StopFlags};
/// SBI re-ecall
///
/// For now, pass all arguments regardless of the actual number of arguments.
fn sbi_call(ext_id: usize, func_id: usize, args: &[u64; 5]) -> SbiRet {
pub fn sbi_call(ext_id: usize, func_id: usize, args: &[u64; 5]) -> SbiRet {
let (error, value);
unsafe {
core::arch::asm!(
Expand Down

0 comments on commit 62d490a

Please sign in to comment.