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
Unified · Split
| @@ -187,7 +187,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) · 186 unmodified lines | ||
| 187 | 187 | leal boot_heap@GOTOFF(%ebx), %eax |
| 188 | 188 | pushl %eax /* heap area */ |
| 189 | 189 | pushl %esi /* real mode pointer */ |
| 190 | − call extract_kernel /* returns kernel location in %eax */ | |
| 190 | + call extract_kernel /* returns kernel entry point in %eax */ | |
| 191 | 191 | addl $24, %esp |
| 192 | 192 | |
| 193 | 193 | /* |
| @@ -569,7 +569,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) · 568 unmodified lines | ||
| 569 | 569 | movl input_len(%rip), %ecx /* input_len */ |
| 570 | 570 | movq %rbp, %r8 /* output target address */ |
| 571 | 571 | 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 */ | |
| 573 | 573 | popq %rsi |
| 574 | 574 | |
| 575 | 575 | /* |
| @@ -277,7 +277,7 @@ static inline void handle_relocations(void *output, unsigned long output_len, · 276 unmodified lines | ||
| 277 | 277 | { } |
| 278 | 278 | #endif |
| 279 | 279 | |
| 280 | −static void parse_elf(void *output) | |
| 280 | +static size_t parse_elf(void *output) | |
| 281 | 281 | { |
| 282 | 282 | #ifdef CONFIG_X86_64 |
| 283 | 283 | Elf64_Ehdr ehdr; |
| @@ -293,10 +293,8 @@ static void parse_elf(void *output) · 9 unmodified lines | ||
| 293 | 293 | if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || |
| 294 | 294 | ehdr.e_ident[EI_MAG1] != ELFMAG1 || |
| 295 | 295 | ehdr.e_ident[EI_MAG2] != ELFMAG2 || |
| 296 | − ehdr.e_ident[EI_MAG3] != ELFMAG3) { | |
| 296 | + ehdr.e_ident[EI_MAG3] != ELFMAG3) | |
| 297 | 297 | error("Kernel is not a valid ELF file"); |
| 298 | − return; | |
| 299 | − } | |
| 300 | 298 | |
| 301 | 299 | debug_putstr("Parsing ELF... "); |
| 302 | 300 | |
| @@ -328,6 +326,8 @@ static void parse_elf(void *output) · 25 unmodified lines | ||
| 328 | 326 | } |
| 329 | 327 | |
| 330 | 328 | free(phdrs); |
| 329 | + | |
| 330 | + return ehdr.e_entry - LOAD_PHYSICAL_ADDR; | |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /* |
| @@ -356,6 +356,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · 22 unmodified lines | ||
| 356 | 356 | const unsigned long kernel_total_size = VO__end - VO__text; |
| 357 | 357 | unsigned long virt_addr = LOAD_PHYSICAL_ADDR; |
| 358 | 358 | unsigned long needed_size; |
| 359 | + size_t entry_offset; | |
| 359 | 360 | |
| 360 | 361 | /* Retain x86 boot parameters pointer passed from startup_32/64. */ |
| 361 | 362 | boot_params = rmode; |
| @@ -456,14 +457,17 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, · 94 unmodified lines | ||
| 456 | 457 | debug_putstr("\nDecompressing Linux... "); |
| 457 | 458 | __decompress(input_data, input_len, NULL, NULL, output, output_len, |
| 458 | 459 | NULL, error); |
| 459 | − parse_elf(output); | |
| 460 | + entry_offset = parse_elf(output); | |
| 460 | 461 | 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"); | |
| 462 | 466 | |
| 463 | 467 | /* Disable exception handling before booting the kernel */ |
| 464 | 468 | cleanup_exception_handling(); |
| 465 | 469 | |
| 466 | − return output; | |
| 470 | + return output + entry_offset; | |
| 467 | 471 | } |
| 468 | 472 | |
| 469 | 473 | void fortify_panic(const char *name) |
| @@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) · 187 unmodified lines | ||
| 188 | 188 | return cpu; |
| 189 | 189 | } |
| 190 | 190 | |
| 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 | + | |
| 191 | 202 | static int __init |
| 192 | 203 | acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) |
| 193 | 204 | { |
| @@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) · 18 unmodified lines | ||
| 212 | 223 | if (apic_id == 0xffffffff) |
| 213 | 224 | return 0; |
| 214 | 225 | |
| 226 | + /* don't register processors that cannot be onlined */ | |
| 227 | + if (!acpi_is_processor_usable(processor->lapic_flags)) | |
| 228 | + return 0; | |
| 229 | + | |
| 215 | 230 | /* |
| 216 | 231 | * We need to register disabled CPU as well to permit |
| 217 | 232 | * 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 | ||
| 250 | 265 | return 0; |
| 251 | 266 | |
| 252 | 267 | /* 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)) | |
| 256 | 269 | return 0; |
| 257 | 270 | |
| 258 | 271 | /* |
| @@ -42,10 +42,4 @@ arch/s390/kernel/head64.o · 41 unmodified lines | ||
| 42 | 42 | arch/sh/kernel/head_32.o |
| 43 | 43 | arch/sparc/kernel/head_32.o |
| 44 | 44 | 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 | |
| 51 | 45 | arch/xtensa/kernel/head.o |