forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/x86/kernel/vmlinux.lds.S
....@@ -21,6 +21,10 @@
2121 #define LOAD_OFFSET __START_KERNEL_map
2222 #endif
2323
24
+#define RUNTIME_DISCARD_EXIT
25
+#define EMITS_PT_NOTE
26
+#define RO_EXCEPTION_TABLE_ALIGN 16
27
+
2428 #include <asm-generic/vmlinux.lds.h>
2529 #include <asm/asm-offsets.h>
2630 #include <asm/thread_info.h>
....@@ -31,7 +35,7 @@
3135
3236 #undef i386 /* in case the preprocessor is a 32bit one */
3337
34
-OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
38
+OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT)
3539
3640 #ifdef CONFIG_X86_32
3741 OUTPUT_ARCH(i386)
....@@ -130,39 +134,18 @@
130134 KPROBES_TEXT
131135 ALIGN_ENTRY_TEXT_BEGIN
132136 ENTRY_TEXT
133
- IRQENTRY_TEXT
134137 ALIGN_ENTRY_TEXT_END
135138 SOFTIRQENTRY_TEXT
139
+ STATIC_CALL_TEXT
136140 *(.fixup)
137141 *(.gnu.warning)
138142
139
-#ifdef CONFIG_X86_64
140
- . = ALIGN(PAGE_SIZE);
141
- __entry_trampoline_start = .;
142
- _entry_trampoline = .;
143
- *(.entry_trampoline)
144
- . = ALIGN(PAGE_SIZE);
145
- __entry_trampoline_end = .;
146
- ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big");
147
-#endif
148
-
149143 #ifdef CONFIG_RETPOLINE
150144 __indirect_thunk_start = .;
151
- *(.text.__x86.indirect_thunk)
145
+ *(.text.__x86.*)
152146 __indirect_thunk_end = .;
153147 #endif
154
-
155
-#ifdef CONFIG_CFI_CLANG
156
- . = ALIGN(PAGE_SIZE);
157
- __cfi_jt_start = .;
158
- *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*)
159
- __cfi_jt_end = .;
160
-#endif
161
- } :text = 0x9090
162
-
163
- NOTES :text :note
164
-
165
- EXCEPTION_TABLE(16) :text = 0x9090
148
+ } :text =0xcccc
166149
167150 /* End of text section, which should occupy whole number of pages */
168151 _etext = .;
....@@ -211,12 +194,10 @@
211194 __vvar_beginning_hack = .;
212195
213196 /* Place all vvars at the offsets in asm/vvar.h. */
214
-#define EMIT_VVAR(name, offset) \
197
+#define EMIT_VVAR(name, offset) \
215198 . = __vvar_beginning_hack + offset; \
216199 *(.vvar_ ## name)
217
-#define __VVAR_KERNEL_LDS
218200 #include <asm/vvar.h>
219
-#undef __VVAR_KERNEL_LDS
220201 #undef EMIT_VVAR
221202
222203 /*
....@@ -291,6 +272,27 @@
291272 __parainstructions_end = .;
292273 }
293274
275
+#ifdef CONFIG_RETPOLINE
276
+ /*
277
+ * List of instructions that call/jmp/jcc to retpoline thunks
278
+ * __x86_indirect_thunk_*(). These instructions can be patched along
279
+ * with alternatives, after which the section can be freed.
280
+ */
281
+ . = ALIGN(8);
282
+ .retpoline_sites : AT(ADDR(.retpoline_sites) - LOAD_OFFSET) {
283
+ __retpoline_sites = .;
284
+ *(.retpoline_sites)
285
+ __retpoline_sites_end = .;
286
+ }
287
+
288
+ . = ALIGN(8);
289
+ .return_sites : AT(ADDR(.return_sites) - LOAD_OFFSET) {
290
+ __return_sites = .;
291
+ *(.return_sites)
292
+ __return_sites_end = .;
293
+ }
294
+#endif
295
+
294296 /*
295297 * struct alt_inst entries. From the header (alternative.h):
296298 * "Alternative instructions for different CPU types or capabilities"
....@@ -333,8 +335,8 @@
333335
334336 . = ALIGN(8);
335337 /*
336
- * .exit.text is discard at runtime, not link time, to deal with
337
- * references from .altinstructions and .eh_frame
338
+ * .exit.text is discarded at runtime, not link time, to deal with
339
+ * references from .altinstructions
338340 */
339341 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
340342 EXIT_TEXT
....@@ -385,6 +387,14 @@
385387 __bss_stop = .;
386388 }
387389
390
+ /*
391
+ * The memory occupied from _text to here, __end_of_kernel_reserve, is
392
+ * automatically reserved in setup_arch(). Anything after here must be
393
+ * explicitly reserved using memblock_reserve() or it will be discarded
394
+ * and treated as available memory.
395
+ */
396
+ __end_of_kernel_reserve = .;
397
+
388398 . = ALIGN(PAGE_SIZE);
389399 .brk : AT(ADDR(.brk) - LOAD_OFFSET) {
390400 __brk_base = .;
....@@ -396,16 +406,74 @@
396406 . = ALIGN(PAGE_SIZE); /* keep VO_INIT_SIZE page aligned */
397407 _end = .;
398408
409
+#ifdef CONFIG_AMD_MEM_ENCRYPT
410
+ /*
411
+ * Early scratch/workarea section: Lives outside of the kernel proper
412
+ * (_text - _end).
413
+ *
414
+ * Resides after _end because even though the .brk section is after
415
+ * __end_of_kernel_reserve, the .brk section is later reserved as a
416
+ * part of the kernel. Since it is located after __end_of_kernel_reserve
417
+ * it will be discarded and become part of the available memory. As
418
+ * such, it can only be used by very early boot code and must not be
419
+ * needed afterwards.
420
+ *
421
+ * Currently used by SME for performing in-place encryption of the
422
+ * kernel during boot. Resides on a 2MB boundary to simplify the
423
+ * pagetable setup used for SME in-place encryption.
424
+ */
425
+ . = ALIGN(HPAGE_SIZE);
426
+ .init.scratch : AT(ADDR(.init.scratch) - LOAD_OFFSET) {
427
+ __init_scratch_begin = .;
428
+ *(.init.scratch)
429
+ . = ALIGN(HPAGE_SIZE);
430
+ __init_scratch_end = .;
431
+ }
432
+#endif
433
+
399434 STABS_DEBUG
400435 DWARF_DEBUG
436
+ ELF_DETAILS
401437
402
- /* Sections to be discarded */
403438 DISCARDS
404
- /DISCARD/ : {
405
- *(.eh_frame)
406
- }
407
-}
408439
440
+ /*
441
+ * Make sure that the .got.plt is either completely empty or it
442
+ * contains only the lazy dispatch entries.
443
+ */
444
+ .got.plt (INFO) : { *(.got.plt) }
445
+ ASSERT(SIZEOF(.got.plt) == 0 ||
446
+#ifdef CONFIG_X86_64
447
+ SIZEOF(.got.plt) == 0x18,
448
+#else
449
+ SIZEOF(.got.plt) == 0xc,
450
+#endif
451
+ "Unexpected GOT/PLT entries detected!")
452
+
453
+ /*
454
+ * Sections that should stay zero sized, which is safer to
455
+ * explicitly check instead of blindly discarding.
456
+ */
457
+ .got : {
458
+ *(.got) *(.igot.*)
459
+ }
460
+ ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
461
+
462
+ .plt : {
463
+ *(.plt) *(.plt.*) *(.iplt)
464
+ }
465
+ ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
466
+
467
+ .rel.dyn : {
468
+ *(.rel.*) *(.rel_*)
469
+ }
470
+ ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!")
471
+
472
+ .rela.dyn : {
473
+ *(.rela.*) *(.rela_*)
474
+ }
475
+ ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
476
+}
409477
410478 #ifdef CONFIG_X86_32
411479 /*
....@@ -420,7 +488,8 @@
420488 */
421489 #define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load
422490 INIT_PER_CPU(gdt_page);
423
-INIT_PER_CPU(irq_stack_union);
491
+INIT_PER_CPU(fixed_percpu_data);
492
+INIT_PER_CPU(irq_stack_backing_store);
424493
425494 /*
426495 * Build-time check on the image size:
....@@ -429,8 +498,8 @@
429498 "kernel image bigger than KERNEL_IMAGE_SIZE");
430499
431500 #ifdef CONFIG_SMP
432
-. = ASSERT((irq_stack_union == 0),
433
- "irq_stack_union is not at start of per-cpu area");
501
+. = ASSERT((fixed_percpu_data == 0),
502
+ "fixed_percpu_data is not at start of per-cpu area");
434503 #endif
435504
436505 #endif /* CONFIG_X86_32 */