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 - 17:43:36 EST


> T0 arrives, and fails the update. That is this piece:
>
> /* write microcode via MSR 0x79 */
> wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits);
>
> rev = intel_get_microcode_revision();
>
> if (rev != mc->hdr.rev) {
> pr_err("CPU%d update to revision 0x%x failed\n",
> cpu, mc->hdr.rev);
> return UCODE_ERROR;
> }
>
> We return here without updating cpu_sig.rev, as we should.
>
> T1 arrives, updates successfully and updates its cpu_sig.rev.

In an ideal world yes. But what if T1 arrives here and tries to do the
update while T0, which has returned out of the microcode update
code and could be doing anything, happen to be doing WRMSR(some MSR
that the ucode update is tinkering with).

Now T0 explodes (not literally, I hope!) but does something crazy because
it was in the middle of some microcode flow that got updated between two
operations.

-Tony