From patchwork Thu Sep 29 13:08:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9356425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECE4A600C8 for ; Thu, 29 Sep 2016 13:11:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF94229A04 for ; Thu, 29 Sep 2016 13:11:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3EDC29A0A; Thu, 29 Sep 2016 13:11:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84A8629A04 for ; Thu, 29 Sep 2016 13:11:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpb54-0000HK-Sj; Thu, 29 Sep 2016 13:08:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpb53-0000H7-W2 for xen-devel@lists.xenproject.org; Thu, 29 Sep 2016 13:08:54 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id BD/D5-11175-5621DE75; Thu, 29 Sep 2016 13:08:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRWlGSWpSXmKPExsXS6fjDSzdF6G2 4wa/Puhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bD49NYCppkKj48v8TUwHhRtIuRk0NIIE/i 9d/FTCA2r4CdxP8Jc1lBbAkBQ4mn76+zgdgsAqoSu3c8AqthE1CXaHu2HaiGg0NEwEDi3NEkE JNZQF9i2zoWkAphoM4LP74wgoR5BQQl/u4QBgkzAw1vmfuVbQIj1yyEzCwkGQhbS+Lhr1ssEL a2xLKFr5lngc2Xllj+jwMibCtxt/sNE6YSD4k1rxUXMHKsYlQvTi0qSy3SNdJLKspMzyjJTcz M0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMOwYg2MG47K/TIUZJDiYlUd6r896EC/El5adUZiQW Z8QXleakFh9ilOHgUJLgnSf4NlxIsCg1PbUiLTMHGAEwaQkOHiUR3lkgad7igsTc4sx0iNQpR kUpcd49IAkBkERGaR5cGyzqLjHKSgnzMgIdIsRTkFqUm1mCKv+KUZyDUUmYNxtkCk9mXgnc9F dAi5mAFucffQOyuCQRISXVwBg+++HR3HeN7pd3P9n03956tU7Sdh52uYOGNrxRMWF9vw+zlbX fXV3eLC2eU842eWtViVUz9/7WO4v5ixS+CO1VY9lSVSqRH+QzsWZW4q7TDlFP39t+CZueeyrL uepp3ey2630FuxTd7bJ+8v6oDTXvvfvAklswUPwrf4ySddF53Vd2FrsdlFiKMxINtZiLihMBw mVHXrUCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1475154530!49796070!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38956 invoked from network); 29 Sep 2016 13:08:52 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Sep 2016 13:08:52 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 29 Sep 2016 07:08:50 -0600 Message-Id: <57ED2E810200007800113BE0@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Thu, 29 Sep 2016 07:08:49 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH] x86emul: simplify LEAVE handling X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 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 --- 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)) ) Reviewed-by: Andrew Cooper --- 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)) )