mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sohil Mehta <sohil.mehta@intel.com>
To: Maciej Wieczor-Retman <m.wieczorretman@pm.me>
Cc: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
	<linux-kernel@vger.kernel.org>, Thomas Gleixner <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v8 3/3] x86/cpu: Do a sanity check on required feature bits
Date: Tue, 10 Mar 2026 00:05:24 -0700	[thread overview]
Message-ID: <de60dc2f-d923-4ac5-890e-9d6bab58bc28@intel.com> (raw)
In-Reply-To: <39306e7e736f76530db62302f1dfa3b94a479861.1772453012.git.m.wieczorretman@pm.me>

On 3/2/2026 7:25 AM, Maciej Wieczor-Retman wrote:

> +/*
> + * As a sanity check compare the final x86_capability bitmask with the initial
> + * predefined required feature bits. In case of a mismatch emit a warning with
> + * the faulty bitmask value.

Aren't we printing the faulty feature name instead of the bitmask value?

> + */
> +static void verify_required_features(const struct cpuinfo_x86 *c)
> +{
> +	u32 missing[NCAPINTS] = REQUIRED_MASK_INITIALIZER;
> +	char cap_buf[16];
> +	u32 error = 0;
> +	unsigned int i;
> +

X86 prefers reverse Xmas order for variable declarations.

> +	for (i = 0; i < NCAPINTS; i++) {
> +		missing[i] &= ~c->x86_capability[i];
> +		error |= missing[i];
> +	}
> +
> +	if (!error)
> +		return;		/* All good */
> +

The tail comments should be avoided. This one is completely unnecessary
here.


> +	/*
> +	 * At least one required feature is missing. Print a warning,
> +	 * and taint the kernel.
> +	 */

The "print a warning, and taint the kernel" part seems redundant.
Probably there is no need for a comment here as well.

> +	pr_warn("cpu %d: missing required feature(s):", c->cpu_index);
> +	for_each_set_bit(i, (void *)missing, NCAPINTS << 5)

for_each_set_bit() typically expects unsigned long *. Do you run into
any issue if you use that?

> +		pr_cont(" %s", x86_cap_name(i, cap_buf));
> +	pr_cont("\n");
> +	add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
> +}
> +
>  /*
>   * This does the hard work of actually picking apart the CPU stuff...
>   */
> @@ -2125,6 +2156,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)
>  	mcheck_cpu_init(c);
>  
>  	numa_add_cpu(smp_processor_id());
> +
> +	verify_required_features(c);
>  }
>  
>  /*


  reply	other threads:[~2026-03-10  7:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 15:24 [PATCH v8 0/3] x86: Capability bits fix and required bits sanity check Maciej Wieczor-Retman
2026-03-02 15:25 ` [PATCH v8 1/3] x86/cpu: Clear feature bits disabled at compile-time Maciej Wieczor-Retman
2026-03-02 19:31   ` Borislav Petkov
2026-03-02 19:48     ` Maciej Wieczor-Retman
2026-03-02 20:25       ` Borislav Petkov
2026-03-02 20:38         ` Maciej Wieczor-Retman
2026-03-02 20:59           ` Borislav Petkov
2026-03-02 21:22             ` Maciej Wieczor-Retman
2026-03-03  5:59               ` Borislav Petkov
2026-03-09 23:47   ` Sohil Mehta
2026-03-10 10:49     ` Maciej Wieczor-Retman
2026-03-02 15:25 ` [PATCH v8 2/3] x86/cpu: Check if feature string is non-zero Maciej Wieczor-Retman
2026-03-10  6:23   ` Sohil Mehta
2026-03-10 12:29     ` Maciej Wieczor-Retman
2026-03-02 15:25 ` [PATCH v8 3/3] x86/cpu: Do a sanity check on required feature bits Maciej Wieczor-Retman
2026-03-10  7:05   ` Sohil Mehta [this message]
2026-03-10 13:06     ` Maciej Wieczor-Retman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de60dc2f-d923-4ac5-890e-9d6bab58bc28@intel.com \
    --to=sohil.mehta@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.wieczorretman@pm.me \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®