* [PATCH v2 0/2] Clear AMD's microcode cache on load failure
@ 2025-03-27 23:05 Boris Ostrovsky
2025-03-27 23:05 ` [PATCH v2 1/2] x86/microcode/AMD: Fix __apply_microcode_amd()'s return value Boris Ostrovsky
2025-03-27 23:05 ` [PATCH v2 2/2] x86/microcode/AMD: Clean the cache if update did not load microcode Boris Ostrovsky
0 siblings, 2 replies; 5+ messages in thread
From: Boris Ostrovsky @ 2025-03-27 23:05 UTC (permalink / raw)
To: linux-kernel; +Cc: bp, tglx, mingo, dave.hansen, x86, hpa, Boris Ostrovsky
Drop microcode cache when load operation fails to update microcode.
Also make __apply_microcode_amd() return correct error.
v2:
- Copy stable on the first patch
Boris Ostrovsky (2):
x86/microcode/AMD: Fix __apply_microcode_amd()'s return value
x86/microcode/AMD: Clean the cache if update did not load microcode
arch/x86/kernel/cpu/microcode/amd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
--
2.43.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] x86/microcode/AMD: Fix __apply_microcode_amd()'s return value
2025-03-27 23:05 [PATCH v2 0/2] Clear AMD's microcode cache on load failure Boris Ostrovsky
@ 2025-03-27 23:05 ` Boris Ostrovsky
2025-03-28 12:29 ` [tip: x86/urgent] " tip-bot2 for Boris Ostrovsky
2025-03-27 23:05 ` [PATCH v2 2/2] x86/microcode/AMD: Clean the cache if update did not load microcode Boris Ostrovsky
1 sibling, 1 reply; 5+ messages in thread
From: Boris Ostrovsky @ 2025-03-27 23:05 UTC (permalink / raw)
To: linux-kernel
Cc: bp, tglx, mingo, dave.hansen, x86, hpa, Boris Ostrovsky, stable
When verify_sha256_digest() fails, __apply_microcode_amd() should propagate
the failure by returning false (and not -1 which is promoted to true)
Fixes: 50cef76d5cb0 ("x86/microcode/AMD: Load only SHA256-checksummed patches")
Cc: stable@vger.kernel.org
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
arch/x86/kernel/cpu/microcode/amd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 138689b8e1d8..b61028cf5c8a 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -600,7 +600,7 @@ static bool __apply_microcode_amd(struct microcode_amd *mc, u32 *cur_rev,
unsigned long p_addr = (unsigned long)&mc->hdr.data_code;
if (!verify_sha256_digest(mc->hdr.patch_id, *cur_rev, (const u8 *)p_addr, psize))
- return -1;
+ return false;
native_wrmsrl(MSR_AMD64_PATCH_LOADER, p_addr);
--
2.43.5
^ permalink raw reply [flat|nested] 5+ messages in thread* [tip: x86/urgent] x86/microcode/AMD: Fix __apply_microcode_amd()'s return value
2025-03-27 23:05 ` [PATCH v2 1/2] x86/microcode/AMD: Fix __apply_microcode_amd()'s return value Boris Ostrovsky
@ 2025-03-28 12:29 ` tip-bot2 for Boris Ostrovsky
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Boris Ostrovsky @ 2025-03-28 12:29 UTC (permalink / raw)
To: linux-tip-commits
Cc: Boris Ostrovsky, Borislav Petkov (AMD), stable, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 31ab12df723543047c3fc19cb8f8c4498ec6267f
Gitweb: https://git.kernel.org/tip/31ab12df723543047c3fc19cb8f8c4498ec6267f
Author: Boris Ostrovsky <boris.ostrovsky@oracle.com>
AuthorDate: Thu, 27 Mar 2025 19:05:02 -04:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 28 Mar 2025 12:49:02 +01:00
x86/microcode/AMD: Fix __apply_microcode_amd()'s return value
When verify_sha256_digest() fails, __apply_microcode_amd() should propagate
the failure by returning false (and not -1 which is promoted to true).
Fixes: 50cef76d5cb0 ("x86/microcode/AMD: Load only SHA256-checksummed patches")
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250327230503.1850368-2-boris.ostrovsky@oracle.com
---
arch/x86/kernel/cpu/microcode/amd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 138689b..b61028c 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -600,7 +600,7 @@ static bool __apply_microcode_amd(struct microcode_amd *mc, u32 *cur_rev,
unsigned long p_addr = (unsigned long)&mc->hdr.data_code;
if (!verify_sha256_digest(mc->hdr.patch_id, *cur_rev, (const u8 *)p_addr, psize))
- return -1;
+ return false;
native_wrmsrl(MSR_AMD64_PATCH_LOADER, p_addr);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] x86/microcode/AMD: Clean the cache if update did not load microcode
2025-03-27 23:05 [PATCH v2 0/2] Clear AMD's microcode cache on load failure Boris Ostrovsky
2025-03-27 23:05 ` [PATCH v2 1/2] x86/microcode/AMD: Fix __apply_microcode_amd()'s return value Boris Ostrovsky
@ 2025-03-27 23:05 ` Boris Ostrovsky
2025-04-07 13:06 ` [tip: x86/microcode] " tip-bot2 for Boris Ostrovsky
1 sibling, 1 reply; 5+ messages in thread
From: Boris Ostrovsky @ 2025-03-27 23:05 UTC (permalink / raw)
To: linux-kernel; +Cc: bp, tglx, mingo, dave.hansen, x86, hpa, Boris Ostrovsky
If microcode did not get loaded there is no reason to keep it in the cache.
Moreover, if loading failed it will not be possible to load an earlier
version of microcode since failed version will always be selected from
the cache on next reload attempt.
Since failed version is not easily avaialble at this point just clean the
whole cache. It will be rebuilt later if needed.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
arch/x86/kernel/cpu/microcode/amd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index b61028cf5c8a..57bd61f9c69b 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -1171,11 +1171,18 @@ static void microcode_fini_cpu_amd(int cpu)
uci->mc = NULL;
}
+static void finalize_late_load_amd(int result)
+{
+ if (result)
+ cleanup();
+}
+
static struct microcode_ops microcode_amd_ops = {
.request_microcode_fw = request_microcode_amd,
.collect_cpu_info = collect_cpu_info_amd,
.apply_microcode = apply_microcode_amd,
.microcode_fini_cpu = microcode_fini_cpu_amd,
+ .finalize_late_load = finalize_late_load_amd,
.nmi_safe = true,
};
--
2.43.5
^ permalink raw reply [flat|nested] 5+ messages in thread* [tip: x86/microcode] x86/microcode/AMD: Clean the cache if update did not load microcode
2025-03-27 23:05 ` [PATCH v2 2/2] x86/microcode/AMD: Clean the cache if update did not load microcode Boris Ostrovsky
@ 2025-04-07 13:06 ` tip-bot2 for Boris Ostrovsky
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Boris Ostrovsky @ 2025-04-07 13:06 UTC (permalink / raw)
To: linux-tip-commits
Cc: Boris Ostrovsky, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/microcode branch of tip:
Commit-ID: 321550859f3bd64f547d0b4e9fbd97bd539ef47c
Gitweb: https://git.kernel.org/tip/321550859f3bd64f547d0b4e9fbd97bd539ef47c
Author: Boris Ostrovsky <boris.ostrovsky@oracle.com>
AuthorDate: Thu, 27 Mar 2025 19:05:03 -04:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 07 Apr 2025 14:46:56 +02:00
x86/microcode/AMD: Clean the cache if update did not load microcode
If microcode did not get loaded there is no reason to keep it in the cache.
Moreover, if loading failed it will not be possible to load an earlier version
of microcode since the failed revision will always be selected from the cache
on the next reload attempt.
Since the failed revisions is not easily available at this point just clean the
whole cache. It will be rebuilt later if needed.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250327230503.1850368-3-boris.ostrovsky@oracle.com
---
arch/x86/kernel/cpu/microcode/amd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index b61028c..57bd61f 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -1171,11 +1171,18 @@ static void microcode_fini_cpu_amd(int cpu)
uci->mc = NULL;
}
+static void finalize_late_load_amd(int result)
+{
+ if (result)
+ cleanup();
+}
+
static struct microcode_ops microcode_amd_ops = {
.request_microcode_fw = request_microcode_amd,
.collect_cpu_info = collect_cpu_info_amd,
.apply_microcode = apply_microcode_amd,
.microcode_fini_cpu = microcode_fini_cpu_amd,
+ .finalize_late_load = finalize_late_load_amd,
.nmi_safe = true,
};
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-07 13:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-27 23:05 [PATCH v2 0/2] Clear AMD's microcode cache on load failure Boris Ostrovsky
2025-03-27 23:05 ` [PATCH v2 1/2] x86/microcode/AMD: Fix __apply_microcode_amd()'s return value Boris Ostrovsky
2025-03-28 12:29 ` [tip: x86/urgent] " tip-bot2 for Boris Ostrovsky
2025-03-27 23:05 ` [PATCH v2 2/2] x86/microcode/AMD: Clean the cache if update did not load microcode Boris Ostrovsky
2025-04-07 13:06 ` [tip: x86/microcode] " tip-bot2 for Boris Ostrovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®