Re: [PATCH v10 3/3] x86/cpu: Do a sanity check on required feature bits

From: Sohil Mehta

Date: Tue Mar 17 2026 - 16:44:41 EST


On 3/17/2026 1:00 PM, Maciej Wieczor-Retman wrote:
> From: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
>
> After CPU identification concludes, do a sanity check by comparing the
> final x86_capability bitmask with the pre-defined required feature bits.
>
> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
> Acked-by: H. Peter Anvin (Intel) <hpa@xxxxxxxxx>
> ---

A minor concern below. Other than that,

Reviewed-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>


>
> +/*
> + * As a sanity check compare the final x86_capability bitmask with the initial
> + * predefined required feature bits.
> + */
> +static void verify_required_features(const struct cpuinfo_x86 *c)
> +{
> + u32 missing[NCAPINTS] = REQUIRED_MASK_INIT;
> + char cap_buf[X86_CAP_BUF_SIZE];
> + unsigned int i;
> + u32 error = 0;
> +
> + for (i = 0; i < NCAPINTS; i++) {
> + missing[i] &= ~c->x86_capability[i];
> + error |= missing[i];
> + }
> +
> + if (!error)
> + return;
> +
> + /* At least one required feature is missing */
> + pr_warn("CPU %d: missing required feature(s):", c->cpu_index);
> + for_each_set_bit(i, (unsigned long *)missing, NCAPINTS * 32)
> + pr_cont(" %s", x86_cap_name(i, cap_buf));
> + pr_cont("\n");

Could multiple APs run into this concurrently? I am wondering if there
is some risk of garbled output because of the pr_warn()/pr_cont()
combination.

Though, I don't have an easy fix if it is an issue.

> + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
> +}
> +
> /*
> * This does the hard work of actually picking apart the CPU stuff...
> */
> @@ -2134,6 +2161,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)
> mcheck_cpu_init(c);
>
> numa_add_cpu(smp_processor_id());
> +
> + verify_required_features(c);
> }
>
> /*