Re: [PATCH 3/5] x86/microcode/intel: Allow a late-load only if a min rev is specified

Peter Zijlstra
2022-08-15T07:46:23Z

On Sat, Aug 13, 2022 at 10:38:23PM +0000, Ashok Raj wrote:

> The proposal here is an even simpler option. The criteria for a microcode to
> be a viable late-load candidate is that no CPUID or OS visible MSR features
> are removed with respect to an earlier version of the microcode.
>
> Pseudocode for late-load is as follows:
>
> if header.min_required_id == 0
> This is old format microcode, block late-load
> else if current_ucode_version < header.min_required_id
> Current version is too old, block late-load of this microcode.
> else
> OK to proceed with late-load.
>
> Any microcode that removes a feature will set the min_version to itself.
> This will enforce this microcode is not suitable for late-loading.
>
> The enforcement is not in hardware and limited to kernel loader enforcing
> the requirement. It is not required for early loading of microcode to
> enforce this requirement, since the new features are only
> evaluated after early loading in the boot process.
>
>
> Test cases covered:
>
> 1. With new kernel, attempting to load an older format microcode with the
> min_rev=0 should be blocked by kernel.
>
> [ 210.541802] microcode: Header MUST specify min version for late-load
>
> 2. New microcode with a non-zero min_rev in the header, but the specified
> min_rev is greater than what is currently loaded in the CPU should be
> blocked by kernel.
>
> 245.139828] microcode: Current revision 0x8f685300 is too old to update,
> must be at 0xaa000050 version or higher
>
> 3. New microcode with a min_rev < currently loaded should allow loading the
> microcode
>
> 4. Build initrd with microcode that has min_rev=0, or min_rev > currently
> loaded should permit early loading microcode from initrd.

What if any validation do you have to ensure min_rev does as promised?
That is, ucode can very easily lie about the number and still remove an
MSR or CPUID enumerated feature.