From patchwork Fri Sep 30 09:39:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9357881 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 B3AB16075E for ; Fri, 30 Sep 2016 09:41:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4B8029F5B for ; Fri, 30 Sep 2016 09:41:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9938E29F5E; Fri, 30 Sep 2016 09:41:26 +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 4B5E729F5B for ; Fri, 30 Sep 2016 09:41:26 +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 1bpuI4-0002xR-Hr; Fri, 30 Sep 2016 09:39:36 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpuI3-0002xH-RM for xen-devel@lists.xenproject.org; Fri, 30 Sep 2016 09:39:35 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 00/96-03281-6D23EE75; Fri, 30 Sep 2016 09:39:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPIsWRWlGSWpSXmKPExsXS6fjDS/ea0bt wg4VrBCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owPB6azF+yUqZg16zlrA+M68S5GTg4hgTyJ V/PvMoPYvAJ2Erv/z2UFsSUEDCWevr/O1sXIwcEioCrxqDsFJMwmoC7R9mw7K0hYRMBA4tzRJ BCTWUBfYts6FpAKYaDo5n8PWUDCvAKCEn93CIOEmYFmL2nvY5rAyDULITMLSQbC1pJ4+OsWC4 StLbFs4WvmWWDzpSWW/+OAKT848QQjqhIQ21Pi+vc+tgWMHKsYNYpTi8pSi3SNjPWSijLTM0p yEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQIDr56BgXEHY99ev0OMkhxMSqK8skffhgvxJeWn VGYkFmfEF5XmpBYfYpTh4FCS4OUHBrKQYFFqempFWmYOMAZg0hIcPEoiEGne4oLE3OLMdIjUK UZdjnVzb6xlEmLJy89LlRLn/WwIVCQAUpRRmgc3AhaPlxhlpYR5GRkYGIR4ClKLcjNLUOVfMY pzMCoJ874HmcKTmVcCt+kV0BFMQEfkH30DckRJIkJKqoFR5KPy1LNp28MStqla3T7Ivc70SPU Cj/rtxy13rhV+fHP+LAv9k8av2f4qiUSI7fXTEJ61esJlhnNZzwO/xfDKvND5ZaP40H2xdRf/ PQG376oiN17uVFerEtu0+F+7rmB6ct1uf0sOk/T8ZTY3nBiXbCku3fNzumNeScoq7cC9ZSt19 OxqtCWUWIozEg21mIuKEwFfgKBPwgIAAA== X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1475228372!63016607!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 30022 invoked from network); 30 Sep 2016 09:39:33 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-10.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 Sep 2016 09:39:33 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 30 Sep 2016 03:39:31 -0600 Message-Id: <57EE4EF3020000780011415E@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Fri, 30 Sep 2016 03:39:31 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH] x86emul: defer injection of #DB 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 Move the raising of the single step trap until after registers were updated. This should probably have been that way from the beginning, to allow the inject_hw_exception() hook to see updated register state (in case it cares) - it's a trap, after all. Signed-off-by: Jan Beulich x86emul: defer injection of #DB Move the raising of the single step trap until after registers were updated. This should probably have been that way from the beginning, to allow the inject_hw_exception() hook to see updated register state (in case it cares) - it's a trap, after all. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -2267,6 +2267,7 @@ x86_emulate( struct x86_emulate_state state; int rc; uint8_t b, d; + bool tf = ctxt->regs->eflags & EFLG_TF; struct operand src = { .reg = REG_POISON }; struct operand dst = { .reg = REG_POISON }; enum x86_swint_type swint_type; @@ -5161,11 +5162,6 @@ x86_emulate( } no_writeback: - /* Inject #DB if single-step tracing was enabled at instruction start. */ - if ( (ctxt->regs->eflags & EFLG_TF) && (rc == X86EMUL_OKAY) && - (ops->inject_hw_exception != NULL) ) - rc = ops->inject_hw_exception(EXC_DB, -1, ctxt) ? : X86EMUL_EXCEPTION; - /* Commit shadow register state. */ _regs.eflags &= ~EFLG_RF; @@ -5175,6 +5171,10 @@ x86_emulate( *ctxt->regs = _regs; + /* Inject #DB if single-step tracing was enabled at instruction start. */ + if ( tf && (rc == X86EMUL_OKAY) && ops->inject_hw_exception ) + rc = ops->inject_hw_exception(EXC_DB, -1, ctxt) ? : X86EMUL_EXCEPTION; + done: _put_fpu(); put_stub(stub); Reviewed-by: Andrew Cooper --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -2267,6 +2267,7 @@ x86_emulate( struct x86_emulate_state state; int rc; uint8_t b, d; + bool tf = ctxt->regs->eflags & EFLG_TF; struct operand src = { .reg = REG_POISON }; struct operand dst = { .reg = REG_POISON }; enum x86_swint_type swint_type; @@ -5161,11 +5162,6 @@ x86_emulate( } no_writeback: - /* Inject #DB if single-step tracing was enabled at instruction start. */ - if ( (ctxt->regs->eflags & EFLG_TF) && (rc == X86EMUL_OKAY) && - (ops->inject_hw_exception != NULL) ) - rc = ops->inject_hw_exception(EXC_DB, -1, ctxt) ? : X86EMUL_EXCEPTION; - /* Commit shadow register state. */ _regs.eflags &= ~EFLG_RF; @@ -5175,6 +5171,10 @@ x86_emulate( *ctxt->regs = _regs; + /* Inject #DB if single-step tracing was enabled at instruction start. */ + if ( tf && (rc == X86EMUL_OKAY) && ops->inject_hw_exception ) + rc = ops->inject_hw_exception(EXC_DB, -1, ctxt) ? : X86EMUL_EXCEPTION; + done: _put_fpu(); put_stub(stub);