1
2
3
4
5
6
7
8#include <asm/hyp_image.h>
9#ifdef CONFIG_KVM
10#define HYPERVISOR_EXTABLE \
11 . = ALIGN(SZ_8); \
12 __start___kvm_ex_table = .; \
13 *(__kvm_ex_table) \
14 __stop___kvm_ex_table = .;
15
16#define HYPERVISOR_DATA_SECTIONS \
17 HYP_SECTION_NAME(.rodata) : { \
18 . = ALIGN(PAGE_SIZE); \
19 __hyp_rodata_start = .; \
20 *(HYP_SECTION_NAME(.data..ro_after_init)) \
21 *(HYP_SECTION_NAME(.rodata)) \
22 . = ALIGN(PAGE_SIZE); \
23 __hyp_rodata_end = .; \
24 }
25
26#define HYPERVISOR_PERCPU_SECTION \
27 . = ALIGN(PAGE_SIZE); \
28 HYP_SECTION_NAME(.data..percpu) : { \
29 *(HYP_SECTION_NAME(.data..percpu)) \
30 }
31
32#define HYPERVISOR_RELOC_SECTION \
33 .hyp.reloc : ALIGN(4) { \
34 __hyp_reloc_begin = .; \
35 *(.hyp.reloc) \
36 __hyp_reloc_end = .; \
37 }
38
39#define BSS_FIRST_SECTIONS \
40 __hyp_bss_start = .; \
41 *(HYP_SECTION_NAME(.bss)) \
42 . = ALIGN(PAGE_SIZE); \
43 __hyp_bss_end = .;
44
45
46
47
48
49
50
51#define SBSS_ALIGN PAGE_SIZE
52#else
53#define HYPERVISOR_EXTABLE
54#define HYPERVISOR_DATA_SECTIONS
55#define HYPERVISOR_PERCPU_SECTION
56#define HYPERVISOR_RELOC_SECTION
57#define SBSS_ALIGN 0
58#endif
59
60#define RO_EXCEPTION_TABLE_ALIGN 8
61#define RUNTIME_DISCARD_EXIT
62
63#include <asm-generic/vmlinux.lds.h>
64#include <asm/cache.h>
65#include <asm/kernel-pgtable.h>
66#include <asm/memory.h>
67#include <asm/page.h>
68
69#include "image.h"
70
71OUTPUT_ARCH(aarch64)
72ENTRY(_text)
73
74jiffies = jiffies_64;
75
76#define HYPERVISOR_TEXT \
77 . = ALIGN(PAGE_SIZE); \
78 __hyp_idmap_text_start = .; \
79 *(.hyp.idmap.text) \
80 __hyp_idmap_text_end = .; \
81 __hyp_text_start = .; \
82 *(.hyp.text) \
83 HYPERVISOR_EXTABLE \
84 . = ALIGN(PAGE_SIZE); \
85 __hyp_text_end = .;
86
87#define IDMAP_TEXT \
88 . = ALIGN(SZ_4K); \
89 __idmap_text_start = .; \
90 *(.idmap.text) \
91 __idmap_text_end = .;
92
93#ifdef CONFIG_HIBERNATION
94#define HIBERNATE_TEXT \
95 . = ALIGN(SZ_4K); \
96 __hibernate_exit_text_start = .; \
97 *(.hibernate_exit.text) \
98 __hibernate_exit_text_end = .;
99#else
100#define HIBERNATE_TEXT
101#endif
102
103#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
104#define TRAMP_TEXT \
105 . = ALIGN(PAGE_SIZE); \
106 __entry_tramp_text_start = .; \
107 *(.entry.tramp.text) \
108 . = ALIGN(PAGE_SIZE); \
109 __entry_tramp_text_end = .;
110#else
111#define TRAMP_TEXT
112#endif
113
114
115
116
117
118
119
120
121PECOFF_FILE_ALIGNMENT = 0x200;
122
123#ifdef CONFIG_EFI
124#define PECOFF_EDATA_PADDING \
125 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
126#else
127#define PECOFF_EDATA_PADDING
128#endif
129
130SECTIONS
131{
132
133
134
135
136
137
138 DISCARDS
139 /DISCARD/ : {
140 *(.interp .dynamic)
141 *(.dynsym .dynstr .hash .gnu.hash)
142 }
143
144 . = KIMAGE_VADDR;
145
146 .head.text : {
147 _text = .;
148 HEAD_TEXT
149 }
150 .text : ALIGN(SEGMENT_ALIGN) {
151 _stext = .;
152 IRQENTRY_TEXT
153 SOFTIRQENTRY_TEXT
154 ENTRY_TEXT
155 TEXT_TEXT
156 SCHED_TEXT
157 CPUIDLE_TEXT
158 LOCK_TEXT
159 KPROBES_TEXT
160 HYPERVISOR_TEXT
161 IDMAP_TEXT
162 HIBERNATE_TEXT
163 TRAMP_TEXT
164 *(.fixup)
165 *(.gnu.warning)
166 . = ALIGN(16);
167 *(.got)
168 }
169
170
171
172
173
174 .got.plt : { *(.got.plt) }
175 ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18,
176 "Unexpected GOT/PLT entries detected!")
177
178 . = ALIGN(SEGMENT_ALIGN);
179 _etext = .;
180
181
182 RO_DATA(PAGE_SIZE)
183
184 HYPERVISOR_DATA_SECTIONS
185
186 idmap_pg_dir = .;
187 . += IDMAP_DIR_SIZE;
188 idmap_pg_end = .;
189
190#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
191 tramp_pg_dir = .;
192 . += PAGE_SIZE;
193#endif
194
195 reserved_pg_dir = .;
196 . += PAGE_SIZE;
197
198 swapper_pg_dir = .;
199 . += PAGE_SIZE;
200
201 . = ALIGN(SEGMENT_ALIGN);
202 __init_begin = .;
203 __inittext_begin = .;
204
205 INIT_TEXT_SECTION(8)
206
207 __exittext_begin = .;
208 .exit.text : {
209 EXIT_TEXT
210 }
211 __exittext_end = .;
212
213 . = ALIGN(4);
214 .altinstructions : {
215 __alt_instructions = .;
216 *(.altinstructions)
217 __alt_instructions_end = .;
218 }
219
220 . = ALIGN(SEGMENT_ALIGN);
221 __inittext_end = .;
222 __initdata_begin = .;
223
224 .init.data : {
225 INIT_DATA
226 INIT_SETUP(16)
227 INIT_CALLS
228 CON_INITCALL
229 INIT_RAM_FS
230 *(.init.altinstructions .init.bss)
231 }
232 .exit.data : {
233 EXIT_DATA
234 }
235
236 PERCPU_SECTION(L1_CACHE_BYTES)
237 HYPERVISOR_PERCPU_SECTION
238
239 HYPERVISOR_RELOC_SECTION
240
241 .rela.dyn : ALIGN(8) {
242 *(.rela .rela*)
243 }
244
245 __rela_offset = ABSOLUTE(ADDR(.rela.dyn) - KIMAGE_VADDR);
246 __rela_size = SIZEOF(.rela.dyn);
247
248#ifdef CONFIG_RELR
249 .relr.dyn : ALIGN(8) {
250 *(.relr.dyn)
251 }
252
253 __relr_offset = ABSOLUTE(ADDR(.relr.dyn) - KIMAGE_VADDR);
254 __relr_size = SIZEOF(.relr.dyn);
255#endif
256
257 . = ALIGN(SEGMENT_ALIGN);
258 __initdata_end = .;
259 __init_end = .;
260
261 _data = .;
262 _sdata = .;
263 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
264
265
266
267
268
269
270
271
272
273 .mmuoff.data.write : ALIGN(SZ_2K) {
274 __mmuoff_data_start = .;
275 *(.mmuoff.data.write)
276 }
277 . = ALIGN(SZ_2K);
278 .mmuoff.data.read : {
279 *(.mmuoff.data.read)
280 __mmuoff_data_end = .;
281 }
282
283 PECOFF_EDATA_PADDING
284 __pecoff_data_rawsize = ABSOLUTE(. - __initdata_begin);
285 _edata = .;
286
287 BSS_SECTION(SBSS_ALIGN, 0, 0)
288
289 . = ALIGN(PAGE_SIZE);
290 init_pg_dir = .;
291 . += INIT_DIR_SIZE;
292 init_pg_end = .;
293
294 . = ALIGN(SEGMENT_ALIGN);
295 __pecoff_data_size = ABSOLUTE(. - __initdata_begin);
296 _end = .;
297
298 STABS_DEBUG
299 DWARF_DEBUG
300 ELF_DETAILS
301
302 HEAD_SYMBOLS
303
304
305
306
307
308 .plt : {
309 *(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
310 }
311 ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
312
313 .data.rel.ro : { *(.data.rel.ro) }
314 ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
315}
316
317#include "image-vars.h"
318
319
320
321
322
323
324ASSERT(__hyp_idmap_text_end - __hyp_idmap_text_start <= PAGE_SIZE,
325 "HYP init code too big")
326ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
327 "ID map text too big or misaligned")
328#ifdef CONFIG_HIBERNATION
329ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1))
330 <= SZ_4K, "Hibernate exit text too big or misaligned")
331#endif
332#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
333ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE,
334 "Entry trampoline text too big")
335#endif
336#ifdef CONFIG_KVM
337ASSERT(__hyp_bss_start == __bss_start, "HYP and Host BSS are misaligned")
338#endif
339
340
341
342ASSERT(_text == KIMAGE_VADDR, "HEAD is misaligned")
343
344ASSERT(swapper_pg_dir - reserved_pg_dir == RESERVED_SWAPPER_OFFSET,
345 "RESERVED_SWAPPER_OFFSET is wrong!")
346
347#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
348ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_SWAPPER_OFFSET,
349 "TRAMP_SWAPPER_OFFSET is wrong!")
350#endif
351