mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Ashok Raj <ashok.raj@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	LKML Mailing List <linux-kernel@vger.kernel.org>,
	X86-kernel <x86@kernel.org>, Dave Hansen <dave.hansen@intel.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Ingo Molnar <mingo@kernel.org>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Tony Luck <tony.luck@intel.com>
Subject: Re: [PATCH] x86/microcode/intel: Allow late loading only if a min rev is specified
Date: Thu, 1 Sep 2022 04:53:04 +0200	[thread overview]
Message-ID: <YxAefm3F9zMdTjcs@nazgul.tnic> (raw)
In-Reply-To: <Yw1AtFrRPWhkJ4r8@araj-dh-work>

On Mon, Aug 29, 2022 at 10:41:56PM +0000, Ashok Raj wrote:
> But I suppose, you mean what refresh_hw is supposed to mean from the
> existing code?

I've been meaning this for a while now.

> refresh_hw seems to imply when to update  the copy of the microcode from
> the filesystem. Also seems to imply late loading.

After your patch:

$ git grep refresh_fw arch/x86/
arch/x86/kernel/cpu/microcode/core.c:601:static enum ucode_state microcode_init_cpu(int cpu, bool refresh_fw)
arch/x86/kernel/cpu/microcode/core.c:616:       ustate = microcode_ops->request_microcode_fw(cpu, &microcode_pdev->dev, refresh_fw);

$ git grep late_loading
arch/x86/include/asm/microcode.h:36:                                              bool late_loading);
arch/x86/kernel/cpu/microcode/amd.c:894:                                              bool late_loading)
arch/x86/kernel/cpu/microcode/amd.c:903:        if (!late_loading || !bsp)
arch/x86/kernel/cpu/microcode/intel.c:166:static int microcode_sanity_check(void *mc, int print_err, bool late_loading)
...

Now you have both. More mess.

> its used in the following places.
> 
> 1. During reload_store() where this is exclicitly due to echo 1 > reload
> 
> 	tmp_ret = microcode_ops->request_microcode_fw(bsp, &microcode_pdev->dev, true);
> 
> 	Here passing true makes sense since you are going to do a full
> 	refresh on all CPUs via late loading.

Yes, and here it is perfectly clear that it is late loading.

> 2. microcode_update_cpu() -> microcode_init_cpu()->request_microcode_fw(false)
> 
>    Early loading from resume.

CPU hotplug rather.

> So we would use the microcode cache to load from.

So this happens when the CPU is coming online. I'm not sure why I set it
to "false" back then - whether it is because there's no filesystem yet
or there was another reason. I *think* this was some contrived used case
again.

In any case, this'll need to be experimented with to figure out what
happens when it is set to "true".

> 3. mc_device_add() -> microcode_init_cpu(true)->request_microcode_fw(true)
> 
>    This seems like normal CPU hot-add, I'm not sure if refresh_fw=true is
>    valid. A new CPU should also use from the cache, but not a full reload
>    from filesystem. This could end up with new cpu with an updated ucode
>    and older with something that was loaded earlier.

Just check when mc_device_add() is actually called and then try to
figure out what that actually does instead of speculating.

> Sort of what was fixed in:
>    commit 7189b3c11903667808029ec9766a6e96de5012a5 (tag: x86_microcode_for_v5.13)

That's a tag - not a git commit.

I think you mean

7189b3c11903 ("x86/microcode: Check for offline CPUs before requesting new microcode")

>    intel.c doesn't seem to use this parameter at all today. But judging from
> 
>    amd.c: request_microcode_amd() 
> 
>         /* reload ucode container only on the boot cpu */
>         if (!refresh_fw || !bsp)
>                 return UCODE_OK;
> 
>   Seems like it does the right job, since you would refresh only if
>   refresh_fw=true and its the bsp. Hence it seems immute to the
>   mc_device_add() bug.

I don't see a bug there.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

      reply	other threads:[~2022-09-01  2:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 18:04 Ashok Raj
2022-08-29 18:36 ` Dave Hansen
2022-08-29 18:52   ` Ashok Raj
2022-08-29 20:24     ` Dave Hansen
2022-08-29 20:31 ` Borislav Petkov
2022-08-29 22:41   ` Ashok Raj
2022-09-01  2:53     ` Borislav Petkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YxAefm3F9zMdTjcs@nazgul.tnic \
    --to=bp@alien8.de \
    --cc=ashok.raj@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®