mm: reorder includes after introduction of linux/pgtable.h
[sfrench/cifs-2.6.git] / arch / arm64 / kernel / vmlinux.lds.S
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * ld script to make ARM Linux kernel
4  * taken from the i386 version by Russell King
5  * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6  */
7
8 #define RO_EXCEPTION_TABLE_ALIGN        8
9
10 #include <asm-generic/vmlinux.lds.h>
11 #include <asm/cache.h>
12 #include <asm/kernel-pgtable.h>
13 #include <asm/thread_info.h>
14 #include <asm/memory.h>
15 #include <asm/page.h>
16
17 #include "image.h"
18
19 OUTPUT_ARCH(aarch64)
20 ENTRY(_text)
21
22 jiffies = jiffies_64;
23
24 #define HYPERVISOR_TEXT                                 \
25         /*                                              \
26          * Align to 4 KB so that                        \
27          * a) the HYP vector table is at its minimum    \
28          *    alignment of 2048 bytes                   \
29          * b) the HYP init code will not cross a page   \
30          *    boundary if its size does not exceed      \
31          *    4 KB (see related ASSERT() below)         \
32          */                                             \
33         . = ALIGN(SZ_4K);                               \
34         __hyp_idmap_text_start = .;                     \
35         *(.hyp.idmap.text)                              \
36         __hyp_idmap_text_end = .;                       \
37         __hyp_text_start = .;                           \
38         *(.hyp.text)                                    \
39         __hyp_text_end = .;
40
41 #define IDMAP_TEXT                                      \
42         . = ALIGN(SZ_4K);                               \
43         __idmap_text_start = .;                         \
44         *(.idmap.text)                                  \
45         __idmap_text_end = .;
46
47 #ifdef CONFIG_HIBERNATION
48 #define HIBERNATE_TEXT                                  \
49         . = ALIGN(SZ_4K);                               \
50         __hibernate_exit_text_start = .;                \
51         *(.hibernate_exit.text)                         \
52         __hibernate_exit_text_end = .;
53 #else
54 #define HIBERNATE_TEXT
55 #endif
56
57 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
58 #define TRAMP_TEXT                                      \
59         . = ALIGN(PAGE_SIZE);                           \
60         __entry_tramp_text_start = .;                   \
61         *(.entry.tramp.text)                            \
62         . = ALIGN(PAGE_SIZE);                           \
63         __entry_tramp_text_end = .;
64 #else
65 #define TRAMP_TEXT
66 #endif
67
68 /*
69  * The size of the PE/COFF section that covers the kernel image, which
70  * runs from _stext to _edata, must be a round multiple of the PE/COFF
71  * FileAlignment, which we set to its minimum value of 0x200. '_stext'
72  * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
73  * boundary should be sufficient.
74  */
75 PECOFF_FILE_ALIGNMENT = 0x200;
76
77 #ifdef CONFIG_EFI
78 #define PECOFF_EDATA_PADDING    \
79         .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
80 #else
81 #define PECOFF_EDATA_PADDING
82 #endif
83
84 SECTIONS
85 {
86         /*
87          * XXX: The linker does not define how output sections are
88          * assigned to input sections when there are multiple statements
89          * matching the same input section name.  There is no documented
90          * order of matching.
91          */
92         /DISCARD/ : {
93                 EXIT_CALL
94                 *(.discard)
95                 *(.discard.*)
96                 *(.interp .dynamic)
97                 *(.dynsym .dynstr .hash .gnu.hash)
98                 *(.eh_frame)
99         }
100
101         . = KIMAGE_VADDR + TEXT_OFFSET;
102
103         .head.text : {
104                 _text = .;
105                 HEAD_TEXT
106         }
107         .text : {                       /* Real text segment            */
108                 _stext = .;             /* Text and read-only data      */
109                         IRQENTRY_TEXT
110                         SOFTIRQENTRY_TEXT
111                         ENTRY_TEXT
112                         TEXT_TEXT
113                         SCHED_TEXT
114                         CPUIDLE_TEXT
115                         LOCK_TEXT
116                         KPROBES_TEXT
117                         HYPERVISOR_TEXT
118                         IDMAP_TEXT
119                         HIBERNATE_TEXT
120                         TRAMP_TEXT
121                         *(.fixup)
122                         *(.gnu.warning)
123                 . = ALIGN(16);
124                 *(.got)                 /* Global offset table          */
125         }
126
127         . = ALIGN(SEGMENT_ALIGN);
128         _etext = .;                     /* End of text section */
129
130         /* everything from this point to __init_begin will be marked RO NX */
131         RO_DATA(PAGE_SIZE)
132
133         idmap_pg_dir = .;
134         . += IDMAP_DIR_SIZE;
135         idmap_pg_end = .;
136
137 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
138         tramp_pg_dir = .;
139         . += PAGE_SIZE;
140 #endif
141
142 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
143         reserved_ttbr0 = .;
144         . += RESERVED_TTBR0_SIZE;
145 #endif
146         swapper_pg_dir = .;
147         . += PAGE_SIZE;
148         swapper_pg_end = .;
149
150         . = ALIGN(SEGMENT_ALIGN);
151         __init_begin = .;
152         __inittext_begin = .;
153
154         INIT_TEXT_SECTION(8)
155
156         __exittext_begin = .;
157         .exit.text : {
158                 EXIT_TEXT
159         }
160         __exittext_end = .;
161
162         . = ALIGN(4);
163         .altinstructions : {
164                 __alt_instructions = .;
165                 *(.altinstructions)
166                 __alt_instructions_end = .;
167         }
168         .altinstr_replacement : {
169                 *(.altinstr_replacement)
170         }
171
172         . = ALIGN(SEGMENT_ALIGN);
173         __inittext_end = .;
174         __initdata_begin = .;
175
176         .init.data : {
177                 INIT_DATA
178                 INIT_SETUP(16)
179                 INIT_CALLS
180                 CON_INITCALL
181                 INIT_RAM_FS
182                 *(.init.rodata.* .init.bss)     /* from the EFI stub */
183         }
184         .exit.data : {
185                 EXIT_DATA
186         }
187
188         PERCPU_SECTION(L1_CACHE_BYTES)
189
190         .rela.dyn : ALIGN(8) {
191                 *(.rela .rela*)
192         }
193
194         __rela_offset   = ABSOLUTE(ADDR(.rela.dyn) - KIMAGE_VADDR);
195         __rela_size     = SIZEOF(.rela.dyn);
196
197 #ifdef CONFIG_RELR
198         .relr.dyn : ALIGN(8) {
199                 *(.relr.dyn)
200         }
201
202         __relr_offset   = ABSOLUTE(ADDR(.relr.dyn) - KIMAGE_VADDR);
203         __relr_size     = SIZEOF(.relr.dyn);
204 #endif
205
206         . = ALIGN(SEGMENT_ALIGN);
207         __initdata_end = .;
208         __init_end = .;
209
210         _data = .;
211         _sdata = .;
212         RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
213
214         /*
215          * Data written with the MMU off but read with the MMU on requires
216          * cache lines to be invalidated, discarding up to a Cache Writeback
217          * Granule (CWG) of data from the cache. Keep the section that
218          * requires this type of maintenance to be in its own Cache Writeback
219          * Granule (CWG) area so the cache maintenance operations don't
220          * interfere with adjacent data.
221          */
222         .mmuoff.data.write : ALIGN(SZ_2K) {
223                 __mmuoff_data_start = .;
224                 *(.mmuoff.data.write)
225         }
226         . = ALIGN(SZ_2K);
227         .mmuoff.data.read : {
228                 *(.mmuoff.data.read)
229                 __mmuoff_data_end = .;
230         }
231
232         PECOFF_EDATA_PADDING
233         __pecoff_data_rawsize = ABSOLUTE(. - __initdata_begin);
234         _edata = .;
235
236         BSS_SECTION(0, 0, 0)
237
238         . = ALIGN(PAGE_SIZE);
239         init_pg_dir = .;
240         . += INIT_DIR_SIZE;
241         init_pg_end = .;
242
243         . = ALIGN(SEGMENT_ALIGN);
244         __pecoff_data_size = ABSOLUTE(. - __initdata_begin);
245         _end = .;
246
247         STABS_DEBUG
248
249         HEAD_SYMBOLS
250 }
251
252 #include "image-vars.h"
253
254 /*
255  * The HYP init code and ID map text can't be longer than a page each,
256  * and should not cross a page boundary.
257  */
258 ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
259         "HYP init code too big or misaligned")
260 ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
261         "ID map text too big or misaligned")
262 #ifdef CONFIG_HIBERNATION
263 ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1))
264         <= SZ_4K, "Hibernate exit text too big or misaligned")
265 #endif
266 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
267 ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE,
268         "Entry trampoline text too big")
269 #endif
270 /*
271  * If padding is applied before .head.text, virt<->phys conversions will fail.
272  */
273 ASSERT(_text == (KIMAGE_VADDR + TEXT_OFFSET), "HEAD is misaligned")