From patchwork Tue Mar 19 16:02:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 10859969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11A051390 for ; Tue, 19 Mar 2019 16:10:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1E4A289DA for ; Tue, 19 Mar 2019 16:10:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6369297DC; Tue, 19 Mar 2019 16:10:48 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 60238289DA for ; Tue, 19 Mar 2019 16:10:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6HID-0000cy-Bg; Tue, 19 Mar 2019 16:08:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6HIC-0000ct-KE for xen-devel@lists.xenproject.org; Tue, 19 Mar 2019 16:08:44 +0000 X-Inumbo-ID: 428f9d86-4a61-11e9-9caa-7b689851a86d Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 428f9d86-4a61-11e9-9caa-7b689851a86d; Tue, 19 Mar 2019 16:08:41 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.58,498,1544486400"; d="scan'208";a="81023586" From: Wei Liu To: Date: Tue, 19 Mar 2019 16:02:31 +0000 Message-ID: <20190319160231.17120-1-wei.liu2@citrix.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] libxc: fix HVM core dump X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Igor Druzhinin , Wei Liu , Andrew Cooper , Ian Jackson , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP f969bc9fc96 forbid get_address_size call on HVM guests, because that didn't make sense. It broke core dump functionality on HVM because libxc unconditionally asked for guest width. Only issue the call when necessary in libxc. Reported-by: Igor Druzhinin Signed-off-by: Wei Liu --- Cc: Ian Jackson Cc: Jan Beulich Cc: Andrew Cooper Cc: Igor Druzhinin Cc: Juergen Gross Juergen, this is probably too late for 4.12, but you can at least add a release note somewhere. Ian, please backport this to 4.12. --- tools/libxc/xc_core.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c index e581905ba9..c825b5b0a0 100644 --- a/tools/libxc/xc_core.c +++ b/tools/libxc/xc_core.c @@ -459,12 +459,6 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, struct xc_core_section_headers *sheaders = NULL; Elf64_Shdr *shdr; - if ( xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 ) - { - PERROR("Could not get address size for domain"); - return sts; - } - xc_core_arch_context_init(&arch_ctxt); if ( (dump_mem_start = malloc(DUMP_INCREMENT*PAGE_SIZE)) == NULL ) { @@ -487,6 +481,13 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, } auto_translated_physmap = xc_core_arch_auto_translated_physmap(&info); + if ( !auto_translated_physmap && + xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 ) + { + PERROR("Could not get address size for domain"); + goto out; + } + if ( domid != info.domid ) { PERROR("Domain %d does not exist", domid); @@ -742,7 +743,10 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, goto out; /* elf note section: xen version */ - sts = elfnote_dump_xen_version(xch, args, dump_rtn, dinfo->guest_width); + sts = elfnote_dump_xen_version(xch, args, dump_rtn, + auto_translated_physmap ? + sizeof(unsigned long): + dinfo->guest_width); if ( sts != 0 ) goto out;