diff options
Diffstat (limited to 'arch/x86/kernel/vmlinux.lds.S')
| -rw-r--r-- | arch/x86/kernel/vmlinux.lds.S | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 3c68fe2d46cf..f3f2104408d9 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S | |||
| @@ -41,6 +41,32 @@ ENTRY(phys_startup_64) | |||
| 41 | jiffies_64 = jiffies; | 41 | jiffies_64 = jiffies; |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA) | ||
| 45 | /* | ||
| 46 | * On 64-bit, align RODATA to 2MB so that even with CONFIG_DEBUG_RODATA | ||
| 47 | * we retain large page mappings for boundaries spanning kernel text, rodata | ||
| 48 | * and data sections. | ||
| 49 | * | ||
| 50 | * However, kernel identity mappings will have different RWX permissions | ||
| 51 | * to the pages mapping to text and to the pages padding (which are freed) the | ||
| 52 | * text section. Hence kernel identity mappings will be broken to smaller | ||
| 53 | * pages. For 64-bit, kernel text and kernel identity mappings are different, | ||
| 54 | * so we can enable protection checks that come with CONFIG_DEBUG_RODATA, | ||
| 55 | * as well as retain 2MB large page mappings for kernel text. | ||
| 56 | */ | ||
| 57 | #define X64_ALIGN_DEBUG_RODATA_BEGIN . = ALIGN(HPAGE_SIZE); | ||
| 58 | |||
| 59 | #define X64_ALIGN_DEBUG_RODATA_END \ | ||
| 60 | . = ALIGN(HPAGE_SIZE); \ | ||
| 61 | __end_rodata_hpage_align = .; | ||
| 62 | |||
| 63 | #else | ||
| 64 | |||
| 65 | #define X64_ALIGN_DEBUG_RODATA_BEGIN | ||
| 66 | #define X64_ALIGN_DEBUG_RODATA_END | ||
| 67 | |||
| 68 | #endif | ||
| 69 | |||
| 44 | PHDRS { | 70 | PHDRS { |
| 45 | text PT_LOAD FLAGS(5); /* R_E */ | 71 | text PT_LOAD FLAGS(5); /* R_E */ |
| 46 | data PT_LOAD FLAGS(7); /* RWE */ | 72 | data PT_LOAD FLAGS(7); /* RWE */ |
| @@ -90,7 +116,9 @@ SECTIONS | |||
| 90 | 116 | ||
| 91 | EXCEPTION_TABLE(16) :text = 0x9090 | 117 | EXCEPTION_TABLE(16) :text = 0x9090 |
| 92 | 118 | ||
| 119 | X64_ALIGN_DEBUG_RODATA_BEGIN | ||
| 93 | RO_DATA(PAGE_SIZE) | 120 | RO_DATA(PAGE_SIZE) |
| 121 | X64_ALIGN_DEBUG_RODATA_END | ||
| 94 | 122 | ||
| 95 | /* Data */ | 123 | /* Data */ |
| 96 | .data : AT(ADDR(.data) - LOAD_OFFSET) { | 124 | .data : AT(ADDR(.data) - LOAD_OFFSET) { |
| @@ -107,13 +135,13 @@ SECTIONS | |||
| 107 | 135 | ||
| 108 | PAGE_ALIGNED_DATA(PAGE_SIZE) | 136 | PAGE_ALIGNED_DATA(PAGE_SIZE) |
| 109 | 137 | ||
| 110 | CACHELINE_ALIGNED_DATA(CONFIG_X86_L1_CACHE_BYTES) | 138 | CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) |
| 111 | 139 | ||
| 112 | DATA_DATA | 140 | DATA_DATA |
| 113 | CONSTRUCTORS | 141 | CONSTRUCTORS |
| 114 | 142 | ||
| 115 | /* rarely changed data like cpu maps */ | 143 | /* rarely changed data like cpu maps */ |
| 116 | READ_MOSTLY_DATA(CONFIG_X86_INTERNODE_CACHE_BYTES) | 144 | READ_MOSTLY_DATA(INTERNODE_CACHE_BYTES) |
| 117 | 145 | ||
| 118 | /* End of data section */ | 146 | /* End of data section */ |
| 119 | _edata = .; | 147 | _edata = .; |
| @@ -137,12 +165,12 @@ SECTIONS | |||
| 137 | *(.vsyscall_0) | 165 | *(.vsyscall_0) |
| 138 | } :user | 166 | } :user |
| 139 | 167 | ||
| 140 | . = ALIGN(CONFIG_X86_L1_CACHE_BYTES); | 168 | . = ALIGN(L1_CACHE_BYTES); |
| 141 | .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { | 169 | .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { |
| 142 | *(.vsyscall_fn) | 170 | *(.vsyscall_fn) |
| 143 | } | 171 | } |
| 144 | 172 | ||
| 145 | . = ALIGN(CONFIG_X86_L1_CACHE_BYTES); | 173 | . = ALIGN(L1_CACHE_BYTES); |
| 146 | .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) { | 174 | .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) { |
| 147 | *(.vsyscall_gtod_data) | 175 | *(.vsyscall_gtod_data) |
| 148 | } | 176 | } |
| @@ -166,7 +194,7 @@ SECTIONS | |||
| 166 | } | 194 | } |
| 167 | vgetcpu_mode = VVIRT(.vgetcpu_mode); | 195 | vgetcpu_mode = VVIRT(.vgetcpu_mode); |
| 168 | 196 | ||
| 169 | . = ALIGN(CONFIG_X86_L1_CACHE_BYTES); | 197 | . = ALIGN(L1_CACHE_BYTES); |
| 170 | .jiffies : AT(VLOAD(.jiffies)) { | 198 | .jiffies : AT(VLOAD(.jiffies)) { |
| 171 | *(.jiffies) | 199 | *(.jiffies) |
| 172 | } | 200 | } |
