From patchwork Mon Jun 20 11:58:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9187277 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 15D6E60756 for ; Mon, 20 Jun 2016 12:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000C12237D for ; Mon, 20 Jun 2016 12:00:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8CFA271FD; Mon, 20 Jun 2016 12:00:18 +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 6F03D2237D for ; Mon, 20 Jun 2016 12:00:18 +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 1bExqQ-0001A2-0p; Mon, 20 Jun 2016 11:58:22 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bExqP-00019v-B0 for xen-devel@lists.xenproject.org; Mon, 20 Jun 2016 11:58:21 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id C2/FC-09256-C5AD7675; Mon, 20 Jun 2016 11:58:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsXS6fjDSzfmVnq 4wa5ODovvWyYzOTB6HP5whSWAMYo1My8pvyKBNWNnywWWgtMyFTPPb2RrYOwT7WLk5BASyJM4 dHY3C4jNK2An8fjzO3YQW0LAUGLf/FVsXYwcHCwCqhInN/CChNkE1CXanm1nBQmLCBhInDuaB GIyC+hLbFsHNkRYwE1iwfx+ZojhdhIb909gArE5BewlphxeAzaQV0BQ4u8OYYhOO4mdW7gnMP LMQkjMQkjMAmplFtCSePjrFguErS2xbOFrZogSaYnl/zggTAeJgwcyUFWA2N4Sizu/sy5g5Fj FqF6cWlSWWqRrqJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERigDECwg3Hnc6dD jJIcTEqivDbF6eFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHg5bgLlBItS01Mr0jJzgLECk5bg4 FES4bUDSfMWFyTmFmemQ6ROMSpKifMeuwGUEABJZJTmwbXB4vMSo6yUMC8j0CFCPAWpRbmZJa jyrxjFORiVhHl5QcbzZOaVwE1/BbSYCWjxsn6wxSWJCCmpBsa4p32tOh9i/jzZ1Fdc7fP+iu1 fvbAe31DWvzpCy2cvU5k44ZjbuaOK+Zb3cj8f37o6JdNwlprNqpLS2F0TDmV3Jq45o1LLfcLv xbtbrby/LrLfu6JmJPlrn9tO/3+s6j6nPvut08xmff531YcFi3en96V0BVScOlVnEzJzeaR0w 3PX1ujHC44osRRnJBpqMRcVJwIAGMZYRcoCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1466423898!19817881!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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50551 invoked from network); 20 Jun 2016 11:58:19 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-5.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Jun 2016 11:58:19 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 20 Jun 2016 05:58:17 -0600 Message-Id: <5767F66902000078000F6ABF@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Mon, 20 Jun 2016 05:58:01 -0600 From: "Jan Beulich" To: "xen-devel" References: <5767F35B02000078000F6A88@prv-mh.provo.novell.com> In-Reply-To: <5767F35B02000078000F6A88@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH 2/4] x86emul: use (locally) consistent exit mechanisms 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 At least similar code should use similar exit mechanisms (return vs goto). Signed-off-by: Jan Beulich --- RFC reason: There are many more paths where we could return directly, avoiding the _put_fpu() and put_stub(). Otoh arguably the two existing return-s around the changes below could also be changed to "goto done" to restore consistency. Subsequently we may then want to consider to reduce the number of "goto done" by checking rc right after at least the main switch() statements. x86emul: use (locally) consistent exit mechanisms At least similar code should use similar exit mechanisms (return vs goto). Signed-off-by: Jan Beulich --- RFC reason: There are many more paths where we could return directly, avoiding the _put_fpu() and put_stub(). Otoh arguably the two existing return-s around the changes below could also be changed to "goto done" to restore consistency. Subsequently we may then want to consider to reduce the number of "goto done" by checking rc right after at least the main switch() statements. --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -2112,7 +2112,7 @@ x86_emulate( op_bytes = 8; if ( (rc = ops->write(x86_seg_ss, sp_pre_dec(op_bytes), ®.sel, op_bytes, ctxt)) != 0 ) - goto done; + return rc; break; } @@ -2125,9 +2125,8 @@ x86_emulate( if ( mode_64bit() && (op_bytes == 4) ) op_bytes = 8; if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes), - &dst.val, op_bytes, ctxt, ops)) != 0 ) - goto done; - if ( (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 ) + &dst.val, op_bytes, ctxt, ops)) != 0 || + (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 ) return rc; break; --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -2112,7 +2112,7 @@ x86_emulate( op_bytes = 8; if ( (rc = ops->write(x86_seg_ss, sp_pre_dec(op_bytes), ®.sel, op_bytes, ctxt)) != 0 ) - goto done; + return rc; break; } @@ -2125,9 +2125,8 @@ x86_emulate( if ( mode_64bit() && (op_bytes == 4) ) op_bytes = 8; if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes), - &dst.val, op_bytes, ctxt, ops)) != 0 ) - goto done; - if ( (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 ) + &dst.val, op_bytes, ctxt, ops)) != 0 || + (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 ) return rc; break;