fix vmentry success

This commit is contained in:
Masato Imai
2025-04-24 04:58:13 +00:00
parent aec46d128d
commit f4bdb36793
3 changed files with 36 additions and 3 deletions

30
src/vmm/ept.rs Normal file
View File

@ -0,0 +1,30 @@
use bitfield::bitfield;
use x86_64::PhysAddr;
bitfield! {
pub struct EntryBase(u64);
impl Debug;
pub read, set_read: 0;
pub write, set_write: 1;
pub exec_super, set_exec_super: 2;
pub typ, set_typ: 5, 3;
pub ignore_pat, set_ignore_pat: 6;
pub map_memory, set_map_memory: 7;
pub accessed, set_accessed: 8;
pub dirty, set_dirty: 9;
pub exec_user, set_exec_user: 10;
pub phys, set_phys: 63, 12;
}
impl EntryBase {
pub fn present(&self) -> bool {
self.read() || self.write() || self.exec_super()
}
pub fn address(&self) -> PhysAddr {
PhysAddr::new(self.phys() << 12)
}
pub fn new_map_table() {}
}

View File

@ -1,3 +1,4 @@
pub mod ept;
pub mod error; pub mod error;
pub mod register; pub mod register;
pub mod support; pub mod support;

View File

@ -351,9 +351,11 @@ impl VCpu {
result == 0 result == 0
}; };
self.launch_done = true; if !self.launch_done && success {
self.launch_done = true;
}
if success { if !success {
let error = InstructionError::read(); let error = InstructionError::read();
if error.0 != 0 { if error.0 != 0 {
return Err(error); return Err(error);
@ -530,7 +532,7 @@ impl VCpu {
"pop r14", "pop r14",
"pop r15", "pop r15",
"pop rbp", "pop rbp",
"mov rax, 1", "mov rax, 0",
"ret", "ret",
const RAX_OFFSET, const RAX_OFFSET,
const RCX_OFFSET, const RCX_OFFSET,