History

Merge tag 'x86-urgent-2023-12-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar: - Fix a secondary CPUs enumeration regression caused by creative MADT APIC table entries on certain systems. - Fix a race in the NOP-patcher that can spuriously trigger crashes on bootup. - Fix a bootup failure regression caused by the parallel bringup code, caused by firmware inconsistency between the APIC initialization states of the boot and secondary CPUs, on certain systems. * tag 'x86-urgent-2023-12-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/acpi: Handle bogus MADT APIC tables gracefully x86/alternatives: Disable interrupts and sync when optimizing NOPs in place x86/alternatives: Sync core before enabling interrupts x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully

Linus Torvalds committed 2 years ago

Commit 3f82f1c2 parents f969c91 d5a10b93 files · +29 −3Browse files

Unified · Split

3 files
  1. arch/x86/kernel/acpi/boot.c +1 −1
  2. arch/x86/kernel/alternative.c +12 −2
  3. arch/x86/kernel/head_64.S +16 −0
arch/x86/kernel/acpi/boot.c+1−1
@@ -293,6 +293,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end) · 292 unmodified lines
293293 processor->processor_id, /* ACPI ID */
294294 processor->lapic_flags & ACPI_MADT_ENABLED);
295295
296+ has_lapic_cpus = true;
296297 return 0;
297298 }
298299
@@ -1134,7 +1135,6 @@ static int __init acpi_parse_madt_lapic_entries(void) · 835 unmodified lines
11341135 if (!count) {
11351136 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
11361137 acpi_parse_lapic, MAX_LOCAL_APIC);
1137− has_lapic_cpus = count > 0;
11381138 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
11391139 acpi_parse_x2apic, MAX_LOCAL_APIC);
11401140 }
arch/x86/kernel/alternative.c+12−2
@@ -255,6 +255,16 @@ static void __init_or_module noinline optimize_nops(u8 *instr, size_t len) · 254 unmodified lines
255255 }
256256 }
257257
258+static void __init_or_module noinline optimize_nops_inplace(u8 *instr, size_t len)
259+{
260+ unsigned long flags;
261+
262+ local_irq_save(flags);
263+ optimize_nops(instr, len);
264+ sync_core();
265+ local_irq_restore(flags);
266+}
267+
258268 /*
259269 * In this context, "source" is where the instructions are placed in the
260270 * section .altinstr_replacement, for example during kernel build by the
@@ -438,7 +448,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, · 177 unmodified lines
438448 * patch if feature is *NOT* present.
439449 */
440450 if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) {
441− optimize_nops(instr, a->instrlen);
451+ optimize_nops_inplace(instr, a->instrlen);
442452 continue;
443453 }
444454
@@ -1685,8 +1695,8 @@ void __init_or_module text_poke_early(void *addr, const void *opcode, · 1240 unmodified lines
16851695 } else {
16861696 local_irq_save(flags);
16871697 memcpy(addr, opcode, len);
1688− local_irq_restore(flags);
16891698 sync_core();
1699+ local_irq_restore(flags);
16901700
16911701 /*
16921702 * Could also do a CLFLUSH here to speed up CPU recovery; but
arch/x86/kernel/head_64.S+16−0
@@ -255,6 +255,22 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL) · 254 unmodified lines
255255 testl $X2APIC_ENABLE, %eax
256256 jnz .Lread_apicid_msr
257257
258+#ifdef CONFIG_X86_X2APIC
259+ /*
260+ * If system is in X2APIC mode then MMIO base might not be
261+ * mapped causing the MMIO read below to fault. Faults can't
262+ * be handled at that point.
263+ */
264+ cmpl $0, x2apic_mode(%rip)
265+ jz .Lread_apicid_mmio
266+
267+ /* Force the AP into X2APIC mode. */
268+ orl $X2APIC_ENABLE, %eax
269+ wrmsr
270+ jmp .Lread_apicid_msr
271+#endif
272+
273+.Lread_apicid_mmio:
258274 /* Read the APIC ID from the fix-mapped MMIO space. */
259275 movq apic_mmio_base(%rip), %rcx
260276 addq $APIC_ID, %rcx