Re: [PATCH v6 10/90] x86/cpu: Rescan CPUID table after disabling PSN

From: Ahmed S. Darwish

Date: Tue May 12 2026 - 03:12:39 EST


Hi Boris,

On Mon, 11 May 2026, Borislav Petkov wrote:
>
> Except that those changes do not belong in this set. So I zapped them, see
> below.
>

Yeah, fair enough.

> Also, why are you doing this min_t thing?
>
> + rescan_from = min_t(int, l0->max_std_leaf, c->cpuid_level) + 1;
> + cpuid_refresh_range(c, rescan_from, CPUID_BASE_END);
> + c->cpuid_level = l0->max_std_leaf;
>

The min_t() logic is meant to handle both max-CPUID-level increases and
decreases after the MSR write.

Assuming a machine with PSN and CPUID(0x3) as the max standard level:

c->cpuid_level == 3

-> MSR write, disable PSN
-> hardware: Max CPUID level becomes 2

Refresh CPUID(0x0)
l0->max_std_leaf == 2
cpuid_refresh_range(c, min(2, 3) + 1, CPUID_BASE_END)

Then, the CPUID parser will avoid touching CPUID(0x1) and CPUID(0x2) and
zero the table from CPUID(0x3) upwards.

Similarly, at patch (13/90), "x86/cpu/intel: Rescan CPUID table after leaf
unlock":

c->cpuid_level == 2

-> MSR write, disable BIOS limiting all leafs > CPUID(0x2)
-> hardware: Max CPUID level becomes 8

Refresh CPUID(0x0)
l0->max_std_leaf == 8
cpuid_refresh_range(c, min(2, 8) + 1, CPUID_BASE_END)

Then the CPUID parser will zero and refresh all leaves from CPUID(0x3)
upwards.

So the min_t()'s intent is just to be defensive against hardware surprises.

If you think this is superfulous, then ACK, removing it will not harm.

Thanks!
Ahmed