Re: [PATCH v2 06/10] x86/mce: Convert multiple if () statements into a switch() statement

From: Dave Hansen
Date: Thu Oct 24 2024 - 18:19:22 EST


On 10/24/24 14:31, Sohil Mehta wrote:
> @@ -1924,6 +1924,10 @@ static void apply_quirks_intel(struct cpuinfo_x86 *c)
> struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array);
> struct mca_config *cfg = &mca_cfg;
>
> + /* Older CPUs (prior to family 6) don't need quirks. */
> + if (c->x86_vfm < INTEL_PENTIUM_PRO)
> + return;

In case anyone grumbles, this is one of those expressions that's not
perfect, but I think it's quite good enough in practice.

It wouldn't work if we ever (for instance) moved 'vendor' to be less
significant bits than 'model'. Or on a CPU that claimed to be family=6
but model=0. But Intel never (as far as I know) sold a CPU like that,
so it's probably only possible in a VM where these checks are rather
worthless anyway.

In short, I think >=INTEL_PENTIUM_PRO is a great check that can mean
"family 6 or later" almost anywhere.