From: Konrad Rzeszutek Wilk <konrad@kernel.org>
To: xen-devel@lists.xenproject.org, julien.grall@arm.com,
sstabellini@kernel.org, andrew.cooper3@citrix.com
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>, jbeulich@suse.com
Subject: [PATCH v2 4/5] alternative/x86/arm32: Align altinstructions (and altinstr_replacement) sections.
Date: Wed, 26 Jul 2017 15:47:55 -0400 [thread overview]
Message-ID: <20170726194756.20265-5-konrad@kernel.org> (raw)
In-Reply-To: <20170726194756.20265-1-konrad@kernel.org>
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 <konrad@kernel.org>
---
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"
--
2.13.3
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-26 19:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 19:47 [PATCH v2] Livepatch fixes for v4.10 (v2) Konrad Rzeszutek Wilk
2017-07-26 19:47 ` [PATCH v2 1/5] livepatch: Tighten alignment checks Konrad Rzeszutek Wilk
2017-07-31 13:46 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 2/5] livepatch: Include sizes when an mismatch occurs Konrad Rzeszutek Wilk
2017-07-31 13:51 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 3/5] xen/livepatch/ARM32: Don't load and crash on livepatches loaded with wrong alignment Konrad Rzeszutek Wilk
2017-07-26 22:27 ` Andrew Cooper
2017-07-31 13:55 ` Jan Beulich
2017-07-31 16:04 ` Konrad Rzeszutek Wilk
2017-08-02 9:20 ` Jan Beulich
2017-09-07 17:36 ` Konrad Rzeszutek Wilk
2017-09-08 9:30 ` Jan Beulich
2017-09-09 12:05 ` Konrad Rzeszutek Wilk
2017-09-11 9:01 ` Jan Beulich
2017-09-12 0:22 ` Konrad Rzeszutek Wilk
2017-09-12 8:57 ` Jan Beulich
2017-09-18 19:37 ` Konrad Rzeszutek Wilk
2017-09-19 15:04 ` Jan Beulich
2017-09-20 15:12 ` Konrad Rzeszutek Wilk
2017-09-20 15:51 ` Jan Beulich
2017-07-26 19:47 ` Konrad Rzeszutek Wilk [this message]
2017-07-31 14:01 ` [PATCH v2 4/5] alternative/x86/arm32: Align altinstructions (and altinstr_replacement) sections Jan Beulich
2017-09-11 18:59 ` Konrad Rzeszutek Wilk
2017-07-26 19:47 ` [PATCH v2 5/5] livepatch: Declare live patching as a supported feature Konrad Rzeszutek Wilk
2017-07-31 14:03 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170726194756.20265-5-konrad@kernel.org \
--to=konrad@kernel.org \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.