mirror of
https://github.com/mii443/nel_os.git
synced 2025-08-22 16:15:38 +00:00
EPT
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use bitfield::bitfield;
|
||||
use x86_64::{
|
||||
structures::paging::{FrameAllocator, PhysFrame, Size4KiB},
|
||||
@ -67,6 +66,9 @@ impl EPT {
|
||||
lv4_entry.set_phys(frame.start_address().as_u64() >> 12);
|
||||
lv4_entry.set_map_memory(false);
|
||||
lv4_entry.set_typ(0);
|
||||
lv4_entry.set_read(true);
|
||||
lv4_entry.set_write(true);
|
||||
lv4_entry.set_exec_super(true);
|
||||
table_ptr
|
||||
} else {
|
||||
let frame =
|
||||
@ -84,6 +86,9 @@ impl EPT {
|
||||
lv3_entry.set_phys(frame.start_address().as_u64() >> 12);
|
||||
lv3_entry.set_map_memory(false);
|
||||
lv3_entry.set_typ(0);
|
||||
lv3_entry.set_read(true);
|
||||
lv3_entry.set_write(true);
|
||||
lv3_entry.set_exec_super(true);
|
||||
table_ptr
|
||||
} else {
|
||||
let frame =
|
||||
@ -94,6 +99,10 @@ impl EPT {
|
||||
let lv2_entry = &mut lv2_table[lv2_index as usize];
|
||||
lv2_entry.set_phys(hpa >> 12);
|
||||
lv2_entry.set_map_memory(true);
|
||||
lv2_entry.set_typ(0);
|
||||
lv2_entry.set_read(true);
|
||||
lv2_entry.set_write(true);
|
||||
lv2_entry.set_exec_super(true);
|
||||
info!("{:#x}", lv2_entry as *const _ as u64);
|
||||
|
||||
Ok(())
|
||||
|
@ -10,11 +10,12 @@ use x86_64::VirtAddr;
|
||||
use core::{
|
||||
arch::{asm, naked_asm},
|
||||
mem::offset_of,
|
||||
sync::atomic::Ordering,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
info,
|
||||
memory::BootInfoFrameAllocator,
|
||||
memory::{self, BootInfoFrameAllocator},
|
||||
vmm::vmcs::{
|
||||
DescriptorType, EntryControls, Granularity, PrimaryExitControls,
|
||||
PrimaryProcessorBasedVmExecutionControls, SecondaryProcessorBasedVmExecutionControls,
|
||||
@ -380,7 +381,8 @@ impl VCpu {
|
||||
info!("Entering VM loop");
|
||||
|
||||
let guest_ptr = Self::guest as u64;
|
||||
let guest_addr = self.ept.get_phys_addr(0).unwrap();
|
||||
let guest_addr = self.ept.get_phys_addr(0).unwrap()
|
||||
+ memory::PHYSICAL_MEMORY_OFFSET.load(Ordering::Relaxed);
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(guest_ptr as *const u8, guest_addr as *mut u8, 200);
|
||||
vmwrite(vmcs::guest::RIP, 0).unwrap();
|
||||
|
Reference in New Issue
Block a user