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

Commit 9ebae16

Browse files
committed
This would cause a crash due to pre-alloc Pts for hooks
- 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.
1 parent 83a6c64 commit 9ebae16

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

hypervisor/src/intel/addresses.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,14 @@ impl PhysicalAddress {
8484
let (pml4_address, _, _) = Ept::decode_eptp(vmcs_eptp)?;
8585
trace!("EPT PML4 Address: {:#x}", pml4_address);
8686

87-
let host_pa = unsafe { Ept::translate_guest_pa_to_host_pa(pml4_address, guest_pa)? };
88-
trace!("Guest PA: {:#x} -> Host PA: {:#x}", guest_pa, host_pa);
87+
// Note: This may cause a crash at `!pt_entry.readable()` because the hypervisor has pre-allocated page tables
88+
// 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.
89+
// The hypervisor maps everything as 2MB pages. The hooked pages are split and stored in the pre-allocated Pt,
90+
// which are usually passed as a parameter, those are not stored in the EPT structure.
91+
// 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.
92+
// let host_pa = unsafe { Ept::translate_guest_pa_to_host_pa(pml4_address, guest_pa)? };
93+
// trace!("Guest PA: {:#x} -> Host PA: {:#x}", guest_pa, host_pa);
8994

90-
Ok(host_pa)
95+
Ok(guest_pa)
9196
}
9297
}

hypervisor/src/intel/ept.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ impl Ept {
526526
pub fn create_eptp_with_wb_and_4lvl_walk(&self) -> Result<u64, HypervisorError> {
527527
// Get the virtual address of the PML4 table for EPT.
528528
let addr = addr_of!(self.pml4) as u64;
529+
trace!("EPT PML4 (self) address: {:#x}", addr);
529530

530531
// Get the physical address of the PML4 table for EPT.
531532
let ept_pml4_base_addr = addr;

0 commit comments

Comments
 (0)