From 251434862f0ad1670a873423bbc9e72d73fc12fa Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Sat, 28 Nov 2020 00:35:58 +0100 Subject: [PATCH] hypervisor: emulator: Fix logic bug in MockVMM emulate_first_insn() really means we want only the first instruction to be emulated. Signed-off-by: Samuel Ortiz --- hypervisor/src/arch/x86/emulator/instructions/mov.rs | 4 ++-- hypervisor/src/arch/x86/emulator/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hypervisor/src/arch/x86/emulator/instructions/mov.rs b/hypervisor/src/arch/x86/emulator/instructions/mov.rs index 5983c6b36..9692cc487 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/mov.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/mov.rs @@ -525,7 +525,7 @@ mod tests { 0x48, 0x8b, 0x58, 0x10, // mov rbx, qword ptr [rax+10h] ]; let mut vmm = MockVMM::new(ip, hashmap![], Some((rax + displacement, &memory))); - vmm.emulate_first_insn(cpu_id, &insn); + vmm.emulate_insn(cpu_id, &insn, Some(2)); let rbx: u64 = vmm .cpu_state(cpu_id) @@ -554,7 +554,7 @@ mod tests { let mut vmm = MockVMM::new(ip, hashmap![], Some((rax + displacement, &memory))); // Only run the first instruction. - vmm.emulate_insn(cpu_id, &insn, Some(1)); + vmm.emulate_first_insn(cpu_id, &insn); assert_eq!(ip + 7 as u64, vmm.cpu_state(cpu_id).unwrap().ip()); diff --git a/hypervisor/src/arch/x86/emulator/mod.rs b/hypervisor/src/arch/x86/emulator/mod.rs index 2b7f7e935..6a54e1173 100644 --- a/hypervisor/src/arch/x86/emulator/mod.rs +++ b/hypervisor/src/arch/x86/emulator/mod.rs @@ -665,7 +665,7 @@ mod mock_vmm { } pub fn emulate_first_insn(&mut self, cpu_id: usize, insn: &[u8]) { - self.emulate_insn(cpu_id, insn, None) + self.emulate_insn(cpu_id, insn, Some(1)) } }