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 <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2024-07-03 18:46:35 +00:00 committed by Liu Wei
parent 9f3bea3e3f
commit 1eb4133034

View File

@ -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!(