History

Merge tag 'x86-boot-2023-02-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 boot updates from Ingo Molnar: - Robustify/fix calling startup_{32,64}() from the decompressor code, and removing x86 quirk from scripts/head-object-list.txt as a result. - Do not register processors that cannot be onlined for x2APIC * tag 'x86-boot-2023-02-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/acpi/boot: Do not register processors that cannot be onlined for x2APIC scripts/head-object-list: Remove x86 from the list x86/boot: Robustify calling startup_{32,64}() from the decompressor code

Linus Torvalds committed 3 years ago

Commit 35011c62 parents 6be3daf e2869bd5 files · +29 −18Browse files

Unified · Split

5 files
  1. arch/x86/boot/compressed/head_32.S +1 −1
  2. arch/x86/boot/compressed/head_64.S +1 −1
  3. arch/x86/boot/compressed/misc.c +11 −7
  4. arch/x86/kernel/acpi/boot.c +16 −3
  5. scripts/head-object-list.txt +0 −6
arch/x86/boot/compressed/head_32.S+1−1
@@ -187,7 +187,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) · 186 unmodified lines
187187 leal boot_heap@GOTOFF(%ebx), %eax
188188 pushl %eax /* heap area */
189189 pushl %esi /* real mode pointer */
190− call extract_kernel /* returns kernel location in %eax */
190+ call extract_kernel /* returns kernel entry point in %eax */
191191 addl $24, %esp
192192
193193 /*
arch/x86/boot/compressed/head_64.S+1−1
@@ -569,7 +569,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) · 568 unmodified lines
569569 movl input_len(%rip), %ecx /* input_len */
570570 movq %rbp, %r8 /* output target address */
571571 movl output_len(%rip), %r9d /* decompressed length, end of relocs */
572− call extract_kernel /* returns kernel location in %rax */
572+ call extract_kernel /* returns kernel entry point in %rax */
573573 popq %rsi
574574
575575 /*
arch/x86/boot/compressed/misc.c+11−7
@@ -277,7 +277,7 @@ static inline void handle_relocations(void *output, unsigned long output_len, · 276 unmodified lines
277277 { }
278278 #endif
279279
280−static void parse_elf(void *output)
280+static size_t parse_elf(void *output)
281281 {
282282 #ifdef CONFIG_X86_64
283283 Elf64_Ehdr ehdr;
@@ -293,10 +293,8 @@ static void parse_elf(void *output) · 9 unmodified lines
293293 if (ehdr.e_ident[EI_MAG0] != ELFMAG0 ||
294294 ehdr.e_ident[EI_MAG1] != ELFMAG1 ||
295295 ehdr.e_ident[EI_MAG2] != ELFMAG2 ||
296− ehdr.e_ident[EI_MAG3] != ELFMAG3) {
296+ ehdr.e_ident[EI_MAG3] != ELFMAG3)
297297 error("Kernel is not a valid ELF file");
298− return;
299− }
300298
301299 debug_putstr("Parsing ELF... ");
302300
@@ -328,6 +326,8 @@ static void parse_elf(void *output) · 25 unmodified lines
328326 }
329327
330328 free(phdrs);
329+
330+ return ehdr.e_entry - LOAD_PHYSICAL_ADDR;
331331 }
332332
333333 /*
@@ -356,6 +356,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · 22 unmodified lines
356356 const unsigned long kernel_total_size = VO__end - VO__text;
357357 unsigned long virt_addr = LOAD_PHYSICAL_ADDR;
358358 unsigned long needed_size;
359+ size_t entry_offset;
359360
360361 /* Retain x86 boot parameters pointer passed from startup_32/64. */
361362 boot_params = rmode;
@@ -456,14 +457,17 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · 94 unmodified lines
456457 debug_putstr("\nDecompressing Linux... ");
457458 __decompress(input_data, input_len, NULL, NULL, output, output_len,
458459 NULL, error);
459− parse_elf(output);
460+ entry_offset = parse_elf(output);
460461 handle_relocations(output, output_len, virt_addr);
461− debug_putstr("done.\nBooting the kernel.\n");
462+
463+ debug_putstr("done.\nBooting the kernel (entry_offset: 0x");
464+ debug_puthex(entry_offset);
465+ debug_putstr(").\n");
462466
463467 /* Disable exception handling before booting the kernel */
464468 cleanup_exception_handling();
465469
466− return output;
470+ return output + entry_offset;
467471 }
468472
469473 void fortify_panic(const char *name)
arch/x86/kernel/acpi/boot.c+16−3
@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) · 187 unmodified lines
188188 return cpu;
189189 }
190190
191+static bool __init acpi_is_processor_usable(u32 lapic_flags)
192+{
193+ if (lapic_flags & ACPI_MADT_ENABLED)
194+ return true;
195+
196+ if (acpi_support_online_capable && (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
197+ return true;
198+
199+ return false;
200+}
201+
191202 static int __init
192203 acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
193204 {
@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) · 18 unmodified lines
212223 if (apic_id == 0xffffffff)
213224 return 0;
214225
226+ /* don't register processors that cannot be onlined */
227+ if (!acpi_is_processor_usable(processor->lapic_flags))
228+ return 0;
229+
215230 /*
216231 * We need to register disabled CPU as well to permit
217232 * counting disabled CPUs. This allows us to size
@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end) · 32 unmodified lines
250265 return 0;
251266
252267 /* don't register processors that can not be onlined */
253− if (acpi_support_online_capable &&
254− !(processor->lapic_flags & ACPI_MADT_ENABLED) &&
255− !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
268+ if (!acpi_is_processor_usable(processor->lapic_flags))
256269 return 0;
257270
258271 /*
scripts/head-object-list.txt+0−6
@@ -42,10 +42,4 @@ arch/s390/kernel/head64.o · 41 unmodified lines
4242 arch/sh/kernel/head_32.o
4343 arch/sparc/kernel/head_32.o
4444 arch/sparc/kernel/head_64.o
45−arch/x86/kernel/head_32.o
46−arch/x86/kernel/head_64.o
47−arch/x86/kernel/head32.o
48−arch/x86/kernel/head64.o
49−arch/x86/kernel/ebda.o
50−arch/x86/kernel/platform-quirks.o
5145 arch/xtensa/kernel/head.o