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

Commit

Permalink
Should PhysicalAlloc not KernelAlloc for Page Tables
Browse files Browse the repository at this point in the history
  • Loading branch information
memN0ps committed Dec 21, 2023
1 parent 67b113b commit 0cc1870
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hypervisor/src/intel/vmcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Vmcs {
/// * `context` - Context containing the host's register states.
/// * `host_descriptor_table` - Descriptor tables for the host.
#[rustfmt::skip]
pub fn setup_host_registers_state(context: &CONTEXT, host_descriptor_table: &Box<DescriptorTables, KernelAlloc>, host_paging: &Box<PageTables, KernelAlloc>) {
pub fn setup_host_registers_state(context: &CONTEXT, host_descriptor_table: &Box<DescriptorTables, KernelAlloc>, host_paging: &Box<PageTables, PhysicalAllocator>) {
unsafe { vmwrite(vmcs::host::CR0, controlregs::cr0().bits() as u64) };
vmwrite(vmcs::host::CR3, PhysicalAddress::pa_from_va(host_paging.as_ref() as *const _ as u64));
unsafe { vmwrite(vmcs::host::CR4, controlregs::cr4().bits() as u64) };
Expand Down
6 changes: 3 additions & 3 deletions hypervisor/src/intel/vmx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ pub struct Vmx {
pub host_rsp: Box<VmStack, KernelAlloc>,

/// Virtual address of the host's paging structures, aligned to a 4-KByte boundary.
/// Allocated using `ExAllocatePool` or `ExAllocatePoolWithTag`.
pub host_paging: Box<PageTables, KernelAlloc>,
/// Allocated using `MmAllocateContiguousMemorySpecifyCacheNode`.
pub host_paging: Box<PageTables, PhysicalAllocator>,

/// Virtual address of the guest's extended page-table structure, aligned to a 4-KByte boundary.
/// Allocated using `MmAllocateContiguousMemorySpecifyCacheNode`.
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Vmx {
let mut guest_descriptor_table = unsafe { Box::try_new_zeroed_in(KernelAlloc)?.assume_init() };
let mut host_descriptor_table = unsafe { Box::try_new_zeroed_in(KernelAlloc)?.assume_init() };
let host_rsp = unsafe { Box::try_new_zeroed_in(KernelAlloc)?.assume_init() };
let mut host_paging: Box<PageTables, KernelAlloc> = unsafe { Box::try_new_zeroed_in(KernelAlloc)?.assume_init() };
let mut host_paging: Box<PageTables, PhysicalAllocator> = unsafe { Box::try_new_zeroed_in(PhysicalAllocator)?.assume_init() };
let mut ept: Box<Ept, PhysicalAllocator> = unsafe { Box::try_new_zeroed_in(PhysicalAllocator)?.assume_init() };
let guest_registers = GuestRegisters::default();

Expand Down

0 comments on commit 0cc1870

Please sign in to comment.