]> xenbits.xensource.com Git - xen.git/commitdiff
x86emul: fix XOP decode
authorJan Beulich <jbeulich@suse.com>
Mon, 24 Oct 2016 15:33:30 +0000 (17:33 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 24 Oct 2016 15:33:30 +0000 (17:33 +0200)
Commit f09902c456 ("x86emul: add XOP decoding") ended up overwriting b
prior to the last use of its previously stored value. SLightly defer
fetching the main opcode byte.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/x86_emulate/x86_emulate.c

index a6217512f670c1b4ded9e1790ea3352a5a9db380..a1821d5666caaae6c16559ab52dada31bb81b4ba 100644 (file)
@@ -2075,11 +2075,10 @@ x86_decode(
                 if ( mode_64bit() && !vex.r )
                     rex_prefix |= REX_R;
 
-                b = insn_fetch_type(uint8_t);
-                opcode |= b | MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK);
                 ext = vex.opcx;
                 if ( b != 0x8f )
                 {
+                    b = insn_fetch_type(uint8_t);
                     switch ( ext )
                     {
                     case vex_0f:
@@ -2102,6 +2101,7 @@ x86_decode(
                 else if ( ext < ext_8f08 +
                                 sizeof(xop_table) / sizeof(*xop_table) )
                 {
+                    b = insn_fetch_type(uint8_t);
                     opcode |= MASK_INSR(0x8f08 + ext - ext_8f08,
                                         X86EMUL_OPC_EXT_MASK);
                     d = xop_table[ext - ext_8f08];
@@ -2112,6 +2112,8 @@ x86_decode(
                     goto done;
                 }
 
+                opcode |= b | MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK);
+
                 modrm = insn_fetch_type(uint8_t);
                 modrm_mod = (modrm & 0xc0) >> 6;