Commit 35011c67 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 6be3dafc e2869bd7
...@@ -187,7 +187,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) ...@@ -187,7 +187,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
leal boot_heap@GOTOFF(%ebx), %eax leal boot_heap@GOTOFF(%ebx), %eax
pushl %eax /* heap area */ pushl %eax /* heap area */
pushl %esi /* real mode pointer */ pushl %esi /* real mode pointer */
call extract_kernel /* returns kernel location in %eax */ call extract_kernel /* returns kernel entry point in %eax */
addl $24, %esp addl $24, %esp
/* /*
......
...@@ -569,7 +569,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) ...@@ -569,7 +569,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
movl input_len(%rip), %ecx /* input_len */ movl input_len(%rip), %ecx /* input_len */
movq %rbp, %r8 /* output target address */ movq %rbp, %r8 /* output target address */
movl output_len(%rip), %r9d /* decompressed length, end of relocs */ movl output_len(%rip), %r9d /* decompressed length, end of relocs */
call extract_kernel /* returns kernel location in %rax */ call extract_kernel /* returns kernel entry point in %rax */
popq %rsi popq %rsi
/* /*
......
...@@ -277,7 +277,7 @@ static inline void handle_relocations(void *output, unsigned long output_len, ...@@ -277,7 +277,7 @@ static inline void handle_relocations(void *output, unsigned long output_len,
{ } { }
#endif #endif
static void parse_elf(void *output) static size_t parse_elf(void *output)
{ {
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
Elf64_Ehdr ehdr; Elf64_Ehdr ehdr;
...@@ -293,10 +293,8 @@ static void parse_elf(void *output) ...@@ -293,10 +293,8 @@ static void parse_elf(void *output)
if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || if (ehdr.e_ident[EI_MAG0] != ELFMAG0 ||
ehdr.e_ident[EI_MAG1] != ELFMAG1 || ehdr.e_ident[EI_MAG1] != ELFMAG1 ||
ehdr.e_ident[EI_MAG2] != ELFMAG2 || ehdr.e_ident[EI_MAG2] != ELFMAG2 ||
ehdr.e_ident[EI_MAG3] != ELFMAG3) { ehdr.e_ident[EI_MAG3] != ELFMAG3)
error("Kernel is not a valid ELF file"); error("Kernel is not a valid ELF file");
return;
}
debug_putstr("Parsing ELF... "); debug_putstr("Parsing ELF... ");
...@@ -328,6 +326,8 @@ static void parse_elf(void *output) ...@@ -328,6 +326,8 @@ static void parse_elf(void *output)
} }
free(phdrs); free(phdrs);
return ehdr.e_entry - LOAD_PHYSICAL_ADDR;
} }
/* /*
...@@ -356,6 +356,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, ...@@ -356,6 +356,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
const unsigned long kernel_total_size = VO__end - VO__text; const unsigned long kernel_total_size = VO__end - VO__text;
unsigned long virt_addr = LOAD_PHYSICAL_ADDR; unsigned long virt_addr = LOAD_PHYSICAL_ADDR;
unsigned long needed_size; unsigned long needed_size;
size_t entry_offset;
/* Retain x86 boot parameters pointer passed from startup_32/64. */ /* Retain x86 boot parameters pointer passed from startup_32/64. */
boot_params = rmode; boot_params = rmode;
...@@ -456,14 +457,17 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, ...@@ -456,14 +457,17 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
debug_putstr("\nDecompressing Linux... "); debug_putstr("\nDecompressing Linux... ");
__decompress(input_data, input_len, NULL, NULL, output, output_len, __decompress(input_data, input_len, NULL, NULL, output, output_len,
NULL, error); NULL, error);
parse_elf(output); entry_offset = parse_elf(output);
handle_relocations(output, output_len, virt_addr); handle_relocations(output, output_len, virt_addr);
debug_putstr("done.\nBooting the kernel.\n");
debug_putstr("done.\nBooting the kernel (entry_offset: 0x");
debug_puthex(entry_offset);
debug_putstr(").\n");
/* Disable exception handling before booting the kernel */ /* Disable exception handling before booting the kernel */
cleanup_exception_handling(); cleanup_exception_handling();
return output; return output + entry_offset;
} }
void fortify_panic(const char *name) void fortify_panic(const char *name)
......
...@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) ...@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
return cpu; return cpu;
} }
static bool __init acpi_is_processor_usable(u32 lapic_flags)
{
if (lapic_flags & ACPI_MADT_ENABLED)
return true;
if (acpi_support_online_capable && (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
return true;
return false;
}
static int __init static int __init
acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
{ {
...@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) ...@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
if (apic_id == 0xffffffff) if (apic_id == 0xffffffff)
return 0; return 0;
/* don't register processors that cannot be onlined */
if (!acpi_is_processor_usable(processor->lapic_flags))
return 0;
/* /*
* We need to register disabled CPU as well to permit * We need to register disabled CPU as well to permit
* counting disabled CPUs. This allows us to size * counting disabled CPUs. This allows us to size
...@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end) ...@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
return 0; return 0;
/* don't register processors that can not be onlined */ /* don't register processors that can not be onlined */
if (acpi_support_online_capable && if (!acpi_is_processor_usable(processor->lapic_flags))
!(processor->lapic_flags & ACPI_MADT_ENABLED) &&
!(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
return 0; return 0;
/* /*
......
...@@ -42,10 +42,4 @@ arch/s390/kernel/head64.o ...@@ -42,10 +42,4 @@ arch/s390/kernel/head64.o
arch/sh/kernel/head_32.o arch/sh/kernel/head_32.o
arch/sparc/kernel/head_32.o arch/sparc/kernel/head_32.o
arch/sparc/kernel/head_64.o arch/sparc/kernel/head_64.o
arch/x86/kernel/head_32.o
arch/x86/kernel/head_64.o
arch/x86/kernel/head32.o
arch/x86/kernel/head64.o
arch/x86/kernel/ebda.o
arch/x86/kernel/platform-quirks.o
arch/xtensa/kernel/head.o arch/xtensa/kernel/head.o
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment