Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litebox_platform_lvbs/src/mshv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod hvcall_vp;
mod mem_integrity;
pub(crate) mod ringbuffer;
pub(crate) mod vsm;
mod vsm_intercept;
pub mod vsm_intercept;
mod vsm_optee_smc;
pub mod vtl1_mem_layout;
pub mod vtl_switch;
Expand Down
8 changes: 7 additions & 1 deletion litebox_platform_lvbs/src/mshv/vsm_intercept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ pub enum InterceptedRegisterName {
Unknown = 0xffff_ffff,
}

/// # Panics
///
/// Panics if:
/// - Failed to get intercept message type
/// - Failed to raise VTL0 GP fault
/// - Intercepted write to unknown MSR/register
pub fn vsm_handle_intercept() {
let simp_page = with_per_cpu_variables_mut(|per_cpu_variables| unsafe {
&mut *per_cpu_variables.hv_simp_page_as_mut_ptr()
Expand Down Expand Up @@ -147,7 +153,7 @@ fn advance_vtl0_rip(int_msg_hdr: &HvInterceptMessageHeader) -> Result<u64, Hyper
}

#[inline]
fn raise_vtl0_gp_fault() -> Result<u64, HypervCallError> {
pub fn raise_vtl0_gp_fault() -> Result<u64, HypervCallError> {
let mut exception = HvPendingExceptionEvent::new();
exception.set_event_pending(true);
exception.set_event_type(0_u8);
Expand Down
4 changes: 4 additions & 0 deletions litebox_platform_lvbs/src/mshv/vtl_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ unsafe extern "C" fn vtl_switch_loop_body() {
}
}

unsafe extern "C" {
pub fn panic_vtl_switch() -> !;
}

fn vtlcall_dispatch(params: &[u64; NUM_VTLCALL_PARAMS]) -> i64 {
let func_id = VsmFunction::try_from(u32::try_from(params[0]).unwrap_or(u32::MAX))
.unwrap_or(VsmFunction::Unknown);
Expand Down
8 changes: 5 additions & 3 deletions litebox_runner_lvbs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

use core::panic::PanicInfo;
use litebox_platform_lvbs::{
arch::{gdt, get_core_id, instrs::hlt_loop, interrupts},
arch::{gdt, get_core_id, interrupts},
debug_serial_println,
host::{bootparam::get_vtl1_memory_info, per_cpu_variables::allocate_per_cpu_variables},
mm::MemoryProvider,
mshv::{
hvcall,
vtl_switch::vtl_switch_loop_entry,
vsm_intercept::raise_vtl0_gp_fault,
vtl_switch::{panic_vtl_switch, vtl_switch_loop_entry},
vtl1_mem_layout::{
PAGE_SIZE, VTL1_INIT_HEAP_SIZE, VTL1_INIT_HEAP_START_PAGE, VTL1_PML4E_PAGE,
VTL1_PRE_POPULATED_MEMORY_SIZE, get_heap_start_address,
Expand Down Expand Up @@ -105,5 +106,6 @@ pub fn run(platform: Option<&'static Platform>) -> ! {
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
serial_println!("{}", info);
hlt_loop()
let _ = raise_vtl0_gp_fault();
unsafe { panic_vtl_switch() }
}