Re: [PATCH v12 3/4] x86/cpu: Do a sanity check on required feature bits
From: Pawan Gupta
Date: Fri Mar 27 2026 - 13:18:04 EST
On Fri, Mar 27, 2026 at 03:10:58PM +0000, Maciej Wieczor-Retman wrote:
> +static void verify_required_features(const struct cpuinfo_x86 *c)
> +{
> + u32 required_features[NCAPINTS + 1] = REQUIRED_MASK_INIT;
> + char cap_buf[X86_NAMELESS_FEAT_BUFLEN];
> + int i, error = 0;
> +
> + for_each_set_bit(i, (unsigned long *)required_features, NCAPINTS * 32) {
> + if (test_bit(i, (unsigned long *)c->x86_capability))
This can be simplified to:
if (test_cpu_cap(c, i))
> + continue;
> + if (!error)
> + pr_warn("CPU %d: missing required feature(s):", c->cpu_index);
> + pr_cont(" %s", x86_feature_name(i, cap_buf));
> + error = 1;
> + }
> +
> + if (!error)
> + return;
> +
> + pr_cont("\n");
> + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
> +}