0001
0002
0003
0004
0005
0006
0007
0008 #include <asm/hyp_image.h>
0009 #ifdef CONFIG_KVM
0010 #define HYPERVISOR_EXTABLE \
0011 . = ALIGN(SZ_8); \
0012 __start___kvm_ex_table = .; \
0013 *(__kvm_ex_table) \
0014 __stop___kvm_ex_table = .;
0015
0016 #define HYPERVISOR_DATA_SECTIONS \
0017 HYP_SECTION_NAME(.rodata) : { \
0018 . = ALIGN(PAGE_SIZE); \
0019 __hyp_rodata_start = .; \
0020 *(HYP_SECTION_NAME(.data..ro_after_init)) \
0021 *(HYP_SECTION_NAME(.rodata)) \
0022 . = ALIGN(PAGE_SIZE); \
0023 __hyp_rodata_end = .; \
0024 }
0025
0026 #define HYPERVISOR_PERCPU_SECTION \
0027 . = ALIGN(PAGE_SIZE); \
0028 HYP_SECTION_NAME(.data..percpu) : { \
0029 *(HYP_SECTION_NAME(.data..percpu)) \
0030 }
0031
0032 #define HYPERVISOR_RELOC_SECTION \
0033 .hyp.reloc : ALIGN(4) { \
0034 __hyp_reloc_begin = .; \
0035 *(.hyp.reloc) \
0036 __hyp_reloc_end = .; \
0037 }
0038
0039 #define BSS_FIRST_SECTIONS \
0040 __hyp_bss_start = .; \
0041 *(HYP_SECTION_NAME(.bss)) \
0042 . = ALIGN(PAGE_SIZE); \
0043 __hyp_bss_end = .;
0044
0045
0046
0047
0048
0049
0050
0051 #define SBSS_ALIGN PAGE_SIZE
0052 #else
0053 #define HYPERVISOR_EXTABLE
0054 #define HYPERVISOR_DATA_SECTIONS
0055 #define HYPERVISOR_PERCPU_SECTION
0056 #define HYPERVISOR_RELOC_SECTION
0057 #define SBSS_ALIGN 0
0058 #endif
0059
0060 #define RO_EXCEPTION_TABLE_ALIGN 4
0061 #define RUNTIME_DISCARD_EXIT
0062
0063 #include <asm-generic/vmlinux.lds.h>
0064 #include <asm/cache.h>
0065 #include <asm/kernel-pgtable.h>
0066 #include <asm/kexec.h>
0067 #include <asm/memory.h>
0068 #include <asm/page.h>
0069
0070 #include "image.h"
0071
0072 OUTPUT_ARCH(aarch64)
0073 ENTRY(_text)
0074
0075 jiffies = jiffies_64;
0076
0077 #define HYPERVISOR_TEXT \
0078 . = ALIGN(PAGE_SIZE); \
0079 __hyp_idmap_text_start = .; \
0080 *(.hyp.idmap.text) \
0081 __hyp_idmap_text_end = .; \
0082 __hyp_text_start = .; \
0083 *(.hyp.text) \
0084 HYPERVISOR_EXTABLE \
0085 . = ALIGN(PAGE_SIZE); \
0086 __hyp_text_end = .;
0087
0088 #define IDMAP_TEXT \
0089 . = ALIGN(SZ_4K); \
0090 __idmap_text_start = .; \
0091 *(.idmap.text) \
0092 __idmap_text_end = .;
0093
0094 #ifdef CONFIG_HIBERNATION
0095 #define HIBERNATE_TEXT \
0096 __hibernate_exit_text_start = .; \
0097 *(.hibernate_exit.text) \
0098 __hibernate_exit_text_end = .;
0099 #else
0100 #define HIBERNATE_TEXT
0101 #endif
0102
0103 #ifdef CONFIG_KEXEC_CORE
0104 #define KEXEC_TEXT \
0105 __relocate_new_kernel_start = .; \
0106 *(.kexec_relocate.text) \
0107 __relocate_new_kernel_end = .;
0108 #else
0109 #define KEXEC_TEXT
0110 #endif
0111
0112 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
0113 #define TRAMP_TEXT \
0114 . = ALIGN(PAGE_SIZE); \
0115 __entry_tramp_text_start = .; \
0116 *(.entry.tramp.text) \
0117 . = ALIGN(PAGE_SIZE); \
0118 __entry_tramp_text_end = .; \
0119 *(.entry.tramp.rodata)
0120 #else
0121 #define TRAMP_TEXT
0122 #endif
0123
0124
0125
0126
0127
0128
0129
0130
0131 PECOFF_FILE_ALIGNMENT = 0x200;
0132
0133 #ifdef CONFIG_EFI
0134 #define PECOFF_EDATA_PADDING \
0135 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
0136 #else
0137 #define PECOFF_EDATA_PADDING
0138 #endif
0139
0140 SECTIONS
0141 {
0142
0143
0144
0145
0146
0147
0148 DISCARDS
0149 /DISCARD/ : {
0150 *(.interp .dynamic)
0151 *(.dynsym .dynstr .hash .gnu.hash)
0152 }
0153
0154 . = KIMAGE_VADDR;
0155
0156 .head.text : {
0157 _text = .;
0158 HEAD_TEXT
0159 }
0160 .text : ALIGN(SEGMENT_ALIGN) {
0161 _stext = .;
0162 IRQENTRY_TEXT
0163 SOFTIRQENTRY_TEXT
0164 ENTRY_TEXT
0165 TEXT_TEXT
0166 SCHED_TEXT
0167 CPUIDLE_TEXT
0168 LOCK_TEXT
0169 KPROBES_TEXT
0170 HYPERVISOR_TEXT
0171 IDMAP_TEXT
0172 *(.gnu.warning)
0173 . = ALIGN(16);
0174 *(.got)
0175 }
0176
0177
0178
0179
0180
0181 .got.plt : { *(.got.plt) }
0182 ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18,
0183 "Unexpected GOT/PLT entries detected!")
0184
0185 . = ALIGN(SEGMENT_ALIGN);
0186 _etext = .;
0187
0188
0189 RO_DATA(PAGE_SIZE)
0190
0191 HYPERVISOR_DATA_SECTIONS
0192
0193
0194 .rodata.text : {
0195 TRAMP_TEXT
0196 HIBERNATE_TEXT
0197 KEXEC_TEXT
0198 . = ALIGN(PAGE_SIZE);
0199 }
0200
0201 idmap_pg_dir = .;
0202 . += PAGE_SIZE;
0203
0204 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
0205 tramp_pg_dir = .;
0206 . += PAGE_SIZE;
0207 #endif
0208
0209 reserved_pg_dir = .;
0210 . += PAGE_SIZE;
0211
0212 swapper_pg_dir = .;
0213 . += PAGE_SIZE;
0214
0215 . = ALIGN(SEGMENT_ALIGN);
0216 __init_begin = .;
0217 __inittext_begin = .;
0218
0219 INIT_TEXT_SECTION(8)
0220
0221 __exittext_begin = .;
0222 .exit.text : {
0223 EXIT_TEXT
0224 }
0225 __exittext_end = .;
0226
0227 . = ALIGN(4);
0228 .altinstructions : {
0229 __alt_instructions = .;
0230 *(.altinstructions)
0231 __alt_instructions_end = .;
0232 }
0233
0234 . = ALIGN(SEGMENT_ALIGN);
0235 __inittext_end = .;
0236 __initdata_begin = .;
0237
0238 init_idmap_pg_dir = .;
0239 . += INIT_IDMAP_DIR_SIZE;
0240 init_idmap_pg_end = .;
0241
0242 .init.data : {
0243 INIT_DATA
0244 INIT_SETUP(16)
0245 INIT_CALLS
0246 CON_INITCALL
0247 INIT_RAM_FS
0248 *(.init.altinstructions .init.bss)
0249 }
0250 .exit.data : {
0251 EXIT_DATA
0252 }
0253
0254 PERCPU_SECTION(L1_CACHE_BYTES)
0255 HYPERVISOR_PERCPU_SECTION
0256
0257 HYPERVISOR_RELOC_SECTION
0258
0259 .rela.dyn : ALIGN(8) {
0260 __rela_start = .;
0261 *(.rela .rela*)
0262 __rela_end = .;
0263 }
0264
0265 .relr.dyn : ALIGN(8) {
0266 __relr_start = .;
0267 *(.relr.dyn)
0268 __relr_end = .;
0269 }
0270
0271 . = ALIGN(SEGMENT_ALIGN);
0272 __initdata_end = .;
0273 __init_end = .;
0274
0275 _data = .;
0276 _sdata = .;
0277 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287 .mmuoff.data.write : ALIGN(SZ_2K) {
0288 __mmuoff_data_start = .;
0289 *(.mmuoff.data.write)
0290 }
0291 . = ALIGN(SZ_2K);
0292 .mmuoff.data.read : {
0293 *(.mmuoff.data.read)
0294 __mmuoff_data_end = .;
0295 }
0296
0297 PECOFF_EDATA_PADDING
0298 __pecoff_data_rawsize = ABSOLUTE(. - __initdata_begin);
0299 _edata = .;
0300
0301 BSS_SECTION(SBSS_ALIGN, 0, 0)
0302
0303 . = ALIGN(PAGE_SIZE);
0304 init_pg_dir = .;
0305 . += INIT_DIR_SIZE;
0306 init_pg_end = .;
0307
0308 . = ALIGN(SEGMENT_ALIGN);
0309 __pecoff_data_size = ABSOLUTE(. - __initdata_begin);
0310 _end = .;
0311
0312 STABS_DEBUG
0313 DWARF_DEBUG
0314 ELF_DETAILS
0315
0316 HEAD_SYMBOLS
0317
0318
0319
0320
0321
0322 .plt : {
0323 *(.plt) *(.plt.*) *(.iplt) *(.igot .igot.plt)
0324 }
0325 ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
0326
0327 .data.rel.ro : { *(.data.rel.ro) }
0328 ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
0329 }
0330
0331 #include "image-vars.h"
0332
0333
0334
0335
0336
0337
0338 ASSERT(__hyp_idmap_text_end - __hyp_idmap_text_start <= PAGE_SIZE,
0339 "HYP init code too big")
0340 ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
0341 "ID map text too big or misaligned")
0342 #ifdef CONFIG_HIBERNATION
0343 ASSERT(__hibernate_exit_text_end - __hibernate_exit_text_start <= SZ_4K,
0344 "Hibernate exit text is bigger than 4 KiB")
0345 #endif
0346 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
0347 ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE,
0348 "Entry trampoline text too big")
0349 #endif
0350 #ifdef CONFIG_KVM
0351 ASSERT(__hyp_bss_start == __bss_start, "HYP and Host BSS are misaligned")
0352 #endif
0353
0354
0355
0356 ASSERT(_text == KIMAGE_VADDR, "HEAD is misaligned")
0357
0358 ASSERT(swapper_pg_dir - reserved_pg_dir == RESERVED_SWAPPER_OFFSET,
0359 "RESERVED_SWAPPER_OFFSET is wrong!")
0360
0361 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
0362 ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_SWAPPER_OFFSET,
0363 "TRAMP_SWAPPER_OFFSET is wrong!")
0364 #endif
0365
0366 #ifdef CONFIG_KEXEC_CORE
0367
0368 ASSERT(__relocate_new_kernel_end - __relocate_new_kernel_start <= SZ_4K,
0369 "kexec relocation code is bigger than 4 KiB")
0370 ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXEC_CONTROL_PAGE_SIZE is broken")
0371 #endif