hypervisor: emulator: Use wrapping add for memory offset

Assume rax is 0xfee003e0 and the displacement is negative 0x60. The effective
address is then 0xfee00380. This is perfectly valid.

Example instruction:
c7 40 a0 00 10 00 00    movl   $0x1000,-0x60(%rax)

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
Philipp Schuster 2023-08-31 14:14:21 +02:00 committed by Rob Bradford
parent 8db85eca1f
commit 556bda74a0

View File

@ -124,7 +124,7 @@ fn memory_operand_address<T: CpuStateManager>(
address += index;
}
address += insn.memory_displacement64();
address = address.wrapping_add(insn.memory_displacement64());
// Translate to a linear address.
state.linearize(insn.memory_segment(), address, write)