From patchwork Wed Jul 26 19:47:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9865729 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 0118A6038F for ; Wed, 26 Jul 2017 19:51:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E77B4281E1 for ; Wed, 26 Jul 2017 19:51:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC070287A3; Wed, 26 Jul 2017 19:51:03 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID 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 330A1287BB for ; Wed, 26 Jul 2017 19:51:02 +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 1daSIc-0008Vf-0i; Wed, 26 Jul 2017 19:48:50 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1daSIa-0008Uw-J2 for xen-devel@lists.xenproject.org; Wed, 26 Jul 2017 19:48:48 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id E9/41-01729-F12F8795; Wed, 26 Jul 2017 19:48:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVyMfTOQV35TxW RBr2bOCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owfT28xFZyTrFg/9wFLA+N8kS5GLg4hgZmM EhsvnWAEcVgEPrBI3OpaxQTiSAhMY5W4fb2bvYuRE8iJk2i71sEMYVdI7HnymAnEFhJQktgy+ TEjxKjnTBL7zt0BaxAW0JOY/O02I4jNJqAv8XTtNbBmEYE8ia79DWA2s4CjxIlvPSwQ9ZkSr0 9PA7NZBFQl5t66wwZi8wqYSRz69Z0JYrG8xMTeaWAzOQXMJd4/ewZ1hJlE971mxgmMggsYGVY xahSnFpWlFukaGuslFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgQGHQMQ7GD8t83z EKMkB5OSKO8k04pIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8bR+AcoJFqempFWmZOcDwh0lLc PAoifDuAEnzFhck5hZnpkOkTjFacly5su4LE8eUA9uB5KsJ/78xCbHk5eelSonzFoM0CIA0ZJ TmwY2DxeglRlkpYV5GoAOFeApSi3IzS1DlXzGKczAqCfOuA5nCk5lXArf1FdBBTEAHzZlRCnJ QSSJCSqqBcW1egPWOTNmajO1K3VZKM2L4f75YuW7b1bJ5TroZJafVGfh0l2tIaP54Yziv7Ny7 mzwpa08LT81t4zhepnzs5ZX8r/Orz554oBXYs/+Nx2JHfZWgcJ+L53ryV6bV+Ah0vw56FtqwL EzD3dJscesP3fvbDb8zHLlwlMVQ/UrODk21134nM9ccVWIpzkg01GIuKk4EADrYv+fMAgAA X-Env-Sender: ketuzsezr@gmail.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1501098526!76229290!1 X-Originating-IP: [209.85.220.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30421 invoked from network); 26 Jul 2017 19:48:47 -0000 Received: from mail-qk0-f193.google.com (HELO mail-qk0-f193.google.com) (209.85.220.193) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 26 Jul 2017 19:48:47 -0000 Received: by mail-qk0-f193.google.com with SMTP id q66so16372319qki.1 for ; Wed, 26 Jul 2017 12:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=pVkPPAKIFFfN5HwMRFTPwWA6KFY69UtAivPzL7wCc+Q=; b=Ut/rCDjrSK5EiUdTQLYAfcp4jEJV9JmniuyHyfhMi+OS1bfxyUJwMn7R6tZQ/iqKj+ vjJYaM2dQPfaqVbcJZrlap2GPsjZSju5Mt8w1RYmOw05uldg3VAvZmZssBoaLMP2kB73 MEuFzDaBHCReTDdQqo/DZWglDEkO0qP1MjMnCQCE2Yfd/o4ptD8jj/Ce8H7U8twD/Fqx ShtrhpTz3b+w1aeWLqk07vKUwvB7JVKxY8Or27fSreQRv9TmffXFAP/Xdl9y7aCORUnr hY1wHhVkJWRKD460IlKFMAmOFz8ixBOPMpJubiahJjUNoS1xd/lUuDQqMuSDBTHL4Bgu tKSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=pVkPPAKIFFfN5HwMRFTPwWA6KFY69UtAivPzL7wCc+Q=; b=MAgRAy/9zf+uo7F5AJCwefGHxLLiu4Yv/ojVAPrSeWnJVRbhWOZIfRrYawdp6Aik6Y rwvtXFrcj40gGHExnlVSHjJSD32p2ePZiTi0wOaR2OOp6uphbE0DcKVt/rfcPwMOIumH CDfLZVtM5rANueZBBj5jg98n9fDifwpPp29qlBTAqMl4t01OA/1fFJMk1ODpuBKkPddY PaeWbStAedgq3wsf5JdmRgH4PsKM7YVyNE36g0/bWMNuBq464uUFIOaLgtePMpddG7hC poORGqS2NcUz16SOaSAzBw1r6oFU6cxpKxl2eZAeqfwXeZhu/0dWZNCoTu0+7tOrKmyG mKhA== X-Gm-Message-State: AIVw1104yJw0Xk+Lq3VkmSZBGTNC73PhYkji3dwb9VpTcYEGmQCsZo1b Rj6WdJfXsbiD+eMI X-Received: by 10.55.48.70 with SMTP id w67mr2626947qkw.207.1501098525676; Wed, 26 Jul 2017 12:48:45 -0700 (PDT) Received: from dhcp-amer-vpn-adc-anyconnect-10-154-174-211.vpn.oracle.com (209-6-200-48.s4398.c3-0.smr-ubr2.sbo-smr.ma.cable.rcncustomer.com. [209.6.200.48]) by smtp.gmail.com with ESMTPSA id m22sm13305504qtm.15.2017.07.26.12.48.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jul 2017 12:48:44 -0700 (PDT) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, julien.grall@arm.com, sstabellini@kernel.org, andrew.cooper3@citrix.com Date: Wed, 26 Jul 2017 15:47:55 -0400 Message-Id: <20170726194756.20265-5-konrad@kernel.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170726194756.20265-1-konrad@kernel.org> References: <20170726194756.20265-1-konrad@kernel.org> Cc: Konrad Rzeszutek Wilk , jbeulich@suse.com Subject: [Xen-devel] [PATCH v2 4/5] alternative/x86/arm32: Align altinstructions (and altinstr_replacement) sections. 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 is very similar to 137c59b9ff3f7a214f03b52d9c00a0a02374af1f "bug/x86/arm: Align bug_frames sections." On ARM and on x86 the C and assembler macros don't include any alignment information - hence they end up being the default byte granularity. On ARM32 it is paramount that the alignment is word-size (4) otherwise if one tries to use (uint32_t*) access (such as livepatch ELF relocations) we get a Data Abort. Enforcing .altinstructions (and also .altinstr_replacement for completness) to have the proper alignment across all architectures and in both C and x86 makes them all the same. On x86 the bloat-o-meter detects that with this change the file shrinks: add/remove: 1/0 grow/shrink: 0/2 up/down: 156/-367 (-211) function old new delta get_page_from_gfn - 156 +156 do_mmu_update 4578 4569 -9 do_mmuext_op 5604 5246 -358 Total: Before=3170439, After=3170228, chg -0.01% While on ARM 32/64: add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) function old new delta Total: Before=822563, After=822563, chg +0.00% Signed-off-by: Konrad Rzeszutek Wilk --- v2: First version --- xen/include/asm-arm/alternative.h | 4 ++++ xen/include/asm-x86/alternative.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/xen/include/asm-arm/alternative.h b/xen/include/asm-arm/alternative.h index 6cc9d0dc5f..cd1373fdd5 100644 --- a/xen/include/asm-arm/alternative.h +++ b/xen/include/asm-arm/alternative.h @@ -54,9 +54,11 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en oldinstr "\n" \ "662:\n" \ ".pushsection .altinstructions,\"a\"\n" \ + ".p2align 2\n" \ ALTINSTR_ENTRY(feature) \ ".popsection\n" \ ".pushsection .altinstr_replacement, \"a\"\n" \ + ".p2align 2\n" \ "663:\n\t" \ newinstr "\n" \ "664:\n\t" \ @@ -84,6 +86,7 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en .if \enable 661: \insn1 662: .pushsection .altinstructions, "a" + .p2align 2 altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f .popsection .pushsection .altinstr_replacement, "ax" @@ -103,6 +106,7 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en .macro alternative_if_not cap, enable = 1 .if \enable .pushsection .altinstructions, "a" + .p2align 2 altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f .popsection 661: diff --git a/xen/include/asm-x86/alternative.h b/xen/include/asm-x86/alternative.h index db4f08e0e7..e667ccfbdb 100644 --- a/xen/include/asm-x86/alternative.h +++ b/xen/include/asm-x86/alternative.h @@ -56,10 +56,12 @@ extern void alternative_instructions(void); #define ALTERNATIVE_N(newinstr, feature, number) \ ".pushsection .altinstructions,\"a\"\n" \ + ".p2align 2\n" \ ALTINSTR_ENTRY(feature, number) \ ".section .discard,\"a\",@progbits\n" \ DISCARD_ENTRY(number) \ ".section .altinstr_replacement, \"ax\"\n" \ + ".p2align 2\n" \ ALTINSTR_REPLACEMENT(newinstr, feature, number) \ ".popsection\n"