public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 "Borislav Petkov (AMD)" <bp@alien8.de>
Subject: Re: [RFC PATCH] x86/cpufeatures: Flip the /proc/cpuinfo appearance logic
Date: Tue, 18 Jun 2024 07:06:13 -0700	[thread overview]
Message-ID: <ZnGUVcEUUF_1Vqmi@google.com> (raw)
In-Reply-To: <20240618113840.24163-1-bp@kernel.org>

On Tue, Jun 18, 2024, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
> 
> I'm getting tired of telling people to put a magic "" in the
> 
>   #define X86_FEATURE		/* "" ... */
> 
> comment to hide the new feature flag from the user-visible
> /proc/cpuinfo.
> 
> Flip the logic to make it explicit: an explicit "<name>" in the comment
> adds the flag to /proc/cpuinfo and otherwise not, by default.
> 
> Add the "<name>" of all the existing flags to keep backwards
> compatibility with userspace.

If we're going to churn the whole file, why not take the opportunity make it more
structured?  E.g. use a variadic macro so the name doesn't need to be buried in a
string inside a comment, and so that each feature doesn't have to open code the
math.  Lack of third input omits the flag from /proc/cpuinfo, and a magic keyword,
e.g. AUTO, uses the feature name.

There are quite a few games that could be played with macros, and IMO pretty much
all of them would be better than comment+string shenanigans.

#define X86F(word, bit, abi_name...) ((word) * 32 + bit)

#define X86_FEATURE_FPU           X86F(0,  0, AUTO)

#define X86_FEATURE_XMM		  X86F(0, 25, SSE2)

#define X86_FEATURE_K8		  X86F(3,  4)


  reply	other threads:[~2024-06-18 14:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18 11:38 [RFC PATCH] x86/cpufeatures: Flip the /proc/cpuinfo appearance logic Borislav Petkov
2024-06-18 14:06 ` Sean Christopherson [this message]
2024-06-18 18:36   ` Borislav Petkov
2024-06-18 15:46 ` Dave Hansen
2024-06-19  8:11 ` H. Peter Anvin
2024-06-20 18:40   ` Borislav Petkov
2024-06-21 10:31 ` [tip: x86/cpu] " tip-bot2 for Borislav Petkov (AMD)

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=ZnGUVcEUUF_1Vqmi@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=bp@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.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