Skip to contentSkip to conversation

x86 fixes

GIT PULL Merged Ingo Molnar 2 participants 4 messages Dec 23, 2023 – Apr 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest x86/urgent git tree from:

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

# HEAD: d5a10b976ecb77fa49b95f3f1016ca2997c122cb x86/acpi: Handle bogus MADT APIC tables gracefully

Misc fixes:

- 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.

Thanks,

Ingo

------------------>
Thomas Gleixner (4):
x86/smpboot/64: Handle X2APIC BIOS inconsistency gracefully x86/alternatives: Sync core before enabling interrupts x86/alternatives: Disable interrupts and sync when optimizing NOPs in place x86/acpi: Handle bogus MADT APIC tables gracefully

 arch/x86/kernel/acpi/boot.c   |  2 +-
 arch/x86/kernel/alternative.c | 14 ++++++++++++--
 arch/x86/kernel/head_64.S     | 16 ++++++++++++++++
 3 files changed, 29 insertions(+), 3 deletions(-)
arch/x86/kernel/acpi/boot.c +1 -1
index 1a0dd80d81ac..85a3ce2a3666 100644
@@ -293,6 +293,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
 			    processor->processor_id, /* ACPI ID */
 			    processor->lapic_flags & ACPI_MADT_ENABLED);
 
+	has_lapic_cpus = true;
 	return 0;
 }
 
@@ -1134,7 +1135,6 @@ static int __init acpi_parse_madt_lapic_entries(void)
 	if (!count) {
 		count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
 					acpi_parse_lapic, MAX_LOCAL_APIC);
-		has_lapic_cpus = count > 0;
 		x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
 					acpi_parse_x2apic, MAX_LOCAL_APIC);
 	}
arch/x86/kernel/alternative.c +12 -2
index 73be3931e4f0..aae7456ece07 100644
@@ -255,6 +255,16 @@ static void __init_or_module noinline optimize_nops(u8 *instr, size_t len)
 	}
 }
 
+static void __init_or_module noinline optimize_nops_inplace(u8 *instr, size_t len)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	optimize_nops(instr, len);
+	sync_core();
+	local_irq_restore(flags);
+}
+
 /*
  * In this context, "source" is where the instructions are placed in the
  * 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,
 		 *   patch if feature is *NOT* present.
 		 */
 		if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) {
-			optimize_nops(instr, a->instrlen);
+			optimize_nops_inplace(instr, a->instrlen);
 			continue;
 		}
 
@@ -1685,8 +1695,8 @@ void __init_or_module text_poke_early(void *addr, const void *opcode,
 	} else {
 		local_irq_save(flags);
 		memcpy(addr, opcode, len);
-		local_irq_restore(flags);
 		sync_core();
+		local_irq_restore(flags);
 
 		/*
 		 * Could also do a CLFLUSH here to speed up CPU recovery; but
arch/x86/kernel/head_64.S +16 -0
index 086a2c3aaaa0..0f8103240fda 100644
@@ -255,6 +255,22 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
 	testl	$X2APIC_ENABLE, %eax
 	jnz	.Lread_apicid_msr
 
+#ifdef CONFIG_X86_X2APIC
+	/*
+	 * If system is in X2APIC mode then MMIO base might not be
+	 * mapped causing the MMIO read below to fault. Faults can't
+	 * be handled at that point.
+	 */
+	cmpl	$0, x2apic_mode(%rip)
+	jz	.Lread_apicid_mmio
+
+	/* Force the AP into X2APIC mode. */
+	orl	$X2APIC_ENABLE, %eax
+	wrmsr
+	jmp	.Lread_apicid_msr
+#endif
+
+.Lread_apicid_mmio:
 	/* Read the APIC ID from the fix-mapped MMIO space. */
 	movq	apic_mmio_base(%rip), %rcx
 	addq	$APIC_ID, %rcx
merge bot Merged
#1 lore raw
The pull request you sent on Sat, 23 Dec 2023 15:34:04 +0100:

The pull request you sent on Sat, 23 Dec 2023 15:34:04 +0100:

Quoted 1 line

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

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/3f82f1c3a03694800a4104ca6b6d3282bd4e213d

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
#2 lore raw
In reply to Ingo Molnar

Linus,

Please pull the latest x86/urgent Git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-2024-04-07

# HEAD: b377c66ae3509ccea596512d6afb4777711c4870 x86/retpoline: Add NOENDBR annotation to the SRSO dummy return thunk

Miscellaneous x86 fixes:

- Fix MCE timer reinit locking
- Fix/improve CoCo guest random entropy pool init
- Fix SEV-SNP late disable bugs
- Fix false positive objtool build warning
- Fix header dependency bug
- Fix resctrl CPU offlining bug

Thanks,

Ingo

------------------>
Arnd Bergmann (1):
x86/numa/32: Include missing <asm/pgtable_areas.h>

Borislav Petkov (AMD) (5):
x86/kvm/Kconfig: Have KVM_AMD_SEV select ARCH_HAS_CC_PLATFORM x86/cc: Add cc_platform_set/_clear() helpers x86/CPU/AMD: Track SNP host status with cc_platform_*() x86/mce: Make sure to grab mce_sysfs_mutex in set_bank() x86/retpoline: Add NOENDBR annotation to the SRSO dummy return thunk

Jason A. Donenfeld (1):
x86/coco: Require seeding RNG with RDRAND on CoCo systems

Reinette Chatre (1):
x86/resctrl: Fix uninitialized memory read when last CPU of domain goes offline

 arch/x86/coco/core.c                   | 93 ++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/coco.h            |  2 +
 arch/x86/include/asm/sev.h             |  4 +-
 arch/x86/kernel/cpu/amd.c              | 38 ++++++++------
 arch/x86/kernel/cpu/mce/core.c         |  4 +-
 arch/x86/kernel/cpu/mtrr/generic.c     |  2 +-
 arch/x86/kernel/cpu/resctrl/internal.h |  3 +-
 arch/x86/kernel/setup.c                |  2 +
 arch/x86/kernel/sev.c                  | 10 ----
 arch/x86/kvm/Kconfig                   |  1 +
 arch/x86/kvm/svm/sev.c                 |  2 +-
 arch/x86/lib/retpoline.S               |  1 +
 arch/x86/mm/numa_32.c                  |  1 +
 arch/x86/virt/svm/sev.c                | 26 +++++++---
 drivers/crypto/ccp/sev-dev.c           |  2 +-
 drivers/iommu/amd/init.c               |  4 +-
 include/linux/cc_platform.h            | 12 +++++
 17 files changed, 166 insertions(+), 41 deletions(-)