UPSTREAM: arm64: mm: fold alternatives into .init
authorMark Rutland <mark.rutland@arm.com>
Wed, 9 Dec 2015 12:44:38 +0000 (12:44 +0000)
committerJeff Vander Stoep <jeffv@google.com>
Sun, 18 Sep 2016 20:19:45 +0000 (13:19 -0700)
Currently we treat the alternatives separately from other data that's
only used during initialisation, using separate .altinstructions and
.altinstr_replacement linker sections. These are freed for general
allocation separately from .init*. This is problematic as:

* We do not remove execute permissions, as we do for .init, leaving the
  memory executable.

* We pad between them, making the kernel Image bianry up to PAGE_SIZE
  bytes larger than necessary.

This patch moves the two sections into the contiguous region used for
.init*. This saves some memory, ensures that we remove execute
permissions, and allows us to remove some code made redundant by this
reorganisation.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Laura Abbott <labbott@fedoraproject.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Bug: 30369029
Patchset: rework-pagetable

(cherry picked from commit 9aa4ec1571da62366cfddc20f3b923609604fe63)
Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
Change-Id: I3fee118ead5c73ade50ea10d436881c9424a549c

arch/arm64/include/asm/alternative.h
arch/arm64/kernel/alternative.c
arch/arm64/kernel/vmlinux.lds.S
arch/arm64/mm/init.c

index d56ec07151570e6e498e9bf35b2fd9ccaed335fe..e4962f04201e295d933d33f7f39745a5f5e65f65 100644 (file)
@@ -19,7 +19,6 @@ struct alt_instr {
 
 void __init apply_alternatives_all(void);
 void apply_alternatives(void *start, size_t length);
-void free_alternatives_memory(void);
 
 #define ALTINSTR_ENTRY(feature)                                                      \
        " .word 661b - .\n"                             /* label           */ \
index ab9db0e9818c0caa52aa040b7c01aa83183d774e..d2ee1b21a10ddd1bcce1718210c6ce7b7725cfe3 100644 (file)
@@ -158,9 +158,3 @@ void apply_alternatives(void *start, size_t length)
 
        __apply_alternatives(&region);
 }
-
-void free_alternatives_memory(void)
-{
-       free_reserved_area(__alt_instructions, __alt_instructions_end,
-                          0, "alternatives");
-}
index 1cc195872a1f81715dde776e8379c93eb8f1a21a..1a056bb26633aeed63b19825e93b5b9bbef5a8e7 100644 (file)
@@ -142,9 +142,6 @@ SECTIONS
 
        PERCPU_SECTION(L1_CACHE_BYTES)
 
-       . = ALIGN(PAGE_SIZE);
-       __init_end = .;
-
        . = ALIGN(4);
        .altinstructions : {
                __alt_instructions = .;
@@ -156,6 +153,8 @@ SECTIONS
        }
 
        . = ALIGN(PAGE_SIZE);
+       __init_end = .;
+
        _data = .;
        _sdata = .;
        RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
index d43715a14383d9535656b7e4e72ce71b237ee30a..f13078bbf66e0938df1a47ed5d847db0dacaaeb6 100644 (file)
@@ -362,7 +362,6 @@ void free_initmem(void)
 {
        fixup_init();
        free_initmem_default(0);
-       free_alternatives_memory();
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD