From patchwork Mon Sep 19 20:26:39 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: 9340463 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 018AB6022E for ; Mon, 19 Sep 2016 20:29:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E90BB2961D for ; Mon, 19 Sep 2016 20:29:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD8F02986F; Mon, 19 Sep 2016 20:29:23 +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.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM,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 739862961D for ; Mon, 19 Sep 2016 20:29:22 +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 1bm59g-0000ZX-By; Mon, 19 Sep 2016 20:27:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bm59f-0000Xr-JE for xen-devel@lists.xenproject.org; Mon, 19 Sep 2016 20:27:07 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 51/4A-28857-A1A40E75; Mon, 19 Sep 2016 20:27:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRWlGSWpSXmKPExsXSO6nOVVfK60G 4wbwDrBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b0PwkFk3UrtrTVNDA2yXUxcnEICXQwScxf +4AFwvnCKLF62jNWCGcjo8T+dT+ZIJxORom3k+4COZwcLAKqEp1PXjF3MXJwsAmYSLxZ5QgSF hFQl/hzYQIjSD2zwBlGiSNPJrOCJIQFgiRmTlzHDmLzCphJTJ+0lg1iaD+TRO+KBlaIhKDEyZ lPWEBsZgEtiRv/XjKBLGAWkJZY/o8DJMwpYC7x/NANNhBbVEBZomHGA2YQW0LAWKJvVh/LBEb BWUgmzUIyaRbCpAWMzKsY1YtTi8pSi3SN9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLz czcxAoOWAQh2MC7763SIUZKDSUmUV47vQbgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV4WT6CcY FFqempFWmYOMH5g0hIcPEoivF89gNK8xQWJucWZ6RCpU4yKUuK8T0ASAiCJjNI8uDZYzF5ilJ US5mUEOkSIpyC1KDezBFX+FaM4B6OSMG8fyBSezLwSuOmvgBYzAS1m7LkPsrgkESEl1cCYumz LxbRFv3WunOs+83yr+IzTDFM1DMXZjh1c/YrPZ2lb/Aub8qi9/F84T9lt9tjN0HVVRuBUW7jY toWLM6Z9uRth1fWPteRgZc2xKb268/Xq5k3Tr0r8qGVQeC/pwRKtbLUlG6W952m7nVzwaEPpF svD4bXnZgWuX/XfK5Pv6py3sr9/Wys0KLEUZyQaajEXFScCADdH6KnUAgAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1474316824!59739750!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 5565 invoked from network); 19 Sep 2016 20:27:05 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-16.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 19 Sep 2016 20:27:05 -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 u8JKQuvK001788 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Sep 2016 20:26:57 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 u8JKQu1o000616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Sep 2016 20:26:56 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8JKQt8U030420; Mon, 19 Sep 2016 20:26:55 GMT Received: from x230.dumpdata.com (/10.154.139.13) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Sep 2016 13:26:54 -0700 Date: Mon, 19 Sep 2016 16:26:39 -0400 From: Konrad Rzeszutek Wilk To: Julien Grall Message-ID: <20160919202637.GA31190@x230.dumpdata.com> References: <1474043908-12101-1-git-send-email-konrad.wilk@oracle.com> <1474043908-12101-13-git-send-email-konrad.wilk@oracle.com> <971defec-b158-051d-dd48-a70be37317bc@arm.com> <0af2ec65-1af8-3341-5fe8-53f02a9ce10b@arm.com> <20160919201939.GA28345@x230.dumpdata.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160919201939.GA28345@x230.dumpdata.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: sstabellini@kernel.org, Andrew Cooper , ross.lagerwall@citrix.com, Jan Beulich , xen-devel@lists.xenproject.org Subject: Re: [Xen-devel] [PATCH v4 12/16] bug/x86/arm: Align bug_frames 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Sep 19, 2016 at 04:19:55PM -0400, Konrad Rzeszutek Wilk wrote: > > > > Signed-off-by: Konrad Rzeszutek Wilk > > > > I forgot to mention that with those NITs fixed: > > > > Reviewed-by: Julien Grall > > Thanks. > > However I noticed (and I recall having it replaced in earlier > versions so I must have in a hurry missed it), but this: > > > > > --- a/xen/include/asm-arm/bug.h > > > > +++ b/xen/include/asm-arm/bug.h > > > > @@ -52,6 +52,7 @@ struct bug_frame { > > > > > > > > ".popsection\n" \ > > > > ".pushsection .bug_frames." __stringify(type) ", \"a\", > > > > %progbits\n"\ > > > > > > > > "4:\n" \ > > > > + ".align 4\n" \ > > [fixed up, your mailer mangled it] > This should have been: > > diff --git a/xen/include/asm-arm/bug.h b/xen/include/asm-arm/bug.h > index 773d63e..affe64f 100644 > --- a/xen/include/asm-arm/bug.h > +++ b/xen/include/asm-arm/bug.h > @@ -52,7 +52,7 @@ struct bug_frame { > ".popsection\n" \ > ".pushsection .bug_frames." __stringify(type) ", \"a\", %progbits\n"\ > "4:\n" \ > - ".align 4\n" \ > + ".p2align 4\n" \ Argh. '.p2align 2' ! For reference, here is the full patch: From ecf25f594118042364367d0bfacb3ee252222046 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Wed, 7 Sep 2016 11:57:05 -0400 Subject: [PATCH] bug/x86/arm: Align bug_frames sections. Most of the WARN_ON or BUG_ON sections are properly aligned on x86. However on ARM and on x86 assembler the 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 bug_frames to have the proper alignment across all architectures and in both C and x86 makes them all the same. Furthermore on x86 the bloat-o-meter detects that with this change: add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) function old new delta On ARM32: add/remove: 1/0 grow/shrink: 0/1 up/down: 384/-288 (96) function old new delta gnttab_unpopulate_status_frames - 384 +384 do_grant_table_op 10808 10520 -288 And ARM64: add/remove: 1/2 grow/shrink: 0/1 up/down: 4164/-4236 (-72) function old new delta gnttab_map_grant_ref - 4164 +4164 do_grant_table_op 9892 9836 -56 grant_map_exists 300 - -300 __gnttab_map_grant_ref 3880 - -3880 Reviewed-by: Julien Grall Acked-by: Jan Beulich [x86 parts] Signed-off-by: Konrad Rzeszutek Wilk --- Cc: Julien Grall Cc: Stefano Stabellini Cc: Jan Beulich Cc: Andrew Cooper v3: First submission. Replaces the "livepatch/elf: Adjust section aligment to word" patch. v4: Remove the .ALIGN(4) in xen.lds.S for x86 (the only place needing that change). Update the commit description with correct x86 results Remove the . = ALIGN(4); in linker filer on x86 [the only file needing the change] v5: Add Jan's Ack on x86 parts. v6: Added Julien's Reviewed-by s/aligment/alignment/ s/align 4/p2align 2/ as the align semnatics varies by platforms, while p2align is the same across all of them. --- xen/arch/x86/xen.lds.S | 1 - xen/include/asm-arm/bug.h | 1 + xen/include/asm-x86/bug.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index d903c31..7676de9 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -79,7 +79,6 @@ SECTIONS .rodata : { _srodata = .; /* Bug frames table */ - . = ALIGN(4); __start_bug_frames = .; *(.bug_frames.0) __stop_bug_frames_0 = .; diff --git a/xen/include/asm-arm/bug.h b/xen/include/asm-arm/bug.h index 68353e1..4704e2d 100644 --- a/xen/include/asm-arm/bug.h +++ b/xen/include/asm-arm/bug.h @@ -52,6 +52,7 @@ struct bug_frame { ".popsection\n" \ ".pushsection .bug_frames." __stringify(type) ", \"a\", %progbits\n"\ "4:\n" \ + ".p2align 2\n" \ ".long (1b - 4b)\n" \ ".long (2b - 4b)\n" \ ".long (3b - 4b)\n" \ diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h index c5d2d4c..9bb4a19 100644 --- a/xen/include/asm-x86/bug.h +++ b/xen/include/asm-x86/bug.h @@ -98,6 +98,7 @@ extern const struct bug_frame __start_bug_frames[], .popsection .pushsection .bug_frames.\type, "a", @progbits + .p2align 2 .L\@bf: .long (.L\@ud - .L\@bf) + \ ((\line >> BUG_LINE_LO_WIDTH) << BUG_DISP_WIDTH)