Skip to content

Commit ea17e93

Browse files
authored
[feat] expose invalid_ept api (#29)
1 parent 3034c6c commit ea17e93

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ cfg_if::cfg_if! {
2626
mod vmx;
2727
use vmx as vender;
2828
pub use vmx::{VmxExitInfo, VmxExitReason, VmxInterruptInfo, VmxIoExitInfo};
29+
pub use vmx::invalid_ept;
2930

3031
pub use vender::VmxArchVCpu;
3132
pub use vender::VmxArchPerCpuState;

src/vmx/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub use self::percpu::VmxPerCpuState as VmxArchPerCpuState;
1313
pub use self::vcpu::VmxVcpu as VmxArchVCpu;
1414
pub use self::vmcs::{VmxExitInfo, VmxInterruptInfo, VmxIoExitInfo};
1515

16+
pub use self::vcpu::invalid_ept;
17+
1618
/// Return if current platform support virtualization extension.
1719
pub fn has_hardware_support() -> bool {
1820
if let Some(feature) = raw_cpuid::CpuId::new().get_feature_info() {

src/vmx/vcpu.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
482482
}
483483

484484
fn setup_vmcs_host(&self) -> AxResult {
485+
// warn!("Host IA32_PAT {:#x}", Msr::IA32_PAT.read());
486+
// warn!("Host IA32_EFER {:#x}", Msr::IA32_EFER.read());
487+
485488
VmcsHost64::IA32_PAT.write(Msr::IA32_PAT.read())?;
486489
VmcsHost64::IA32_EFER.write(Msr::IA32_EFER.read())?;
487490

@@ -1647,3 +1650,8 @@ impl<H: AxVCpuHal> AxVcpuAccessGuestState for VmxVcpu<H> {
16471650
warn!("Dumping VmxVcpu {:#x?}", self);
16481651
}
16491652
}
1653+
1654+
pub fn invalid_ept(eptp: EPTPointer) -> AxResult<()> {
1655+
use super::instructions::{InvEptType, invept};
1656+
unsafe { invept(InvEptType::SingleContext, eptp.bits()).map_err(as_axerr) }
1657+
}

0 commit comments

Comments
 (0)