diff --git a/kernel/src/fuzz_session.rs b/kernel/src/fuzz_session.rs index 1d5063b..526fdff 100644 --- a/kernel/src/fuzz_session.rs +++ b/kernel/src/fuzz_session.rs @@ -987,6 +987,24 @@ impl<'a> Worker<'a> { self.stats.vm_cycles += vm_cycles; match vmexit { + VmExit::CpuId { inst_len } => { + let rax = self.reg(Register::Rax) as u32; + let rcx = self.reg(Register::Rcx) as u32; + + // Take the host cpuid and write it into the guest + unsafe{ + let (eax, ebx, ecx, edx) = cpu::cpuid(rax,rcx); + self.set_reg(Register::Eax, eax as u64); + self.set_reg(Register::Ebx, ebx as u64); + self.set_reg(Register::Ecx, ecx as u64); + self.set_reg(Register::Edx, edx as u64); + } + + // Advance RIP to next instruction + let rip = self.reg(Register::Rip); + self.set_reg(Register::Rip, rip.wrapping_add(inst_len)); + continue 'vm_loop; + } VmExit::Rdtsc { inst_len } => { let tsc = self.backing.vm.guest_regs.tsc; self.set_reg(Register::Rax, (tsc >> 0) & 0xffffffff); diff --git a/kernel/src/vtx.rs b/kernel/src/vtx.rs index fac4f17..556eeaa 100644 --- a/kernel/src/vtx.rs +++ b/kernel/src/vtx.rs @@ -1141,6 +1141,9 @@ pub enum CpuMode { /// Virtual machine exit reason #[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)] pub enum VmExit { + CpuId { + inst_len: u64, + }, VmCall, InterruptWindow, Io, @@ -1954,6 +1957,10 @@ impl Vm { } 1 => VmExit::ExternalInterrupt, 7 => VmExit::InterruptWindow, + 10 => { + let inst_len = self.reg(Register::ExitInstructionLength); + VmExit::CpuId { inst_len } + } 16 => { let inst_len = self.reg(Register::ExitInstructionLength); VmExit::Rdtsc { inst_len }