Commit 9aa4ec15 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

arm64: mm: fold alternatives into .init

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: default avatarMark 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: default avatarWill Deacon <will.deacon@arm.com>
parent 5b28cd9d
...@@ -19,7 +19,6 @@ struct alt_instr { ...@@ -19,7 +19,6 @@ struct alt_instr {
void __init apply_alternatives_all(void); void __init apply_alternatives_all(void);
void apply_alternatives(void *start, size_t length); void apply_alternatives(void *start, size_t length);
void free_alternatives_memory(void);
#define ALTINSTR_ENTRY(feature) \ #define ALTINSTR_ENTRY(feature) \
" .word 661b - .\n" /* label */ \ " .word 661b - .\n" /* label */ \
......
...@@ -158,9 +158,3 @@ void apply_alternatives(void *start, size_t length) ...@@ -158,9 +158,3 @@ void apply_alternatives(void *start, size_t length)
__apply_alternatives(&region); __apply_alternatives(&region);
} }
void free_alternatives_memory(void)
{
free_reserved_area(__alt_instructions, __alt_instructions_end,
0, "alternatives");
}
...@@ -140,9 +140,6 @@ SECTIONS ...@@ -140,9 +140,6 @@ SECTIONS
PERCPU_SECTION(64) PERCPU_SECTION(64)
. = ALIGN(PAGE_SIZE);
__init_end = .;
. = ALIGN(4); . = ALIGN(4);
.altinstructions : { .altinstructions : {
__alt_instructions = .; __alt_instructions = .;
...@@ -154,6 +151,8 @@ SECTIONS ...@@ -154,6 +151,8 @@ SECTIONS
} }
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
__init_end = .;
_data = .; _data = .;
_sdata = .; _sdata = .;
RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE) RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
......
...@@ -360,7 +360,6 @@ void free_initmem(void) ...@@ -360,7 +360,6 @@ void free_initmem(void)
{ {
fixup_init(); fixup_init();
free_initmem_default(0); free_initmem_default(0);
free_alternatives_memory();
} }
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment