Skip to content

Commit d924cc3

Browse files
bsingharorampe
authored andcommitted
powerpc/vmlinux.lds: Align __init_begin to 16M
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 37bc3e5 commit d924cc3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arch/powerpc/kernel/vmlinux.lds.S

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include <asm/cache.h>
99
#include <asm/thread_info.h>
1010

11+
#ifdef CONFIG_STRICT_KERNEL_RWX
12+
#define STRICT_ALIGN_SIZE (1 << 24)
13+
#else
14+
#define STRICT_ALIGN_SIZE PAGE_SIZE
15+
#endif
16+
1117
ENTRY(_stext)
1218

1319
PHDRS {
@@ -123,7 +129,7 @@ SECTIONS
123129
PROVIDE32 (etext = .);
124130

125131
/* Read-only data */
126-
RODATA
132+
RO_DATA(PAGE_SIZE)
127133

128134
EXCEPTION_TABLE(0)
129135

@@ -140,7 +146,7 @@ SECTIONS
140146
/*
141147
* Init sections discarded at runtime
142148
*/
143-
. = ALIGN(PAGE_SIZE);
149+
. = ALIGN(STRICT_ALIGN_SIZE);
144150
__init_begin = .;
145151
INIT_TEXT_SECTION(PAGE_SIZE) :kernel
146152

0 commit comments

Comments
 (0)