From 1eb413303469888adca4956f5308267f85d4d24a Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 3 Jul 2024 18:46:35 +0000 Subject: [PATCH] hypervisor: x86: emulator: set IP properly for newly fetched stream The default value of IP is zero. If the decoder's state not set properly, then the guest state is going to be wrong. Signed-off-by: Wei Liu --- hypervisor/src/arch/x86/emulator/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/hypervisor/src/arch/x86/emulator/mod.rs b/hypervisor/src/arch/x86/emulator/mod.rs index 91801f6cd..f61e7886a 100644 --- a/hypervisor/src/arch/x86/emulator/mod.rs +++ b/hypervisor/src/arch/x86/emulator/mod.rs @@ -588,6 +588,7 @@ impl<'a, T: CpuStateManager> Emulator<'a, T> { // Once we have the new stream, we must create a new decoder // and emulate one last instruction from the last decoded IP. decoder = Decoder::new(64, &fetched_insn_stream, DecoderOptions::NONE); + decoder.set_ip(last_decoded_ip); decoder.decode_out(&mut insn); if decoder.last_error() != DecoderError::None { return Err(EmulationError::InstructionFetchingError(anyhow!(