hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/kernel/head_32.S
....@@ -23,6 +23,7 @@
2323 #include <asm/cpufeatures.h>
2424 #include <asm/percpu.h>
2525 #include <asm/nops.h>
26
+#include <asm/nospec-branch.h>
2627 #include <asm/bootparam.h>
2728 #include <asm/export.h>
2829 #include <asm/pgtable_32.h>
....@@ -64,14 +65,9 @@
6465 * can.
6566 */
6667 __HEAD
67
-ENTRY(startup_32)
68
+SYM_CODE_START(startup_32)
6869 movl pa(initial_stack),%ecx
6970
70
- /* test KEEP_SEGMENTS flag to see if the bootloader is asking
71
- us to not reload segments */
72
- testb $KEEP_SEGMENTS, BP_loadflags(%esi)
73
- jnz 2f
74
-
7571 /*
7672 * Set segments to known values.
7773 */
....@@ -82,7 +78,6 @@
8278 movl %eax,%fs
8379 movl %eax,%gs
8480 movl %eax,%ss
85
-2:
8681 leal -__PAGE_OFFSET(%ecx),%esp
8782
8883 /*
....@@ -140,38 +135,8 @@
140135 movl %eax,pa(initial_page_table+0xffc)
141136 #endif
142137
143
-#ifdef CONFIG_PARAVIRT
144
- /* This is can only trip for a broken bootloader... */
145
- cmpw $0x207, pa(boot_params + BP_version)
146
- jb .Ldefault_entry
147
-
148
- /* Paravirt-compatible boot parameters. Look to see what architecture
149
- we're booting under. */
150
- movl pa(boot_params + BP_hardware_subarch), %eax
151
- cmpl $num_subarch_entries, %eax
152
- jae .Lbad_subarch
153
-
154
- movl pa(subarch_entries)(,%eax,4), %eax
155
- subl $__PAGE_OFFSET, %eax
156
- jmp *%eax
157
-
158
-.Lbad_subarch:
159
-WEAK(xen_entry)
160
- /* Unknown implementation; there's really
161
- nothing we can do at this point. */
162
- ud2a
163
-
164
- __INITDATA
165
-
166
-subarch_entries:
167
- .long .Ldefault_entry /* normal x86/PC */
168
- .long xen_entry /* Xen hypervisor */
169
- .long .Ldefault_entry /* Moorestown MID */
170
-num_subarch_entries = (. - subarch_entries) / 4
171
-.previous
172
-#else
173138 jmp .Ldefault_entry
174
-#endif /* CONFIG_PARAVIRT */
139
+SYM_CODE_END(startup_32)
175140
176141 #ifdef CONFIG_HOTPLUG_CPU
177142 /*
....@@ -179,12 +144,12 @@
179144 * up already except stack. We just set up stack here. Then call
180145 * start_secondary().
181146 */
182
-ENTRY(start_cpu0)
147
+SYM_FUNC_START(start_cpu0)
183148 movl initial_stack, %ecx
184149 movl %ecx, %esp
185150 call *(initial_code)
186151 1: jmp 1b
187
-ENDPROC(start_cpu0)
152
+SYM_FUNC_END(start_cpu0)
188153 #endif
189154
190155 /*
....@@ -195,7 +160,7 @@
195160 * If cpu hotplug is not supported then this code can go in init section
196161 * which will be freed later
197162 */
198
-ENTRY(startup_32_smp)
163
+SYM_FUNC_START(startup_32_smp)
199164 cld
200165 movl $(__BOOT_DS),%eax
201166 movl %eax,%ds
....@@ -362,7 +327,7 @@
362327
363328 call *(initial_code)
364329 1: jmp 1b
365
-ENDPROC(startup_32_smp)
330
+SYM_FUNC_END(startup_32_smp)
366331
367332 #include "verify_cpu.S"
368333
....@@ -390,9 +355,9 @@
390355 #endif
391356
392357 andl $0,setup_once_ref /* Once is enough, thanks */
393
- ret
358
+ RET
394359
395
-ENTRY(early_idt_handler_array)
360
+SYM_FUNC_START(early_idt_handler_array)
396361 # 36(%esp) %eflags
397362 # 32(%esp) %cs
398363 # 28(%esp) %eip
....@@ -407,9 +372,9 @@
407372 i = i + 1
408373 .fill early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE - ., 1, 0xcc
409374 .endr
410
-ENDPROC(early_idt_handler_array)
375
+SYM_FUNC_END(early_idt_handler_array)
411376
412
-early_idt_handler_common:
377
+SYM_CODE_START_LOCAL(early_idt_handler_common)
413378 /*
414379 * The stack is the hardware frame, an error code or zero, and the
415380 * vector number.
....@@ -460,10 +425,10 @@
460425 decl %ss:early_recursion_flag
461426 addl $4, %esp /* pop pt_regs->orig_ax */
462427 iret
463
-ENDPROC(early_idt_handler_common)
428
+SYM_CODE_END(early_idt_handler_common)
464429
465430 /* This is the default interrupt "handler" :-) */
466
-ENTRY(early_ignore_irq)
431
+SYM_FUNC_START(early_ignore_irq)
467432 cld
468433 #ifdef CONFIG_PRINTK
469434 pushl %eax
....@@ -498,19 +463,16 @@
498463 hlt_loop:
499464 hlt
500465 jmp hlt_loop
501
-ENDPROC(early_ignore_irq)
466
+SYM_FUNC_END(early_ignore_irq)
502467
503468 __INITDATA
504469 .align 4
505
-GLOBAL(early_recursion_flag)
506
- .long 0
470
+SYM_DATA(early_recursion_flag, .long 0)
507471
508472 __REFDATA
509473 .align 4
510
-ENTRY(initial_code)
511
- .long i386_start_kernel
512
-ENTRY(setup_once_ref)
513
- .long setup_once
474
+SYM_DATA(initial_code, .long i386_start_kernel)
475
+SYM_DATA(setup_once_ref, .long setup_once)
514476
515477 #ifdef CONFIG_PAGE_TABLE_ISOLATION
516478 #define PGD_ALIGN (2 * PAGE_SIZE)
....@@ -553,7 +515,7 @@
553515 __PAGE_ALIGNED_DATA
554516 /* Page-aligned for the benefit of paravirt? */
555517 .align PGD_ALIGN
556
-ENTRY(initial_page_table)
518
+SYM_DATA_START(initial_page_table)
557519 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
558520 # if KPMDS == 3
559521 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
....@@ -571,17 +533,28 @@
571533 # error "Kernel PMDs should be 1, 2 or 3"
572534 # endif
573535 .align PAGE_SIZE /* needs to be page-sized too */
536
+
537
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
538
+ /*
539
+ * PTI needs another page so sync_initial_pagetable() works correctly
540
+ * and does not scribble over the data which is placed behind the
541
+ * actual initial_page_table. See clone_pgd_range().
542
+ */
543
+ .fill 1024, 4, 0
544
+#endif
545
+
546
+SYM_DATA_END(initial_page_table)
574547 #endif
575548
576549 .data
577550 .balign 4
578
-ENTRY(initial_stack)
579
- /*
580
- * The SIZEOF_PTREGS gap is a convention which helps the in-kernel
581
- * unwinder reliably detect the end of the stack.
582
- */
583
- .long init_thread_union + THREAD_SIZE - SIZEOF_PTREGS - \
584
- TOP_OF_KERNEL_STACK_PADDING;
551
+/*
552
+ * The SIZEOF_PTREGS gap is a convention which helps the in-kernel unwinder
553
+ * reliably detect the end of the stack.
554
+ */
555
+SYM_DATA(initial_stack,
556
+ .long init_thread_union + THREAD_SIZE -
557
+ SIZEOF_PTREGS - TOP_OF_KERNEL_STACK_PADDING)
585558
586559 __INITRODATA
587560 int_msg:
....@@ -597,27 +570,28 @@
597570 */
598571
599572 .data
600
-.globl boot_gdt_descr
601
-
602573 ALIGN
603574 # early boot GDT descriptor (must use 1:1 address mapping)
604575 .word 0 # 32 bit align gdt_desc.address
605
-boot_gdt_descr:
576
+SYM_DATA_START_LOCAL(boot_gdt_descr)
606577 .word __BOOT_DS+7
607578 .long boot_gdt - __PAGE_OFFSET
579
+SYM_DATA_END(boot_gdt_descr)
608580
609581 # boot GDT descriptor (later on used by CPU#0):
610582 .word 0 # 32 bit align gdt_desc.address
611
-ENTRY(early_gdt_descr)
583
+SYM_DATA_START(early_gdt_descr)
612584 .word GDT_ENTRIES*8-1
613585 .long gdt_page /* Overwritten for secondary CPUs */
586
+SYM_DATA_END(early_gdt_descr)
614587
615588 /*
616589 * The boot_gdt must mirror the equivalent in setup.S and is
617590 * used only for booting.
618591 */
619592 .align L1_CACHE_BYTES
620
-ENTRY(boot_gdt)
593
+SYM_DATA_START(boot_gdt)
621594 .fill GDT_ENTRY_BOOT_CS,8,0
622595 .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
623596 .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
597
+SYM_DATA_END(boot_gdt)