All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/emul: only emulate possibly operand sizes for POPA
@ 2012-11-07 16:08 Jan Beulich
  2012-11-07 17:10 ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2012-11-07 16:08 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]

This opcode neither support 1-byte operands, nor does it support 8-byte
ones (since the opcode is undefined in 64-bit mode). Simplify the code
accordingly.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1996,13 +1996,10 @@ x86_emulate(
             if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes),
                                   &dst.val, op_bytes, ctxt, ops)) != 0 )
                 goto done;
-            switch ( op_bytes )
-            {
-            case 1: *(uint8_t  *)regs[i] = (uint8_t)dst.val; break;
-            case 2: *(uint16_t *)regs[i] = (uint16_t)dst.val; break;
-            case 4: *regs[i] = (uint32_t)dst.val; break; /* 64b: zero-ext */
-            case 8: *regs[i] = dst.val; break;
-            }
+            if ( op_bytes != 2 )
+                *regs[i] = (uint32_t)dst.val; /* 64b: zero-ext */
+            else
+                *(uint16_t *)regs[i] = (uint16_t)dst.val;
         }
         break;
     }




[-- Attachment #2: x86-emul-popa-sizes.patch --]
[-- Type: text/plain, Size: 1128 bytes --]

x86/emul: only emulate possibly operand sizes for POPA

This opcode neither support 1-byte operands, nor does it support 8-byte
ones (since the opcode is undefined in 64-bit mode). Simplify the code
accordingly.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1996,13 +1996,10 @@ x86_emulate(
             if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes),
                                   &dst.val, op_bytes, ctxt, ops)) != 0 )
                 goto done;
-            switch ( op_bytes )
-            {
-            case 1: *(uint8_t  *)regs[i] = (uint8_t)dst.val; break;
-            case 2: *(uint16_t *)regs[i] = (uint16_t)dst.val; break;
-            case 4: *regs[i] = (uint32_t)dst.val; break; /* 64b: zero-ext */
-            case 8: *regs[i] = dst.val; break;
-            }
+            if ( op_bytes != 2 )
+                *regs[i] = (uint32_t)dst.val; /* 64b: zero-ext */
+            else
+                *(uint16_t *)regs[i] = (uint16_t)dst.val;
         }
         break;
     }

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-08  9:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-07 16:08 [PATCH] x86/emul: only emulate possibly operand sizes for POPA Jan Beulich
2012-11-07 17:10 ` Keir Fraser
2012-11-08  7:34   ` Jan Beulich
2012-11-08  7:48     ` Keir Fraser
2012-11-08  8:34       ` Jan Beulich
2012-11-08  9:08         ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.