From 3ad8d24943cb2739e930bb0b37af1d85c53d01bc Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 27 Jun 2024 22:32:30 +0000 Subject: [PATCH] hypervisor: x86: emulator: fix a variable Comparing RAX with RIP makes no logical sense other than RIP happens to be the correct value. Use `target_rax` instead. Signed-off-by: Wei Liu --- hypervisor/src/arch/x86/emulator/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hypervisor/src/arch/x86/emulator/mod.rs b/hypervisor/src/arch/x86/emulator/mod.rs index 4ccb97bdc..039f2f99e 100644 --- a/hypervisor/src/arch/x86/emulator/mod.rs +++ b/hypervisor/src/arch/x86/emulator/mod.rs @@ -778,6 +778,7 @@ mod tests { // mov rbx, qword ptr [rax+10h] // Test with a first instruction truncated. fn test_fetch_first_instruction() { + let target_rax: u64 = 0x1000; let ip: u64 = 0x1000; let cpu_id = 0; let memory = [ @@ -802,7 +803,7 @@ mod tests { .unwrap() .read_reg(Register::RAX) .unwrap(); - assert_eq!(rax, ip); + assert_eq!(rax, target_rax); } #[test]