diff --git a/hypervisor/src/intel/addresses.rs b/hypervisor/src/intel/addresses.rs index 94ffb71..bd1732c 100644 --- a/hypervisor/src/intel/addresses.rs +++ b/hypervisor/src/intel/addresses.rs @@ -84,9 +84,14 @@ impl PhysicalAddress { let (pml4_address, _, _) = Ept::decode_eptp(vmcs_eptp)?; trace!("EPT PML4 Address: {:#x}", pml4_address); - let host_pa = unsafe { Ept::translate_guest_pa_to_host_pa(pml4_address, guest_pa)? }; - trace!("Guest PA: {:#x} -> Host PA: {:#x}", guest_pa, host_pa); + // Note: This may cause a crash at `!pt_entry.readable()` because the hypervisor has pre-allocated page tables + // in the hook_manager that are not passed to this function. We're attempting to translate a guest physical address to a host physical address using the EPT. + // The hypervisor maps everything as 2MB pages. The hooked pages are split and stored in the pre-allocated Pt, + // which are usually passed as a parameter, those are not stored in the EPT structure. + // This translation is not required in a 1:1 mapping but is done for demonstration purposes and in case changes are made to the Paging/EPT. + // let host_pa = unsafe { Ept::translate_guest_pa_to_host_pa(pml4_address, guest_pa)? }; + // trace!("Guest PA: {:#x} -> Host PA: {:#x}", guest_pa, host_pa); - Ok(host_pa) + Ok(guest_pa) } } diff --git a/hypervisor/src/intel/ept.rs b/hypervisor/src/intel/ept.rs index 909a275..71a1cff 100644 --- a/hypervisor/src/intel/ept.rs +++ b/hypervisor/src/intel/ept.rs @@ -526,6 +526,7 @@ impl Ept { pub fn create_eptp_with_wb_and_4lvl_walk(&self) -> Result { // Get the virtual address of the PML4 table for EPT. let addr = addr_of!(self.pml4) as u64; + trace!("EPT PML4 (self) address: {:#x}", addr); // Get the physical address of the PML4 table for EPT. let ept_pml4_base_addr = addr;