From patchwork Mon Sep 25 12:03:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Ovidiu PIRCALABU X-Patchwork-Id: 9969817 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 C32FB6038E for ; Mon, 25 Sep 2017 12:05:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B586328C73 for ; Mon, 25 Sep 2017 12:05:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA60228C75; Mon, 25 Sep 2017 12:05:36 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 8605B28C73 for ; Mon, 25 Sep 2017 12:05:35 +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 1dwS6e-0007pb-AI; Mon, 25 Sep 2017 12:03:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwS6c-0007oa-Lq for xen-devel@lists.xen.org; Mon, 25 Sep 2017 12:03:22 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id CC/55-01754-980F8C95; Mon, 25 Sep 2017 12:03:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRWlGSWpSXmKPExsUSfTyjVbfzw4l Ig54WLoslHxezODB6HN39mymAMYo1My8pvyKBNeP+q5lMBes0Kpa8mMDcwDhBoYuRk4NZwFqi 918zYxcjFweLwCwWiYm/djJDOBNYJDZ++sUIUiUk4CEx7/RFsCohgQWMEu+PdrDDJKZcXsAGk VjMKPHj4UVWkASbgJHEkmVvwYpEBKQlrn2+DNbNLPCGSeLd95lgY4UF/CWet55lA7FZBFQlnn /9xgJi8wp4Styc2wnWLCEgJ3HzXCcziM0p4CWxa9UpZojNnhJvzx5nmsAIdA/DKkaN4tSistQ iXUMDvaSizPSMktzEzBwgz1QvN7W4ODE9NScxqVgvOT93EyMwvBiAYAfjmqnOhxglOZiURHnv 8p2IFOJLyk+pzEgszogvKs1JLT7EKMPBoSTB+/Q9UE6wKDU9tSItMwcY6DBpCQ4eJRHe/SBp3 uKCxNzizHSI1ClGXY6Om3f/MAmx5OXnpUqJ8zaCFAmAFGWU5sGNgEXdJUZZKWFeRqCjhHgKUo tyM0tQ5V8xinMwKgnzdoFM4cnMK4Hb9AroCCagI3qngh1RkoiQkmpgFFgxNT3gi9cJ7YOHD35 Tj6oU+nD25bznW75bXzttJ9lpHPI1fWqFqGXklwczQ093G6ov0rtiasAeU1fYOL91Uh1vTsMz Zytb2zWZe0+7HGpYN33diu46o1PlK2WO6afeadR4f8eCc9Gx1ZIH7km4unkxzP1tx3jr4SWpK C4R16nzHoV8rX2pp8RSnJFoqMVcVJwIAKZTQEG1AgAA X-Env-Sender: ppircalabu@bitdefender.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1506341000!93104908!1 X-Originating-IP: [91.199.104.133] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35795 invoked from network); 25 Sep 2017 12:03:21 -0000 Received: from mx02.bbu.dsd.mx.bitdefender.com (HELO mx02.buh.bitdefender.com) (91.199.104.133) by server-16.tower-206.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 25 Sep 2017 12:03:21 -0000 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=wochWE+Fsw1zbVthkd/CkctcJ3+kPIHRMm1OxeIlsyTJkwf5p4BxTUZclJSCQKlNLx02wBeZYV58LdMYXkVRPCP4/zFpa5JII42gzSTou5y8TVSGktUFbR7+N9hET6AUBkiZ5ug2kQtC2woZjmCaRIbUq5lWDkEBT9mMFqKOSC2ySJokV6yvYeXfbsu2mVgVNGT50iddpHJd2LKx2uWCDz6G5Dtkt/7SDmsyU4q/h1PVdnXW7JZVCvQny+GUtyZsWWmW2WIGYVlgYYGT/cUuesWUB1iPPEncSo51tugBaNQH+0hMI5L/+gnc9ikqLct6No8Xj/JWjRP1PkFvckdaGA==; h=Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bitdefender.com; h=from:to :cc:subject:date:message-id:in-reply-to:references; s=default; bh=hAqm7Y9OFTthwJFFuhUtdM1IfxQ=; b=G7DSI9yaxnKscMFonZ4mvqZ4g4sZ DwZ16nklAQQlMcMpNf0nr3VyOx6P1rKQbQM6FYZFbAYu+YdZ2ui0sWk2+skXnVav 0AacGzG5NyS4KGyu/J0n7QQNnEn8ow3bi/TMLd9L+0R7GPhBRcZ+0pANROUCcotq Bqx+ze63aluaaJC3WwtbhXSmw92EjJEV3aVgeEzBDWrOWFcdp3y1lY+PzKxWFwES PhmQPhtog33OED/Zj5oNHXPp6qlyvznthRdArmtxDVAzy7NXyeqDHvB4DlF34UD4 z4X1Ue1/fTibbXVBwlAI8gHOmNnwIUS2+pSHA5Zq+CLxde3YBIx3anL8xA== Received: (qmail 25155 invoked from network); 25 Sep 2017 15:03:14 +0300 Received: from mx01robo.bbu.dsd.mx.bitdefender.com (10.17.80.60) by mx02.buh.bitdefender.com with AES128-GCM-SHA256 encrypted SMTP; 25 Sep 2017 15:03:14 +0300 Received: (qmail 10969 invoked from network); 25 Sep 2017 15:03:14 +0300 Received: from unknown (HELO pepi-OptiPlex-9020.bbu.bitdefender.biz) (10.10.194.146) by mx01robo.bbu.dsd.mx.bitdefender.com with SMTP; 25 Sep 2017 15:03:14 +0300 From: Petre Pircalabu To: xen-devel@lists.xen.org Date: Mon, 25 Sep 2017 15:03:11 +0300 Message-Id: <1506340992-5587-3-git-send-email-ppircalabu@bitdefender.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506340992-5587-1-git-send-email-ppircalabu@bitdefender.com> References: <1506340992-5587-1-git-send-email-ppircalabu@bitdefender.com> Cc: Petre Pircalabu , kevin.tian@intel.com, sstabellini@kernel.org, wei.liu2@citrix.com, jun.nakajima@intel.com, rcojocaru@bitdefender.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, paul.durrant@citrix.com, tamas@tklengyel.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v13 2/3] x86emul: Add return code information to error messages 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP - print the return code of the last failed emulator operation in hvm_dump_emulation_state. - print the return code in sh_page_fault (SHADOW_PRINTK) to make the distiction between X86EMUL_UNHANDLEABLE and X86EMUL_UNIMPLEMENTED. Signed-off-by: Petre Pircalabu Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant Reviewed-by: George Dunlap --- Changed since v11: * Removed "rc=" from the error message. --- xen/arch/x86/hvm/emulate.c | 13 +++++++------ xen/arch/x86/hvm/io.c | 4 ++-- xen/arch/x86/hvm/vmx/realmode.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 4 ++-- xen/include/asm-x86/hvm/emulate.h | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 385fe1e..4fe61b4 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2056,7 +2056,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla) { case X86EMUL_UNHANDLEABLE: case X86EMUL_UNIMPLEMENTED: - hvm_dump_emulation_state(XENLOG_G_WARNING, "MMCFG", &ctxt); + hvm_dump_emulation_state(XENLOG_G_WARNING, "MMCFG", &ctxt, rc); break; case X86EMUL_EXCEPTION: hvm_inject_event(&ctxt.ctxt.event); @@ -2115,7 +2115,7 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr, return; case X86EMUL_UNIMPLEMENTED: case X86EMUL_UNHANDLEABLE: - hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx); + hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx, rc); hvm_inject_hw_exception(trapnr, errcode); break; case X86EMUL_EXCEPTION: @@ -2243,16 +2243,17 @@ static const char *guest_x86_mode_to_str(int mode) } void hvm_dump_emulation_state(const char *loglvl, const char *prefix, - struct hvm_emulate_ctxt *hvmemul_ctxt) + struct hvm_emulate_ctxt *hvmemul_ctxt, int rc) { struct vcpu *curr = current; const char *mode_str = guest_x86_mode_to_str(hvm_guest_x86_mode(curr)); const struct segment_register *cs = hvmemul_get_seg_reg(x86_seg_cs, hvmemul_ctxt); - printk("%s%s emulation failed: %pv %s @ %04x:%08lx -> %*ph\n", - loglvl, prefix, curr, mode_str, cs->sel, hvmemul_ctxt->insn_buf_eip, - hvmemul_ctxt->insn_buf_bytes, hvmemul_ctxt->insn_buf); + printk("%s%s emulation failed (%d): %pv %s @ %04x:%08lx -> %*ph\n", + loglvl, prefix, rc, curr, mode_str, cs->sel, + hvmemul_ctxt->insn_buf_eip, hvmemul_ctxt->insn_buf_bytes, + hvmemul_ctxt->insn_buf); } /* diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index b8c0ae7..c7b1c53 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -96,11 +96,11 @@ bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate, const char *descr) switch ( rc ) { case X86EMUL_UNHANDLEABLE: - hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt); + hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt, rc); return false; case X86EMUL_UNRECOGNIZED: - hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt); + hvm_dump_emulation_state(XENLOG_G_WARNING, descr, &ctxt, rc); hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC); break; diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmode.c index b73fc80..03dea6c 100644 --- a/xen/arch/x86/hvm/vmx/realmode.c +++ b/xen/arch/x86/hvm/vmx/realmode.c @@ -147,7 +147,7 @@ void vmx_realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt) return; fail: - hvm_dump_emulation_state(XENLOG_G_ERR, "Real-mode", hvmemul_ctxt); + hvm_dump_emulation_state(XENLOG_G_ERR, "Real-mode", hvmemul_ctxt, rc); domain_crash(curr->domain); } diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 2557e21..28030ac 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -3498,8 +3498,8 @@ static int sh_page_fault(struct vcpu *v, v->arch.paging.last_write_emul_ok = 0; } #endif - SHADOW_PRINTK("emulator failure, unshadowing mfn %#lx\n", - mfn_x(gmfn)); + SHADOW_PRINTK("emulator failure (rc=%d), unshadowing mfn %#lx\n", + r, mfn_x(gmfn)); /* If this is actually a page table, then we have a bug, and need * to support more operations in the emulator. More likely, * though, this is a hint that this page should not be shadowed. */ diff --git a/xen/include/asm-x86/hvm/emulate.h b/xen/include/asm-x86/hvm/emulate.h index 8864775..58d17c4 100644 --- a/xen/include/asm-x86/hvm/emulate.h +++ b/xen/include/asm-x86/hvm/emulate.h @@ -92,7 +92,7 @@ int hvmemul_do_pio_buffer(uint16_t port, void *buffer); void hvm_dump_emulation_state(const char *loglvl, const char *prefix, - struct hvm_emulate_ctxt *hvmemul_ctxt); + struct hvm_emulate_ctxt *hvmemul_ctxt, int rc); #endif /* __ASM_X86_HVM_EMULATE_H__ */