Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
This would cause a crash due to pre-alloc Pts for hooks
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
memN0ps committed Jul 31, 2024
1 parent 83a6c64 commit 9ebae16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hypervisor/src/intel/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
1 change: 1 addition & 0 deletions hypervisor/src/intel/ept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ impl Ept {
pub fn create_eptp_with_wb_and_4lvl_walk(&self) -> Result<u64, HypervisorError> {
// 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;
Expand Down

0 comments on commit 9ebae16

Please sign in to comment.