mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
To: Maciej Wieczor-Retman <m.wieczorretman@pm.me>
Cc: tglx@kernel.org, bp@alien8.de, mingo@redhat.com,
	darwi@linutronix.de, thuth@redhat.com,
	dave.hansen@linux.intel.com, ak@linux.intel.com,
	babu.moger@amd.com, chang.seok.bae@intel.com,
	peterz@infradead.org, nik.borisov@suse.com, jpoimboe@kernel.org,
	hpa@zytor.com, xin@zytor.com, maciej.wieczor-retman@intel.com,
	sohil.mehta@intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v10 2/3] x86/cpu: Check if feature string is non-zero
Date: Wed, 18 Mar 2026 16:41:58 -0700	[thread overview]
Message-ID: <20260318234158.4nluxyckypcezyam@desk> (raw)
In-Reply-To: <92b57f62940b1972d39ae270b1b1ea497462c9ec.1773771353.git.m.wieczorretman@pm.me>

On Tue, Mar 17, 2026 at 08:00:16PM +0000, Maciej Wieczor-Retman wrote:
> From: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> 
> In filter_cpuid_features(), x86_cap_flags[] is read, but it's not verified
> whether the string is non-zero which could lead to unwanted output.
> 
> In two more places there are open coded paths that try to retrieve a
> feature string, and if there isn't one, the feature word and bit are
> returned instead.
> 
> Add a common helper to fix filter_cpuid_features() as well as clean up
> the open coded cases.
> 
> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> ---
> Changelog v10:
> - Reword the patch message a bit.
> - Move x86_cap_name() declaration and X86_CAP_BUF_SIZE define to
>   asm/cpufeature.h.
> - Don't include asm/cpu.h in cpuid-deps.c
> - Extend the comment above x86_cap_name to include information on buffer
>   size that needs to be prepared before calling the function.
> - Remove the likely(), unlikely() calls since this is not a hot path.
> 
> Changelog v9:
> - 16 -> X86_CAP_BUF_SIZE.
> - Add comment to the x86_cap_name().
> 
> Changelog v8:
> - Move x86_cap_name() declaration from linux/cpu.h to the arch/cpu.h.
>   Include arch/cpu.h in the cpuid-deps.c file instead of linux/cpu.h.
> 
> Changelog v7:
> - sizeof(buf) -> 16
> - Rebase onto 7.01-rc1.
> 
> Changelog v6:
> - Remove parts of the patch message that are redundant and just copy
>   what's visible in the diff.
> - Redo the helper to use an external char buffer instead of a local
>   static string.
> 
>  arch/x86/include/asm/cpufeature.h |  4 ++++
>  arch/x86/kernel/cpu/common.c      | 32 ++++++++++++++++++++++++++-----
>  arch/x86/kernel/cpu/cpuid-deps.c  | 21 +++-----------------
>  3 files changed, 34 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
> index 3ddc1d33399b..dc1cd44ddd63 100644
> --- a/arch/x86/include/asm/cpufeature.h
> +++ b/arch/x86/include/asm/cpufeature.h
> @@ -138,5 +138,9 @@ static __always_inline bool _static_cpu_has(u16 bit)
>  #define CPU_FEATURE_TYPEVAL		boot_cpu_data.x86_vendor, boot_cpu_data.x86, \
>  					boot_cpu_data.x86_model
>  
> +#define X86_CAP_BUF_SIZE			16

This can get rid of the extra tab.

Reviewed-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>

  parent reply	other threads:[~2026-03-18 23:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 20:00 [PATCH v10 0/3] x86: Capability bits fix and required bits sanity check Maciej Wieczor-Retman
2026-03-17 20:00 ` [PATCH v10 1/3] x86/cpu: Clear feature bits disabled at compile-time Maciej Wieczor-Retman
2026-03-17 20:00 ` [PATCH v10 2/3] x86/cpu: Check if feature string is non-zero Maciej Wieczor-Retman
2026-03-17 20:29   ` Sohil Mehta
2026-03-18 23:41   ` Pawan Gupta [this message]
2026-03-19 17:18     ` Maciej Wieczor-Retman
2026-03-17 20:00 ` [PATCH v10 3/3] x86/cpu: Do a sanity check on required feature bits Maciej Wieczor-Retman
2026-03-17 20:43   ` Sohil Mehta
2026-03-18 10:08     ` Maciej Wieczor-Retman
2026-03-19  0:02   ` Pawan Gupta
2026-03-19 17:46     ` 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=20260318234158.4nluxyckypcezyam@desk \
    --to=pawan.kumar.gupta@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=darwi@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.wieczorretman@pm.me \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=sohil.mehta@intel.com \
    --cc=tglx@kernel.org \
    --cc=thuth@redhat.com \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /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®