[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] Arm: avoid .init.data to be marked as executable



commit 8c9ed863738ff9e8b91975d6aa4464e7e8324eb7
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jun 14 15:52:36 2021 +0200
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Mon Jun 14 17:53:52 2021 +0100

    Arm: avoid .init.data to be marked as executable
    
    This confuses disassemblers, at the very least. Move
    .altinstr_replacement to .init.text. The previously redundant ALIGN()
    now gets converted to page alignment, such that the hypervisor mapping
    won't have this as executable (it'll instead get mapped r/w, which I'm
    told is intended to be adjusted at some point).
    
    Note that for the actual patching logic's purposes this part of
    .init.text _has_ to live after _einittext (or before _sinittext), or
    else branch_insn_requires_update() would produce wrong results.
    
    Also, to have .altinstr_replacement have consistent attributes in the
    object files, add "x" to the one instance where it was missing.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 xen/arch/arm/xen.lds.S            | 4 ++--
 xen/include/asm-arm/alternative.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index fc1d39a886..b773f91f1c 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -148,6 +148,8 @@ SECTIONS
        _sinittext = .;
        *(.init.text)
        _einittext = .;
+       . = ALIGN(PAGE_SIZE);        /* Avoid mapping alt insns executable */
+       *(.altinstr_replacement)
   } :text
   . = ALIGN(PAGE_SIZE);
   .init.data : {
@@ -169,8 +171,6 @@ SECTIONS
        __alt_instructions = .;
        *(.altinstructions)
        __alt_instructions_end = .;
-       . = ALIGN(4);
-       *(.altinstr_replacement)
 
 #ifdef CONFIG_DEBUG_LOCK_PROFILE
        . = ALIGN(POINTER_ALIGN);
diff --git a/xen/include/asm-arm/alternative.h 
b/xen/include/asm-arm/alternative.h
index 92e888aff8..1eb4b60fbb 100644
--- a/xen/include/asm-arm/alternative.h
+++ b/xen/include/asm-arm/alternative.h
@@ -67,7 +67,7 @@ int apply_alternatives(const struct alt_instr *start, const 
struct alt_instr *en
        ALTINSTR_ENTRY(feature,cb)                                      \
        ".popsection\n"                                                 \
        " .if " __stringify(cb) " == 0\n"                               \
-       ".pushsection .altinstr_replacement, \"a\"\n"                   \
+       ".pushsection .altinstr_replacement, \"ax\"\n"                  \
        "663:\n\t"                                                      \
        newinstr "\n"                                                   \
        "664:\n\t"                                                      \
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.