All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86emul: simplify LEAVE handling
@ 2016-09-29 13:08 Jan Beulich
  2016-09-29 17:46 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-09-29 13:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

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

There's no 1-byte operand size case to take care of here, and there's
no point doing the first writeback using dst fields - we can read rBP
and write rSP directly.

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
@@ -3130,21 +3130,16 @@ x86_emulate(
 
     case 0xc9: /* leave */
         /* First writeback, to %%esp. */
-        dst.type = OP_REG;
         dst.bytes = (mode_64bit() && (op_bytes == 4)) ? 8 : op_bytes;
-        dst.reg = (unsigned long *)&_regs.esp;
-        dst.val = _regs.ebp;
-
-        /* Flush first writeback, since there is a second. */
         switch ( dst.bytes )
         {
-        case 1: *(uint8_t  *)dst.reg = (uint8_t)dst.val; break;
-        case 2: *(uint16_t *)dst.reg = (uint16_t)dst.val; break;
-        case 4: *dst.reg = (uint32_t)dst.val; break; /* 64b: zero-ext */
-        case 8: *dst.reg = dst.val; break;
+        case 2: *(uint16_t *)&_regs.esp = (uint16_t)_regs.ebp; break;
+        case 4: _regs.esp = (uint32_t)_regs.ebp; break; /* 64b: zero-ext */
+        case 8: _regs.esp = _regs.ebp; break;
         }
 
         /* Second writeback, to %%ebp. */
+        dst.type = OP_REG;
         dst.reg = (unsigned long *)&_regs.ebp;
         if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(dst.bytes),
                               &dst.val, dst.bytes, ctxt, ops)) )




[-- Attachment #2: x86emul-leave-simplify.patch --]
[-- Type: text/plain, Size: 1474 bytes --]

x86emul: simplify LEAVE handling

There's no 1-byte operand size case to take care of here, and there's
no point doing the first writeback using dst fields - we can read rBP
and write rSP directly.

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
@@ -3130,21 +3130,16 @@ x86_emulate(
 
     case 0xc9: /* leave */
         /* First writeback, to %%esp. */
-        dst.type = OP_REG;
         dst.bytes = (mode_64bit() && (op_bytes == 4)) ? 8 : op_bytes;
-        dst.reg = (unsigned long *)&_regs.esp;
-        dst.val = _regs.ebp;
-
-        /* Flush first writeback, since there is a second. */
         switch ( dst.bytes )
         {
-        case 1: *(uint8_t  *)dst.reg = (uint8_t)dst.val; break;
-        case 2: *(uint16_t *)dst.reg = (uint16_t)dst.val; break;
-        case 4: *dst.reg = (uint32_t)dst.val; break; /* 64b: zero-ext */
-        case 8: *dst.reg = dst.val; break;
+        case 2: *(uint16_t *)&_regs.esp = (uint16_t)_regs.ebp; break;
+        case 4: _regs.esp = (uint32_t)_regs.ebp; break; /* 64b: zero-ext */
+        case 8: _regs.esp = _regs.ebp; break;
         }
 
         /* Second writeback, to %%ebp. */
+        dst.type = OP_REG;
         dst.reg = (unsigned long *)&_regs.ebp;
         if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(dst.bytes),
                               &dst.val, dst.bytes, ctxt, ops)) )

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

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

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

* Re: [PATCH] x86emul: simplify LEAVE handling
  2016-09-29 13:08 [PATCH] x86emul: simplify LEAVE handling Jan Beulich
@ 2016-09-29 17:46 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2016-09-29 17:46 UTC (permalink / raw)
  To: Jan Beulich, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]

On 29/09/16 14:08, Jan Beulich wrote:
> There's no 1-byte operand size case to take care of here, and there's
> no point doing the first writeback using dst fields - we can read rBP
> and write rSP directly.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

[-- Attachment #1.2: Type: text/html, Size: 866 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

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

end of thread, other threads:[~2016-09-29 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29 13:08 [PATCH] x86emul: simplify LEAVE handling Jan Beulich
2016-09-29 17:46 ` Andrew Cooper

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.