[XEN] Fix EA calculation for POP <rm> when stack pointer is used as
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 5 Jan 2007 14:44:58 +0000 (14:44 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 5 Jan 2007 14:44:58 +0000 (14:44 +0000)
base of the EA calculation. It should be used *post* increment.

Original patch from Jan Beulich <jbeulich@novell.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/x86_emulate.c

index 323626ce0f85ab55382edeb27056dd0eba51744a..6ad67874ad21fb4bc5df2e6f54af291ed40f4a8e 100644 (file)
@@ -616,6 +616,11 @@ x86_emulate(
                 ea.mem.off <<= (sib >> 6) & 3;
                 if ( (modrm_mod == 0) && ((sib_base & 7) == 5) )
                     ea.mem.off += insn_fetch_type(int32_t);
+                else if ( (sib_base == 4) && !twobyte && (b == 0x8f) )
+                    /* POP <rm> must have its EA calculated post increment. */
+                    ea.mem.off += _regs.esp +
+                        (((mode == X86EMUL_MODE_PROT64) && (op_bytes == 4))
+                         ? 8 : op_bytes);
                 else
                     ea.mem.off += *(long*)decode_register(sib_base, &_regs, 0);
             }