From f063f747c21548329170fd09fd09d391b2277aed Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 16 Dec 2021 19:58:15 -0800 Subject: displacements are stored as unsigned, but are functionally signed ints so multiplying to expand EVEX compressed offsets can overflow, and that needs to be okay. --- src/long_mode/evex.rs | 2 +- src/protected_mode/evex.rs | 2 +- src/real_mode/evex.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/long_mode/evex.rs b/src/long_mode/evex.rs index 7f456e7..5c0967b 100644 --- a/src/long_mode/evex.rs +++ b/src/long_mode/evex.rs @@ -11,7 +11,7 @@ fn isa_has_qwords() -> bool { } fn apply_disp_scale(inst: &mut Instruction) { - inst.disp *= inst.mem_size as u64; + inst.disp = ((inst.disp as i64) * (inst.mem_size as i64)) as u64; } include!("../shared/generated_evex.in"); diff --git a/src/protected_mode/evex.rs b/src/protected_mode/evex.rs index cb0a4ba..2ef91b6 100644 --- a/src/protected_mode/evex.rs +++ b/src/protected_mode/evex.rs @@ -11,7 +11,7 @@ fn isa_has_qwords() -> bool { } fn apply_disp_scale(inst: &mut Instruction) { - inst.disp *= inst.mem_size as u32; + inst.disp = ((inst.disp as i32) * (inst.mem_size as i32)) as u32; } include!("../shared/generated_evex.in"); diff --git a/src/real_mode/evex.rs b/src/real_mode/evex.rs index 9840b35..b63c08d 100644 --- a/src/real_mode/evex.rs +++ b/src/real_mode/evex.rs @@ -11,7 +11,7 @@ fn isa_has_qwords() -> bool { } fn apply_disp_scale(inst: &mut Instruction) { - inst.disp *= inst.mem_size as u32; + inst.disp = ((inst.disp as i32) * (inst.mem_size as i32)) as u32; } include!("../shared/generated_evex.in"); -- cgit v1.1