lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Aug 2022 09:58:52 +0000
From:   Ashok Raj <ashok.raj@...el.com>
To:     Borislav Petkov <bp@...en8.de>
CC:     Ashok Raj <ashok_raj@...ux.intel.com>, X86 ML <x86@...nel.org>,
        "Andrew Cooper" <amc96@...f.net>,
        LKML <linux-kernel@...r.kernel.org>,
        Ștefan Talpalaru <stefantalpalaru@...oo.com>,
        Ashok Raj <ashok.raj@...el.com>
Subject: Re: [PATCH] x86/microcode/AMD: Attempt applying on every logical
 thread

Hi Boris

On Wed, Aug 17, 2022 at 11:56:02PM +0200, Borislav Petkov wrote:
> On Wed, Aug 17, 2022 at 08:58:07PM +0000, Ashok Raj wrote:
> > For this specific patch in question, its not for testing though.. Its
> > required for functional purposes?
> 
> From its commit message:
> 
> "However, there are microcode patches which do per-thread modification,
> see Link tag below.
> 

I did read the commit log. I was just stating the fact that reload isn't
just for testing, for e.g. in this case its required for functional
reasons.

if cpu_rev > ucode_rev, there is no need to reload microcode correct?
There are a bunch of changes in the original post that seemed like it had
nothing to do with force load on a sibling.

Completely untested, no commit log to spare you from fixing them :-)

Seemed like we were simply passing over each other with emails, thought
I'll convey what I meant here via a patch. Hope this helps.

lemme know what you think.

Cheers,
Ashok

---
 arch/x86/kernel/cpu/microcode/amd.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 8b2fcdfa6d31..124e15b8559b 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -440,7 +440,7 @@ apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_p
 		return ret;
 
 	native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
-	if (rev >= mc->hdr.patch_id)
+	if (rev > mc->hdr.patch_id)
 		return ret;
 
 	if (!__apply_microcode_amd(mc)) {
@@ -679,6 +679,7 @@ static enum ucode_state apply_microcode_amd(int cpu)
 	struct ucode_patch *p;
 	enum ucode_state ret;
 	u32 rev, dummy __always_unused;
+	int first_cpu;
 
 	BUG_ON(raw_smp_processor_id() != cpu);
 
@@ -691,10 +692,17 @@ static enum ucode_state apply_microcode_amd(int cpu)
 	mc_amd  = p->data;
 	uci->mc = p->data;
 
+	first_cpu = cpumask_first(topology_sibling_cpumask(cpu));
 	rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy);
 
 	/* need to apply patch? */
-	if (rev >= mc_amd->hdr.patch_id) {
+	if (((cpu == first_cpu) && rev >= mc_amd->hdr.patch_id)) {
+		ret = UCODE_OK;
+		goto out;
+	}
+
+	/* Siblings need to reload microcode even if rev is same */
+	if (rev > mc_amd->hdr.patch_id) {
 		ret = UCODE_OK;
 		goto out;
 	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ