diff --git a/hypervisor/src/arch/x86/emulator/instructions/mod.rs b/hypervisor/src/arch/x86/emulator/instructions/mod.rs index e04a072f3..c2d39aea0 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/mod.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/mod.rs @@ -116,14 +116,14 @@ fn memory_operand_address( if insn.memory_base() != iced_x86::Register::None { let base: u64 = state.read_reg(insn.memory_base())?; - address += base; + address = address.wrapping_add(base); } if insn.memory_index() != iced_x86::Register::None { let mut index: u64 = state.read_reg(insn.memory_index())?; - index *= insn.memory_index_scale() as u64; + index = index.wrapping_mul(insn.memory_index_scale() as u64); - address += index; + address = address.wrapping_add(index); } address = address.wrapping_add(insn.memory_displacement64()); diff --git a/hypervisor/src/arch/x86/emulator/mod.rs b/hypervisor/src/arch/x86/emulator/mod.rs index 160d07a45..2a3125eb8 100644 --- a/hypervisor/src/arch/x86/emulator/mod.rs +++ b/hypervisor/src/arch/x86/emulator/mod.rs @@ -185,7 +185,7 @@ pub trait CpuStateManager: Clone { ))); } - Ok(logical_addr + segment_register.base) + Ok(logical_addr.wrapping_add(segment_register.base)) } _ => Err(PlatformError::UnsupportedCpuMode(anyhow!("{:?}", mode))),