Skip to content

Commit 7570d38

Browse files
committed
x86/microcode/AMD: Apply the patch early on every logical thread
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2138389 commit e7ad18d Author: Borislav Petkov <bp@suse.de> Date: Wed, 5 Oct 2022 12:00:08 +0200 x86/microcode/AMD: Apply the patch early on every logical thread Currently, the patch application logic checks whether the revision needs to be applied on each logical CPU (SMT thread). Therefore, on SMT designs where the microcode engine is shared between the two threads, the application happens only on one of them as that is enough to update the shared microcode engine. However, there are microcode patches which do per-thread modification, see Link tag below. Therefore, drop the revision check and try applying on each thread. This is what the BIOS does too so this method is very much tested. Btw, change only the early paths. On the late loading paths, there's no point in doing per-thread modification because if is it some case like in the bugzilla below - removing a CPUID flag - the kernel cannot go and un-use features it has detected are there early. For that, one should use early loading anyway. [ bp: Fixes does not contain the oldest commit which did check for equality but that is good enough. ] Fixes: 8801b3f ("x86/microcode/AMD: Rework container parsing") Reported-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com> Signed-off-by: Borislav Petkov <bp@suse.de> Tested-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com> Cc: <stable@vger.kernel.org> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216211 Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 394ed15 commit 7570d38

File tree

1 file changed

+13
-3
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+13
-3
lines changed

arch/x86/kernel/cpu/microcode/amd.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,13 @@ apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_p
440440
return ret;
441441

442442
native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
443-
if (rev >= mc->hdr.patch_id)
443+
444+
/*
445+
* Allow application of the same revision to pick up SMT-specific
446+
* changes even if the revision of the other SMT thread is already
447+
* up-to-date.
448+
*/
449+
if (rev > mc->hdr.patch_id)
444450
return ret;
445451

446452
if (!__apply_microcode_amd(mc)) {
@@ -528,8 +534,12 @@ void load_ucode_amd_ap(unsigned int cpuid_1_eax)
528534

529535
native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
530536

531-
/* Check whether we have saved a new patch already: */
532-
if (*new_rev && rev < mc->hdr.patch_id) {
537+
/*
538+
* Check whether a new patch has been saved already. Also, allow application of
539+
* the same revision in order to pick up SMT-thread-specific configuration even
540+
* if the sibling SMT thread already has an up-to-date revision.
541+
*/
542+
if (*new_rev && rev <= mc->hdr.patch_id) {
533543
if (!__apply_microcode_amd(mc)) {
534544
*new_rev = mc->hdr.patch_id;
535545
return;

0 commit comments

Comments
 (0)