Skip to content

Commit

Permalink
powerpc/vmlinux.lds: Align __init_begin to 16M
Browse files Browse the repository at this point in the history
For CONFIG_STRICT_KERNEL_RWX align __init_begin to 16M. We use 16M
since its the larger of 2M on radix and 16M on hash for our linear
mapping. The plan is to have .text, .rodata and everything upto
__init_begin marked as RX. Note we still have executable read only
data. We could further align rodata to another 16M boundary. I've used
keeping text plus rodata as read-only-executable as a trade-off to
doing read-only-executable for text and read-only for rodata.

We don't use multi PT_LOAD in PHDRS because we are not sure if all
bootloaders support them. This patch keeps PHDRS in vmlinux.lds.S as
the same they are with just one PT_LOAD for all of the kernel marked
as RWX (7).

mpe: What this means is the added alignment bloats the resulting
binary on disk, a powernv kernel goes from 17M to 22M.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Balbir Singh authored and Michael Ellerman committed Jul 3, 2017
1 parent 37bc3e5 commit d924cc3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arch/powerpc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include <asm/cache.h>
#include <asm/thread_info.h>

#ifdef CONFIG_STRICT_KERNEL_RWX
#define STRICT_ALIGN_SIZE (1 << 24)
#else
#define STRICT_ALIGN_SIZE PAGE_SIZE
#endif

ENTRY(_stext)

PHDRS {
Expand Down Expand Up @@ -123,7 +129,7 @@ SECTIONS
PROVIDE32 (etext = .);

/* Read-only data */
RODATA
RO_DATA(PAGE_SIZE)

EXCEPTION_TABLE(0)

Expand All @@ -140,7 +146,7 @@ SECTIONS
/*
* Init sections discarded at runtime
*/
. = ALIGN(PAGE_SIZE);
. = ALIGN(STRICT_ALIGN_SIZE);
__init_begin = .;
INIT_TEXT_SECTION(PAGE_SIZE) :kernel

Expand Down

0 comments on commit d924cc3

Please sign in to comment.