[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xen-cvs
Subject:    [Xen-changelog] [xen master] x86emul: simplify LEAVE handling
From:       patchbot () xen ! org
Date:       2016-09-30 18:55:53
Message-ID: E1bq2yP-0000uL-BF () xenbits ! xenproject ! org
[Download RAW message or body]

commit 002e3ffb2156a135abbfb57374802922e162c5ae
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri Sep 30 10:01:14 2016 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Sep 30 10:01:14 2016 +0200

    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>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index b1b1883..78b23a0 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3171,21 +3171,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)) )
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xen.org
https://lists.xenproject.org/xen-changelog
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic