blob: bc75629a4d0e18d24ba6d8d0a38866aeb34e9e8e [file]
From 29e4e4016c7ee3c05d03350c361d6bc1239dc357 Mon Sep 17 00:00:00 2001
From: Sasha Levin <sashal@kernel.org>
Date: Wed, 16 Sep 2026 22:59:39 +0000
Subject: x86/microcode/intel: Reject problematic loading on Granite Rapids
systems
From: Chang S. Bae <chang.seok.bae@intel.com>
[ Upstream commit e7d3e2f46dd5a69046e6d95a0f189155a5516b93 ]
Microcode updates can usually jump revisions. However, there is an erratum on
Granite Rapids systems. If they "jump over" revision 0x1000405, they result in
an #MC. Avoid it.
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260916225939.1144524-1-chang.seok.bae@intel.com
[ sashal: Backport hooks the Granite Rapids revision-jump check into the older loader's extra paths (early AP load, patch cache lookup, late apply with real-revision refresh) and uses family/model checks instead of IFM(). ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kernel/cpu/microcode/intel.c | 55 ++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 1def66118b03c..07efc44d227cc 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -261,6 +261,23 @@ static int microcode_sanity_check(void *mc, int print_err)
return 0;
}
+static bool revision_is_safe(struct cpu_signature *sig, u32 rev)
+{
+ /*
+ * Erratum GNR98 can cause #MCs if "jumping over" revision 0x1000405.
+ * Avoid the jumps.
+ */
+ if (x86_family(sig->sig) == 6 &&
+ x86_model(sig->sig) == INTEL_FAM6_GRANITERAPIDS_X &&
+ x86_stepping(sig->sig) == 1 &&
+ sig->pf & 0x95 &&
+ sig->rev < 0x1000405 &&
+ rev > 0x1000405)
+ return false;
+
+ return true;
+}
+
/*
* Get microcode matching with BSP's model. Only CPUs with the same model as
* BSP can stay in the platform.
@@ -292,8 +309,19 @@ scan_microcode(void *data, size_t size, struct ucode_cpu_info *uci, bool save)
continue;
}
+ if (!revision_is_safe(&uci->cpu_sig, mc_header->rev)) {
+ data += mc_size;
+ continue;
+ }
+
if (save) {
- save_microcode_patch(uci, data, mc_size);
+ /*
+ * Only cache what the BSP could have loaded: a newer
+ * revision was rejected as unsafe and must not be
+ * applied on resume or hotplug.
+ */
+ if (mc_header->rev <= uci->cpu_sig.rev)
+ save_microcode_patch(uci, data, mc_size);
goto next;
}
@@ -629,6 +657,11 @@ void load_ucode_intel_ap(void)
*iup = patch;
}
+ intel_cpu_collect_info(&uci);
+
+ if (!revision_is_safe(&uci.cpu_sig, (*iup)->hdr.rev))
+ return;
+
uci.mc = *iup;
apply_microcode_early(&uci, true);
@@ -646,6 +679,9 @@ static struct microcode_intel *find_patch(struct ucode_cpu_info *uci)
if (phdr->rev <= uci->cpu_sig.rev)
continue;
+ if (!revision_is_safe(&uci->cpu_sig, phdr->rev))
+ continue;
+
if (!find_matching_signature(phdr,
uci->cpu_sig.sig,
uci->cpu_sig.pf))
@@ -706,6 +742,7 @@ static enum ucode_state apply_microcode_intel(int cpu)
struct cpuinfo_x86 *c = &cpu_data(cpu);
bool bsp = c->cpu_index == boot_cpu_data.cpu_index;
struct microcode_intel *mc;
+ struct cpu_signature sig;
enum ucode_state ret;
static int prev_rev;
u32 rev;
@@ -733,6 +770,17 @@ static enum ucode_state apply_microcode_intel(int cpu)
goto out;
}
+ /*
+ * uci->cpu_sig.rev can be stale, e.g. on resume. Check against the
+ * revision the CPU is really running.
+ */
+ sig = uci->cpu_sig;
+ sig.rev = rev;
+ if (!revision_is_safe(&sig, mc->hdr.rev)) {
+ ret = UCODE_NFOUND;
+ goto out;
+ }
+
/*
* Writeback and invalidate caches before updating microcode to avoid
* internal issues depending on what the microcode is updating.
@@ -818,6 +866,11 @@ static enum ucode_state generic_load_microcode(int cpu, struct iov_iter *iter)
break;
}
+ if (!revision_is_safe(&uci->cpu_sig, mc_header.rev)) {
+ pr_err_once("Erratum GNR98: skipping revision 0x%x.\n", mc_header.rev);
+ continue;
+ }
+
csig = uci->cpu_sig.sig;
cpf = uci->cpu_sig.pf;
if (has_newer_microcode(mc, csig, cpf, new_rev)) {
--
2.53.0