From patchwork Thu Aug 25 13:37:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9299349 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 707EB60459 for ; Thu, 25 Aug 2016 13:40:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 624CB29332 for ; Thu, 25 Aug 2016 13:40:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5672929335; Thu, 25 Aug 2016 13:40:09 +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 CDB6829332 for ; Thu, 25 Aug 2016 13:40: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 1bcurF-0001Au-7o; Thu, 25 Aug 2016 13:38:13 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcurD-00018Z-TI for xen-devel@lists.xenproject.org; Thu, 25 Aug 2016 13:38:12 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id AE/BD-17152-3C4FEB75; Thu, 25 Aug 2016 13:38:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXSO6nOVffQl33 hBl+WKFt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkf+wsKHvFWbFv7laWB8RNXFyMXh5DAZCaJ 9jvfWbsYOYGcL4wSO+9oQNgbGSXe70iGKJrGKPHv8h2gIg4ONgETiTerHEHiIgJ9jBKHj25iB mlgBnH2nQazhQU8JKZu3ssOYrMIqEpM/T0dbAGvgLvE7stf2UHmSAjISzy7XQ8S5gQK/27YzA ax103i+6UOFhBbQsBYov3tRbYJjHwLGBlWMWoUpxaVpRbpGhnqJRVlpmeU5CZm5ugaGhjr5aY WFyemp+YkJhXrJefnbmIEBkk9AwPjDsaevX6HGCU5mJREebVX7AsX4kvKT6nMSCzOiC8qzUkt PsQow8GhJME75TNQTrAoNT21Ii0zBxiuMGkJDh4lEd51IGne4oLE3OLMdIjUKUZFKXHeKpCEA EgiozQPrg0WI5cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfNWg0zhycwrgZv+CmgxE9Dilv u7QRaXJCKkpBoYpfk2Fq3sX7DtlqBo/9TATcfmdKQsk8zM4/4idsiRL9Z8Ln+J4/Hjaz5oPU8 UmHrCMZhJWilmUofOWR7B+W+5Gk+LX/pT3l6yV51xxcr+COlu42PVIudPr5jLv1yHvfUk47Nz syvf/J+eOHv2zO4FChOuh+1afHbHc//Q/5m97UtTOGsP7+/JU2Ipzkg01GIuKk4EAJclTx6MA gAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1472132288!57417969!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 35792 invoked from network); 25 Aug 2016 13:38:10 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2016 13:38:10 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PDc14M006524 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2016 13:38:01 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u7PDc1rp009731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 13:38:01 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u7PDc0IA026132; Thu, 25 Aug 2016 13:38:00 GMT Received: from localhost.event.rightround.com (/75.98.193.200) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Aug 2016 06:38:00 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, ross.lagerwall@citrix.com, sstabellini@kernel.org, julien.grall@arm.com Date: Thu, 25 Aug 2016 09:37:34 -0400 Message-Id: <1472132255-23470-20-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1472132255-23470-1-git-send-email-konrad.wilk@oracle.com> References: <1472132255-23470-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Andrew Cooper , Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v2 19/20] livepatch/elf: Adjust section aligment to word 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 On most architectures it does not matter what the aligment is. On ARM32 it is paramount that the aligment is word-size (4) otherwise we get a Data Abort when trying to perform ELF relocations. That is due to ARM 32 only being able to write to word-aligned addresses. The default section alignments for .bug.frame, .livepatch.depends, ,.rodata.str1, and .strtab are 1 unless we: - Provide our own linker script file. - Piggyback on Xen's (but that means lots of #ifdefery) - Throw an error and refuse the payload Or just fix it up. Signed-off-by: Konrad Rzeszutek Wilk --- Cc: Julien Grall Cc: Stefano Stabellini Cc: Jan Beulich Cc: Andrew Cooper v2: First submission --- xen/common/livepatch_elf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/common/livepatch_elf.c b/xen/common/livepatch_elf.c index cda9b27..2392bdf 100644 --- a/xen/common/livepatch_elf.c +++ b/xen/common/livepatch_elf.c @@ -71,7 +71,15 @@ static int elf_resolve_sections(struct livepatch_elf *elf, const void *data) delta = elf->hdr->e_shoff + i * elf->hdr->e_shentsize; sec[i].sec = data + delta; - + /* + * Some architectures REQUIRE section alignment to be word-size. + */ + if ( sec[i].sec->sh_addralign % sizeof(uint32_t) ) + { + dprintk(XENLOG_DEBUG, LIVEPATCH "%s: Adjusting aligment for section [%u]\n", + elf->name, i); + ((Elf_Shdr *)sec[i].sec)->sh_addralign = 4; + } delta = sec[i].sec->sh_offset; /* * N.B. elf_resolve_section_names, elf_get_sym skip this check as