mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-08 13:55:19 +00:00
hypervisor: emulator: use wrapping arithmetic
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
1180f757b3
commit
73e1451a12
@ -116,14 +116,14 @@ fn memory_operand_address<T: CpuStateManager>(
|
||||
|
||||
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());
|
||||
|
@ -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))),
|
||||
|
Loading…
Reference in New Issue
Block a user