RE: [Patch v3 Part2 3/9] x86/microcode/intel: Fix collect_cpu_info() to reflect current microcode

From: Luck, Tony
Date: Tue Jan 31 2023 - 15:50:01 EST


> I presume you're talking about late update. If so and if it finds a
> patch in the cache, it'll do this:

Yes. This is about late update.

>
> apply_microcode_intel:
>
> /*
> * Save us the MSR write below - which is a particular expensive
> * operation - when the other hyperthread has updated the microcode
> * already.
> */
> rev = intel_get_microcode_revision();

What happens here if the update on the first hyperthread failed (sure, it shouldn't,
but stuff happens at large scale). In this case the current rev is still older that the
the cache version ... so there is no "goto out", and this hyperthread will now write
the MSR to initiate microcode update here, while the first thread is off executing
arbitrary code (the situation that we want to avoid).

> if (rev >= mc->hdr.rev) {
> ret = UCODE_OK;
> goto out;
> }
>
> and at the out: label it'll update the revision.

-Tony