From patchwork Wed Nov 30 13:04:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9454315 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 5BDEE6071E for ; Wed, 30 Nov 2016 13:08:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5211428409 for ; Wed, 30 Nov 2016 13:08:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46A2A2841A; Wed, 30 Nov 2016 13:08: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, 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 DC55C28409 for ; Wed, 30 Nov 2016 13:08:17 +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 1cC4Zq-0003PU-1B; Wed, 30 Nov 2016 13:05:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cC4Zo-0003PH-QV for xen-devel@lists.xenproject.org; Wed, 30 Nov 2016 13:05:32 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 5B/20-01928-B9ECE385; Wed, 30 Nov 2016 13:05:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRWlGSWpSXmKPExsUyZ7p8oO6sc3Y RBl9uS1t83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBl7f4gXLBaquN/8mbmBsZm/i5GLQ0igg0ni 2r3dbBDON0aJq0332SGcjYwSm0/fZoVwJjJKdOxpY+xi5ORgE9CRuPjlITuILSKgJHFv1WQmk CJmgZlMEqfvnGQBSQgL+EvMmfoNzGYRUJW4c3klG4jNK+Au8fvwAzBbQkBRovvZBDCbU8BD4u mEu2BDhYBqvi29xAxRYyzRN6uPZQIj3wJGhlWMGsWpRWWpRbpGRnpJRZnpGSW5iZk5uoYGpnq 5qcXFiempOYlJxXrJ+bmbGIHBUs/AwLiDcU+73yFGSQ4mJVFevk67CCG+pPyUyozE4oz4otKc 1OJDjDIcHEoSvBlngXKCRanpqRVpmTnAsIVJS3DwKInwFoCkeYsLEnOLM9MhUqcYFaXEIRICI ImM0jy4NlisXGKUlRLmZWRgYBDiKUgtys0sQZV/xSjOwagkzNsDMoUnM68EbvoroMVMQIvfvr YGWVySiJCSamBcvufR9Xf/KpqWLP3dszj1W7f4z3WPvlra3j3uIy29VW/5sjk77K5Uv2Vxmak RxNbjrbMgefFXZe0mXd2yju+t+24nbYm5qpnxZH6t5I+Ueal7vz3488R1mlzoRb0DjfqTs9wu qLAw3RSPWGS+ZNrdpb+PGW7+5DRxts1vJm2/+b5RPqZuJyWllFiKMxINtZiLihMBoF9ASpACA AA= X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1480511127!57143391!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50906 invoked from network); 30 Nov 2016 13:05:29 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 Nov 2016 13:05:29 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uAUD5HwO008090 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Nov 2016 13:05:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id uAUD5G4R001170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Nov 2016 13:05:16 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id uAUD5E4L007811; Wed, 30 Nov 2016 13:05:15 GMT Received: from olila.local.net-space.pl (/10.175.217.205) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 30 Nov 2016 05:05:14 -0800 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Wed, 30 Nov 2016 14:04:10 +0100 Message-Id: <1480511059-14062-5-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1480511059-14062-1-git-send-email-daniel.kiper@oracle.com> References: <1480511059-14062-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 v10 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)