EPTP
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
use modular_bitfield::{
|
use modular_bitfield::{
|
||||||
bitfield,
|
bitfield,
|
||||||
prelude::{B3, B53},
|
prelude::{B3, B53, B56},
|
||||||
};
|
};
|
||||||
use x86_64::{
|
use x86_64::{
|
||||||
structures::paging::{FrameAllocator, PhysFrame, Size4KiB},
|
structures::paging::{FrameAllocator, PhysFrame, Size4KiB},
|
||||||
@ -283,6 +283,34 @@ impl EPT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bitfield]
|
||||||
|
#[repr(u64)]
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct EPTP {
|
||||||
|
pub typ: B3,
|
||||||
|
pub level: B3,
|
||||||
|
pub dirty_accessed: bool,
|
||||||
|
pub enforce_access_rights: bool,
|
||||||
|
pub phys: B56,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EPTP {
|
||||||
|
pub fn init(lv4_table: &PhysFrame) -> Self {
|
||||||
|
EPTP::new()
|
||||||
|
.with_typ(6)
|
||||||
|
.with_level(3)
|
||||||
|
.with_dirty_accessed(true)
|
||||||
|
.with_enforce_access_rights(false)
|
||||||
|
.with_phys(lv4_table.start_address().as_u64() >> 12)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_lv4_table(&self) -> &mut [EntryBase; 512] {
|
||||||
|
let table_ptr = self.phys() << 12;
|
||||||
|
|
||||||
|
unsafe { &mut *(table_ptr as *mut [EntryBase; 512]) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[bitfield]
|
#[bitfield]
|
||||||
#[repr(u64)]
|
#[repr(u64)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
Reference in New Issue
Block a user