All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/microcode: Fix crashes on early 486 CPUs due to usage of 'cpuid'.
@ 2024-10-19  6:29 Oerg866
  2024-10-19  9:49 ` Borislav Petkov
                   ` (3 more replies)
  0 siblings, 4 replies; 46+ messages in thread
From: Oerg866 @ 2024-10-19  6:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Borislav Petkov, Thomas Gleixner, Ingo Molnar, Dave Hansen, x86,
	H. Peter Anvin

Starting with v6.7-rc1, the kernel was no longer able to boot on early
i486-class CPUs.

To clarify, this was caused by the comprehensive microcode rework, from

0a23fb262d17f("Merge tag 'x86_microcode_for_v6.7_rc1'
of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip").

The breaking changes were introduced with these specific commits:

4c585af7180c1("x86/boot/32: Temporarily map initrd for microcode loading")

...causes immediate reboot.

a7939f0167203("x86/microcode/amd: Cache builtin/initrd microcode early")

...causes kernel panic early on.

They assume the host CPU supports the CPUID instruction, which
the pre-"enhanced" 486 type ones do not.

These changes make every kernel version from 6.7 to 6.11.4 bootable on
them.
---
 arch/x86/kernel/cpu/microcode/amd.c | 8 ++++++--
 arch/x86/kernel/head32.c            | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c
b/arch/x86/kernel/cpu/microcode/amd.c
index c0d56c02b8da..71fa388573ac 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -516,14 +516,18 @@ static enum ucode_state load_microcode_amd(u8
family, const u8 *data, size_t siz

 static int __init save_microcode_in_initrd(void)
 {
- unsigned int cpuid_1_eax = native_cpuid_eax(1);
+ unsigned int cpuid_1_eax;
  struct cpuinfo_x86 *c = &boot_cpu_data;
  struct cont_desc desc = { 0 };
  enum ucode_state ret;
  struct cpio_data cp;

- if (dis_ucode_ldr || c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10)
+ if (!have_cpuid_p() || dis_ucode_ldr ||
+        c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
         return 0;
+ }
+
+ cpuid_1_eax = native_cpuid_eax(1);

  find_blobs_in_containers(cpuid_1_eax, &cp);
  if (!(cp.data && cp.size))
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index de001b2146ab..79fd9f11dbcb 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -146,7 +146,7 @@ void __init __no_stack_protector mk_early_pgtbl_32(void)

 #ifdef CONFIG_MICROCODE_INITRD32
  /* Running on a hypervisor? */
- if (native_cpuid_ecx(1) & BIT(31))
+ if (have_cpuid_p() && (native_cpuid_ecx(1) & BIT(31)))
         return;

  params = (struct boot_params *)__pa_nodebug(&boot_params);
--
2.34.1

^ permalink raw reply related	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2025-05-06 12:19 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-19  6:29 [PATCH] x86/microcode: Fix crashes on early 486 CPUs due to usage of 'cpuid' Oerg866
2024-10-19  9:49 ` Borislav Petkov
2024-10-19 14:06   ` Oerg866
2025-04-05  2:03 ` Kevin Koster
2025-04-05  9:32   ` Borislav Petkov
2025-04-05 20:33     ` H. Peter Anvin
2025-04-05 20:50       ` Borislav Petkov
2025-04-05 21:03         ` Borislav Petkov
2025-04-06  6:40     ` Kevin Koster
2025-04-06  7:46       ` Kevin Koster
2025-04-06 19:02         ` Borislav Petkov
2025-04-06 23:58           ` Kevin Koster
2025-04-07 10:29             ` Borislav Petkov
2025-04-07 14:21               ` Kevin Koster
2025-04-07 13:55                 ` Borislav Petkov
2025-04-07 14:28                   ` Oerg866
2025-04-08 10:37                     ` Maciej W. Rozycki
2025-04-08 17:22                   ` [PATCH] x86/microcode: Consolidate the loader enablement Borislav Petkov
2025-04-09  7:51                     ` Kevin Koster
2025-04-10 11:53                     ` Thomas Gleixner
2025-04-11 11:07                       ` Borislav Petkov
2025-04-14  9:59                         ` [PATCH -v2] x86/microcode: Consolidate the loader enablement checking Borislav Petkov
2025-04-14 10:48                           ` Ingo Molnar
2025-04-14 11:26                             ` Borislav Petkov
2025-05-03 10:51                               ` David Laight
2025-04-30 19:16                           ` Thomas Gleixner
2025-05-02 16:22                             ` Borislav Petkov
2025-05-02 19:15                               ` Thomas Gleixner
2025-04-07 14:38                 ` [PATCH] x86/microcode: Fix crashes on early 486 CPUs due to usage of 'cpuid' H. Peter Anvin
2025-04-07 23:20                   ` Kevin Koster
2025-04-07 18:10                 ` David Laight
2025-04-07 14:36               ` H. Peter Anvin
2025-04-08 10:16           ` Maciej W. Rozycki
2025-04-08 10:31             ` Borislav Petkov
2025-04-08 12:29               ` Maciej W. Rozycki
2025-04-08 17:28                 ` Borislav Petkov
2025-04-06 16:49       ` H. Peter Anvin
2025-05-03 15:14 ` [tip: x86/urgent] x86/microcode: Consolidate the loader enablement checking tip-bot2 for Borislav Petkov (AMD)
2025-05-04  6:14   ` Ingo Molnar
2025-05-05  5:15     ` [PATCH] x86/microcode: Add microcode_loader_disabled() storage class for the !CONFIG_MICROCODE case Ingo Molnar
2025-05-05  5:32       ` [tip: x86/microcode] " tip-bot2 for Ingo Molnar
2025-05-05  7:27       ` tip-bot2 for Ingo Molnar
2025-05-05  7:47       ` [PATCH] " Borislav Petkov
2025-05-06 10:57         ` Ingo Molnar
2025-05-06 12:19           ` Borislav Petkov
2025-05-06 10:44 ` [tip: x86/urgent] x86/microcode: Consolidate the loader enablement checking tip-bot2 for Borislav Petkov (AMD)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.