* [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed
@ 2025-11-26 11:26 Andrew Cooper
2025-11-26 11:33 ` Andrew Cooper
2025-11-26 13:03 ` [PATCH v2] " Andrew Cooper
0 siblings, 2 replies; 7+ messages in thread
From: Andrew Cooper @ 2025-11-26 11:26 UTC (permalink / raw)
To: LKML; +Cc: Andrew Cooper, Borislav Petkov, Mario Limonciello, x86
The good revisions are tied to exact steppings, meaning it's not valid to
match on model number alone, let alone a range.
This is probably only a latent issue. From public microcode archives, the
followin CPUs exist 17-30-00, 17-60-00, 17-70-00 and would be captured by the
model ranges. They're likely pre-production steppings, and likely didn't get
Zenbleed microcode, but it's still incorrect to compare them to a different
stepping's revision.
Either way, convert the logic to use x86_match_min_microcode_rev(), which is
the preferred mechanism.
Fixes: 522b1d69219d ("x86/cpu/amd: Add a Zenbleed fix")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Borislav Petkov <bp@alien8.de>
CC: Mario Limonciello <mario.limonciello@amd.com>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
arch/x86/kernel/cpu/amd.c | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 5d46709c58d0..9721d24727e9 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -951,26 +951,13 @@ static void init_amd_zen1(struct cpuinfo_x86 *c)
}
}
-static bool cpu_has_zenbleed_microcode(void)
-{
- u32 good_rev = 0;
-
- switch (boot_cpu_data.x86_model) {
- case 0x30 ... 0x3f: good_rev = 0x0830107b; break;
- case 0x60 ... 0x67: good_rev = 0x0860010c; break;
- case 0x68 ... 0x6f: good_rev = 0x08608107; break;
- case 0x70 ... 0x7f: good_rev = 0x08701033; break;
- case 0xa0 ... 0xaf: good_rev = 0x08a00009; break;
-
- default:
- return false;
- }
-
- if (boot_cpu_data.microcode < good_rev)
- return false;
-
- return true;
-}
+static const struct x86_cpu_id amd_zenbleed_microcode[] = {
+ ZEN_MODEL_STEP_UCODE(0x17, 0x31, 0x0, 0x0830107b),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x60, 0x1, 0x0860010c),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x68, 0x1, 0x08608107),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x71, 0x0, 0x08701033),
+ ZEN_MODEL_STEP_UCODE(0x17, 0xa0, 0x0, 0x08a00009),
+};
static void zen2_zenbleed_check(struct cpuinfo_x86 *c)
{
@@ -980,7 +967,7 @@ static void zen2_zenbleed_check(struct cpuinfo_x86 *c)
if (!cpu_has(c, X86_FEATURE_AVX))
return;
- if (!cpu_has_zenbleed_microcode()) {
+ if (!x86_match_min_microcode_rev(amd_zenbleed_microcode)) {
pr_notice_once("Zenbleed: please update your microcode for the most optimal fix\n");
msr_set_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
} else {
base-commit: ac3fd01e4c1efce8f2c054cdeb2ddd2fc0fb150d
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed
2025-11-26 11:26 [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed Andrew Cooper
@ 2025-11-26 11:33 ` Andrew Cooper
2025-11-26 12:44 ` Borislav Petkov
2025-11-26 13:03 ` [PATCH v2] " Andrew Cooper
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2025-11-26 11:33 UTC (permalink / raw)
To: LKML; +Cc: Borislav Petkov, Mario Limonciello, x86, Andrew Cooper
On 26/11/2025 11:26 am, Andrew Cooper wrote:
> The good revisions are tied to exact steppings, meaning it's not valid to
> match on model number alone, let alone a range.
>
> This is probably only a latent issue. From public microcode archives, the
> followin CPUs exist 17-30-00, 17-60-00, 17-70-00 and would be captured by the
> model ranges. They're likely pre-production steppings, and likely didn't get
> Zenbleed microcode, but it's still incorrect to compare them to a different
> stepping's revision.
>
> Either way, convert the logic to use x86_match_min_microcode_rev(), which is
> the preferred mechanism.
>
> Fixes: 522b1d69219d ("x86/cpu/amd: Add a Zenbleed fix")
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Borislav Petkov <bp@alien8.de>
> CC: Mario Limonciello <mario.limonciello@amd.com>
> CC: x86@kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
> arch/x86/kernel/cpu/amd.c | 29 ++++++++---------------------
> 1 file changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index 5d46709c58d0..9721d24727e9 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -951,26 +951,13 @@ static void init_amd_zen1(struct cpuinfo_x86 *c)
> }
> }
>
> -static bool cpu_has_zenbleed_microcode(void)
> -{
> - u32 good_rev = 0;
> -
> - switch (boot_cpu_data.x86_model) {
> - case 0x30 ... 0x3f: good_rev = 0x0830107b; break;
> - case 0x60 ... 0x67: good_rev = 0x0860010c; break;
> - case 0x68 ... 0x6f: good_rev = 0x08608107; break;
> - case 0x70 ... 0x7f: good_rev = 0x08701033; break;
> - case 0xa0 ... 0xaf: good_rev = 0x08a00009; break;
> -
> - default:
> - return false;
> - }
> -
> - if (boot_cpu_data.microcode < good_rev)
> - return false;
> -
> - return true;
> -}
> +static const struct x86_cpu_id amd_zenbleed_microcode[] = {
> + ZEN_MODEL_STEP_UCODE(0x17, 0x31, 0x0, 0x0830107b),
> + ZEN_MODEL_STEP_UCODE(0x17, 0x60, 0x1, 0x0860010c),
> + ZEN_MODEL_STEP_UCODE(0x17, 0x68, 0x1, 0x08608107),
> + ZEN_MODEL_STEP_UCODE(0x17, 0x71, 0x0, 0x08701033),
> + ZEN_MODEL_STEP_UCODE(0x17, 0xa0, 0x0, 0x08a00009),
> +};
Sorry, this needs a {} terminator to be correct. I'll send out a v2 in
a bit, assuming there are no other comments.
~Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed
2025-11-26 11:33 ` Andrew Cooper
@ 2025-11-26 12:44 ` Borislav Petkov
2025-11-26 13:00 ` Andrew Cooper
2025-11-26 14:42 ` david laight
0 siblings, 2 replies; 7+ messages in thread
From: Borislav Petkov @ 2025-11-26 12:44 UTC (permalink / raw)
To: Andrew Cooper; +Cc: LKML, Mario Limonciello, x86
On Wed, Nov 26, 2025 at 11:33:43AM +0000, Andrew Cooper wrote:
> Sorry, this needs a {} terminator to be correct. I'll send out a v2 in
> a bit, assuming there are no other comments.
I'm just glad that I'm not the only one to fall for this no-terminator shit.
:-P
In any case, makes sense. It'll have to wait for after the merge window along
with your other patch.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed
2025-11-26 12:44 ` Borislav Petkov
@ 2025-11-26 13:00 ` Andrew Cooper
2025-11-26 14:42 ` david laight
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Cooper @ 2025-11-26 13:00 UTC (permalink / raw)
To: Borislav Petkov; +Cc: LKML, Mario Limonciello, x86, Andrew Cooper
On 26/11/2025 12:44 pm, Borislav Petkov wrote:
> On Wed, Nov 26, 2025 at 11:33:43AM +0000, Andrew Cooper wrote:
>> Sorry, this needs a {} terminator to be correct. I'll send out a v2 in
>> a bit, assuming there are no other comments.
> I'm just glad that I'm not the only one to fall for this no-terminator shit.
>
> :-P
>
> In any case, makes sense. It'll have to wait for after the merge window along
> with your other patch.
There's no rush. I'm fixing Xen, and at least ensuring that I have sent
a patch in Linux's direction.
~Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed
2025-11-26 12:44 ` Borislav Petkov
2025-11-26 13:00 ` Andrew Cooper
@ 2025-11-26 14:42 ` david laight
1 sibling, 0 replies; 7+ messages in thread
From: david laight @ 2025-11-26 14:42 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Andrew Cooper, LKML, Mario Limonciello, x86
On Wed, 26 Nov 2025 13:44:53 +0100
Borislav Petkov <bp@alien8.de> wrote:
> On Wed, Nov 26, 2025 at 11:33:43AM +0000, Andrew Cooper wrote:
> > Sorry, this needs a {} terminator to be correct. I'll send out a v2 in
> > a bit, assuming there are no other comments.
>
> I'm just glad that I'm not the only one to fall for this no-terminator shit.
Could you add an #define wrapper, eg
#define x86_match_min_microcode_rev(table) \
x86_match_min_microcode_rev(table, ARRAY_COUNT(table))
to pass the count into the function?
Then the terminator can be made optional.
The data will be smaller, the code slightly larger.
So a net size gain since the performance can't be critical.
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] x86/cpu/amd: Correct the microcode table for Zenbleed
2025-11-26 11:26 [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed Andrew Cooper
2025-11-26 11:33 ` Andrew Cooper
@ 2025-11-26 13:03 ` Andrew Cooper
2025-12-15 7:18 ` [tip: x86/cpu] " tip-bot2 for Andrew Cooper
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2025-11-26 13:03 UTC (permalink / raw)
To: LKML; +Cc: Andrew Cooper, Borislav Petkov, Mario Limonciello, x86
The good revisions are tied to exact steppings, meaning it's not valid to
match on model number alone, let alone a range.
This is probably only a latent issue. From public microcode archives, the
following CPUs exist 17-30-00, 17-60-00, 17-70-00 and would be captured by the
model ranges. They're likely pre-production steppings, and likely didn't get
Zenbleed microcode, but it's still incorrect to compare them to a different
steppings revision.
Either way, convert the logic to use x86_match_min_microcode_rev(), which is
the preferred mechanism.
Fixes: 522b1d69219d ("x86/cpu/amd: Add a Zenbleed fix")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Borislav Petkov <bp@alien8.de>
CC: Mario Limonciello <mario.limonciello@amd.com>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
v2:
* Terminate the list with {}.
---
arch/x86/kernel/cpu/amd.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 5d46709c58d0..a92750f3079a 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -951,26 +951,14 @@ static void init_amd_zen1(struct cpuinfo_x86 *c)
}
}
-static bool cpu_has_zenbleed_microcode(void)
-{
- u32 good_rev = 0;
-
- switch (boot_cpu_data.x86_model) {
- case 0x30 ... 0x3f: good_rev = 0x0830107b; break;
- case 0x60 ... 0x67: good_rev = 0x0860010c; break;
- case 0x68 ... 0x6f: good_rev = 0x08608107; break;
- case 0x70 ... 0x7f: good_rev = 0x08701033; break;
- case 0xa0 ... 0xaf: good_rev = 0x08a00009; break;
-
- default:
- return false;
- }
-
- if (boot_cpu_data.microcode < good_rev)
- return false;
-
- return true;
-}
+static const struct x86_cpu_id amd_zenbleed_microcode[] = {
+ ZEN_MODEL_STEP_UCODE(0x17, 0x31, 0x0, 0x0830107b),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x60, 0x1, 0x0860010c),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x68, 0x1, 0x08608107),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x71, 0x0, 0x08701033),
+ ZEN_MODEL_STEP_UCODE(0x17, 0xa0, 0x0, 0x08a00009),
+ {}
+};
static void zen2_zenbleed_check(struct cpuinfo_x86 *c)
{
@@ -980,7 +968,7 @@ static void zen2_zenbleed_check(struct cpuinfo_x86 *c)
if (!cpu_has(c, X86_FEATURE_AVX))
return;
- if (!cpu_has_zenbleed_microcode()) {
+ if (!x86_match_min_microcode_rev(amd_zenbleed_microcode)) {
pr_notice_once("Zenbleed: please update your microcode for the most optimal fix\n");
msr_set_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
} else {
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* [tip: x86/cpu] x86/cpu/amd: Correct the microcode table for Zenbleed
2025-11-26 13:03 ` [PATCH v2] " Andrew Cooper
@ 2025-12-15 7:18 ` tip-bot2 for Andrew Cooper
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot2 for Andrew Cooper @ 2025-12-15 7:18 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andrew Cooper, Ingo Molnar, Borislav Petkov, Mario Limonciello,
x86, linux-kernel
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: fb7bfa31b8e8569f154f2fe0ea6c2f03c0f087aa
Gitweb: https://git.kernel.org/tip/fb7bfa31b8e8569f154f2fe0ea6c2f03c0f087aa
Author: Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed, 26 Nov 2025 13:03:52
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Sun, 14 Dec 2025 09:54:46 +01:00
x86/cpu/amd: Correct the microcode table for Zenbleed
The good revisions are tied to exact steppings, meaning it's not valid to
match on model number alone, let alone a range.
This is probably only a latent issue. From public microcode archives, the
following CPUs exist 17-30-00, 17-60-00, 17-70-00 and would be captured by the
model ranges. They're likely pre-production steppings, and likely didn't get
Zenbleed microcode, but it's still incorrect to compare them to a different
steppings revision.
Either way, convert the logic to use x86_match_min_microcode_rev(), which is
the preferred mechanism.
Fixes: 522b1d69219d ("x86/cpu/amd: Add a Zenbleed fix")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: x86@kernel.org
Link: https://patch.msgid.link/20251126130352.880424-1-andrew.cooper3@citrix.com
---
arch/x86/kernel/cpu/amd.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bc94ff1..86059f2 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -951,26 +951,14 @@ static void init_amd_zen1(struct cpuinfo_x86 *c)
}
}
-static bool cpu_has_zenbleed_microcode(void)
-{
- u32 good_rev = 0;
-
- switch (boot_cpu_data.x86_model) {
- case 0x30 ... 0x3f: good_rev = 0x0830107b; break;
- case 0x60 ... 0x67: good_rev = 0x0860010c; break;
- case 0x68 ... 0x6f: good_rev = 0x08608107; break;
- case 0x70 ... 0x7f: good_rev = 0x08701033; break;
- case 0xa0 ... 0xaf: good_rev = 0x08a00009; break;
-
- default:
- return false;
- }
-
- if (boot_cpu_data.microcode < good_rev)
- return false;
-
- return true;
-}
+static const struct x86_cpu_id amd_zenbleed_microcode[] = {
+ ZEN_MODEL_STEP_UCODE(0x17, 0x31, 0x0, 0x0830107b),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x60, 0x1, 0x0860010c),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x68, 0x1, 0x08608107),
+ ZEN_MODEL_STEP_UCODE(0x17, 0x71, 0x0, 0x08701033),
+ ZEN_MODEL_STEP_UCODE(0x17, 0xa0, 0x0, 0x08a00009),
+ {}
+};
static void zen2_zenbleed_check(struct cpuinfo_x86 *c)
{
@@ -980,7 +968,7 @@ static void zen2_zenbleed_check(struct cpuinfo_x86 *c)
if (!cpu_has(c, X86_FEATURE_AVX))
return;
- if (!cpu_has_zenbleed_microcode()) {
+ if (!x86_match_min_microcode_rev(amd_zenbleed_microcode)) {
pr_notice_once("Zenbleed: please update your microcode for the most optimal fix\n");
msr_set_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
} else {
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-15 7:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 11:26 [PATCH] x86/cpu/amd: Correct the microcode table for Zenbleed Andrew Cooper
2025-11-26 11:33 ` Andrew Cooper
2025-11-26 12:44 ` Borislav Petkov
2025-11-26 13:00 ` Andrew Cooper
2025-11-26 14:42 ` david laight
2025-11-26 13:03 ` [PATCH v2] " Andrew Cooper
2025-12-15 7:18 ` [tip: x86/cpu] " tip-bot2 for Andrew Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox