From patchwork Mon Dec 5 22:25:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9461661 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 817DC6022E for ; Mon, 5 Dec 2016 22:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7672B28285 for ; Mon, 5 Dec 2016 22:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AECB282DC; Mon, 5 Dec 2016 22:28:08 +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, UNPARSEABLE_RELAY 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 19079282ED for ; Mon, 5 Dec 2016 22:28:08 +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 1cE1hy-00034F-PX; Mon, 05 Dec 2016 22:26:02 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cE1hy-00033z-7y for xen-devel@lists.xenproject.org; Mon, 05 Dec 2016 22:26:02 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 35/0A-28694-979E5485; Mon, 05 Dec 2016 22:26:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXSO6nOVbfypWu Ewf7FfBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8beH+IFi4Uq7jd/Zm5gbObvYuTkEBJoZ5K4 Mremi5ELyP7KKHFnxhYWCGcDo8Sbfe/ZIZx+Roml924wgrSwCehIXPzykB3EFhFQkri3ajITS BGzwEwmidN3TrKAJIQF/CW2nVrEBGKzCKhKbL+6nBXE5hVwl/iy6TUziC0hoCjR/WwCG4jNKe AhseJgGzvETe4Sq+9dZ4GoMZbom9XHMoGRbwEjwypG9eLUorLUIl1DvaSizPSMktzEzBxdQwM zvdzU4uLE9NScxKRiveT83E2MwEBhAIIdjDufOx1ilORgUhLlXfjANUKILyk/pTIjsTgjvqg0 J7X4EKMMB4eSBO/550A5waLU9NSKtMwcYMjCpCU4eJREeIVfAKV5iwsSc4sz0yFSpxgVpcR5v UASAiCJjNI8uDZYnFxilJUS5mUEOkSIpyC1KDezBFX+FaM4B6OSMK8YyBSezLwSuOmvgBYzAS 0+cdwZZHFJIkJKqoExXj24xU5r1U3edfVHeAW3RVdoS+SavliWULcx4vOK3xMM7PQcvlyunVB r9sfcJebPgdbwZWa2j08IFWWc4uY9/2e1gmTMIv7DZ63MnjPtftLMlNZZUBwUcX7ll2fGr6Ua pP9JfVX4p81+6t2W348WWCoeO3Ji3YuLsloFSz891VApVMxa8m+ZEktxRqKhFnNRcSIAQHQmf 44CAAA= X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1480976759!32851853!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17471 invoked from network); 5 Dec 2016 22:26:00 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-2.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 5 Dec 2016 22:26:00 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uB5MPmMA020668 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Dec 2016 22:25:49 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id uB5MPmHg008158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Dec 2016 22:25:48 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uB5MPmjU021233; Mon, 5 Dec 2016 22:25:48 GMT Received: from olila.local.net-space.pl (/10.175.220.3) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Dec 2016 14:25:47 -0800 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Mon, 5 Dec 2016 23:25:09 +0100 Message-Id: <1480976718-12198-5-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1480976718-12198-1-git-send-email-daniel.kiper@oracle.com> References: <1480976718-12198-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: jgross@suse.com, sstabellini@kernel.org, andrew.cooper3@citrix.com, cardoe@cardoe.com, pgnet.dev@gmail.com, ning.sun@intel.com, julien.grall@arm.com, jbeulich@suse.com, qiaowei.ren@intel.com, gang.wei@intel.com, fu.wei@linaro.org Subject: [Xen-devel] [PATCH v11 04/13] x86: properly calculate xen ELF end of image address 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 This patch is prereq for "efi: build xen.gz with EFI code" patch which adds, among others, xen/arch/x86/efi/relocs-dummy.S to xen.gz output. Below there is a description why it is needed. Currently xen ELF end of image address is calculated using first line from "nm -nr xen/xen-syms" output. However, potentially it may contain symbol address not related to the end of image in any way. It can happen if a symbol is introduced with address larger than _end symbol address. Such situation encountered when I linked xen ELF binary with xen/arch/x86/efi/relocs-dummy.S. Then first line from "nm -nr xen/xen-syms" contained "ffff82d0c0000000 A ALT_START" and xen ELF image memory size was silently set to 1023 MiB. This issue happened because there is no check which symbol address is used to calculate end of image address. So, let's fix it and take ELF end of image address by reading __2M_rwdata_end symbol address from nm output. This way xen ELF image build process is not prone to changes in order of nm output. Signed-off-by: Daniel Kiper Acked-by: Jan Beulich --- v9 - suggestions/fixes: - use __2M_rwdata_end symbol instead of _end symbol (suggested by Jan Beulich), - really fix indention (suggested by Jan Beulich), - improve commit message (suggested by Jan Beulich). v8 - suggestions/fixes: - use spaces instead of tab in indentation (suggested by Jan Beulich and Konrad Rzeszutek Wilk), - improve commit message (suggested by Jan Beulich). v7 - suggestions/fixes: - use sed instead of awk (suggested by Jan Beulich), - improve commit message (suggested by Jan Beulich). --- xen/arch/x86/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 931917d..e40897f 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -91,7 +91,7 @@ endif $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) 0x100000 \ - `$(NM) -nr $(TARGET)-syms | head -n 1 | sed -e 's/^\([^ ]*\).*/0x\1/'` + `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'` ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS)