From patchwork Thu Sep 29 21:42:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9357149 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 E46356077B for ; Thu, 29 Sep 2016 21:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6F2A29C75 for ; Thu, 29 Sep 2016 21:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C701929C79; Thu, 29 Sep 2016 21:45:49 +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 41DA029C75 for ; Thu, 29 Sep 2016 21:45:48 +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 1bpj70-0003Nk-0s; Thu, 29 Sep 2016 21:43:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpj6y-0003Nc-UU for xen-devel@lists.xenproject.org; Thu, 29 Sep 2016 21:43:25 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 2D/60-21986-CFA8DE75; Thu, 29 Sep 2016 21:43:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHLMWRWlGSWpSXmKPExsXSO6nOVfd319t wg3WXDS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyZ1ycwF/wUrFh99z9rA+Ndvi5GLg4hgQ4m iY9dW1ghnC+MEuteNkE5Gxkl2i63MUE4ExklDlzcDpTh5GAT0JG4+OUhO4gtIqAkcW/VZLAiZ oFdTBKnLm9kBEkIC/hJPD3ZxAZiswioSny7NBHM5hVwl/jTt4IJxJYQUJTofjYBLM4p4CExo+ EFWK8QUE3fsV/sEDXGEn2z+lgmMPItYGRYxahRnFpUllqka2Sol1SUmZ5RkpuYmaNraGCml5t aXJyYnpqTmFSsl5yfu4kRGC4MQLCD8c+ygEOMkhxMSqK8pwPfhgvxJeWnVGYkFmfEF5XmpBYf YpTh4FCS4J3bCZQTLEpNT61Iy8wBBi5MWoKDR0mEdxZImre4IDG3ODMdInWKUVFKnFcEGO5CA iCJjNI8uDZYtFxilJUS5mUEOkSIpyC1KDezBFX+FaM4B6OSMG8CyHiezLwSuOmvgBYzAS3OP/ oGZHFJIkJKqoHROufnHpvlyi+SvK/eO7XtplXuGvfUC2z7t4kXej87caHlyfnYs7ob/9tvPBg pOodxtfRrfdejpasWbjultPTOidtarxQ3ezFIz9wWH3pnv5zxVqZE7z+7HreuyU9mXyLCt+Ff nCNP/tTzpzsF1+9s/DBLTU+cU7aQvXjC4xc7F1/fLbT3GneNqhJLcUaioRZzUXEiAGaEr7+RA gAA X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1475185401!62088054!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: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1218 invoked from network); 29 Sep 2016 21:43:23 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-3.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Sep 2016 21:43:23 -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 u8TLhAeA024378 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Sep 2016 21:43:11 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8TLhAqW010815 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Sep 2016 21:43:10 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8TLh96i015826; Thu, 29 Sep 2016 21:43:09 GMT Received: from olila.local.net-space.pl (/10.175.208.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 29 Sep 2016 14:43:09 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Thu, 29 Sep 2016 23:42:33 +0200 Message-Id: <1475185362-14198-5-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1475185362-14198-1-git-send-email-daniel.kiper@oracle.com> References: <1475185362-14198-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, david.vrabel@citrix.com, jbeulich@suse.com, qiaowei.ren@intel.com, gang.wei@intel.com, fu.wei@linaro.org Subject: [Xen-devel] [PATCH v9 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)