public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Borislav Petkov <bp@alien8.de>,
	Maciej Wieczor-Retman <m.wieczorretman@pm.me>
Cc: tglx@kernel.org, peterz@infradead.org, xin@zytor.com,
	maciej.wieczor-retman@intel.com, babu.moger@amd.com,
	chang.seok.bae@intel.com, sohil.mehta@intel.com,
	dave.hansen@linux.intel.com, jpoimboe@kernel.org,
	elena.reshetova@intel.com, pawan.kumar.gupta@linux.intel.com,
	ak@linux.intel.com, darwi@linutronix.de, mingo@redhat.com,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v11 4/4] x86/cpu: Clear feature bits whose dependencies were cleared
Date: Mon, 23 Mar 2026 11:57:45 -0700	[thread overview]
Message-ID: <55af4420-e230-4f14-a2d3-608f2bc5a412@zytor.com> (raw)
In-Reply-To: <20260323175902.GBacF_ZnWQJJWdOZJT@fat_crate.local>

On 2026-03-23 10:59, Borislav Petkov wrote:
> On Mon, Mar 23, 2026 at 05:23:19PM +0000, Maciej Wieczor-Retman wrote:
>> Clearing the compile time disabled bits is fairly low effort since it's just
>> initializing the cpu_caps_cleared[].
> 
> and cpu_caps_cleared[] is consulted in apply_forced_caps().
> 
>> To validate the whole cpuid_deps[] array and add relevant bits to
>> cpu_caps_cleared[] would probably require adding another loop that would
>> check all of the entries. Since now only SGX has this problem I didn't think
>> it warranted adding more than this check in check_cpufeature_deps().
> 
> So we're going to do half-baked solution again and it'll come to bite us in
> the ass later?
> 
> How about we hammer it out properly once and for all?
> 

One could argue that the Right Thing[TM] to do would be to encode the
dependencies in a file that can be processed at compile time, and have those
features explicitly added to the enabled and disabled masks, basically
augmenting Kconfig.cpufeatures.

The sanest way to do that would probably be to move cpuid_deps[] from
cpuid-deps.c into a standalone file which can be processed by
cpufeaturesmask.awk or equivalent.

I do have to say that using awk for these things, especially being restricted
to POSIX awk, is really awful as it really is pushing the limits of that tool.
String processing in C is most definitely no fun either -- the single biggest
shortcoming of what is otherwise one of my favorite languages -- but it
*would* also be possible to refactor cpuid-deps.c so that it can be compiled
in user space and linked with a C tool that would replace cpufeaturesmask.awk,
mkcapflags.sh, and boot/mkcpustr.c.

This seemed to me to be a bit excessive in terms of churn and complexity, but
perhaps this is what you are looking for?

	-hpa






  parent reply	other threads:[~2026-03-23 19:14 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 12:50 [PATCH v11 0/4] x86: Capability bits fix and required bits sanity check Maciej Wieczor-Retman
2026-03-20 12:50 ` [PATCH v11 1/4] x86/cpu: Clear feature bits disabled at compile-time Maciej Wieczor-Retman
2026-03-20 12:50 ` [PATCH v11 2/4] x86/cpu: Check if feature string is non-zero Maciej Wieczor-Retman
2026-03-23 14:24   ` Borislav Petkov
2026-03-23 15:52     ` Maciej Wieczor-Retman
2026-03-23 16:23       ` Borislav Petkov
2026-03-23 16:58         ` Maciej Wieczor-Retman
2026-03-23 17:51           ` Borislav Petkov
2026-03-23 18:11             ` Maciej Wieczor-Retman
2026-03-23 18:15               ` H. Peter Anvin
2026-03-20 12:50 ` [PATCH v11 3/4] x86/cpu: Do a sanity check on required feature bits Maciej Wieczor-Retman
2026-03-21  0:31   ` Pawan Gupta
2026-03-21  5:58     ` Maciej Wieczór-Retman
2026-03-23 18:16       ` Pawan Gupta
2026-03-23 18:33         ` Maciej Wieczor-Retman
2026-03-26 18:36     ` Maciej Wieczor-Retman
2026-03-26 19:04       ` Pawan Gupta
2026-03-26 19:11         ` Maciej Wieczor-Retman
2026-03-28  1:52           ` H. Peter Anvin
2026-03-28  2:01             ` H. Peter Anvin
2026-03-30  9:47               ` Maciej Wieczor-Retman
2026-03-30 10:09             ` Maciej Wieczor-Retman
2026-03-30 16:01               ` Pawan Gupta
2026-03-30 21:24               ` David Laight
2026-03-31  8:12                 ` Maciej Wieczor-Retman
2026-03-31 13:29             ` Maciej Wieczor-Retman
2026-03-23 16:31   ` Borislav Petkov
2026-03-23 17:05     ` Maciej Wieczor-Retman
2026-03-23 17:55       ` Borislav Petkov
2026-03-23 18:43         ` H. Peter Anvin
2026-03-23 18:43     ` H. Peter Anvin
2026-03-23 19:19       ` Borislav Petkov
2026-03-23 20:24         ` H. Peter Anvin
2026-03-23 20:58           ` Borislav Petkov
2026-03-23 21:40             ` H. Peter Anvin
2026-03-23 21:50               ` Borislav Petkov
2026-03-23 21:56                 ` Borislav Petkov
2026-03-23 22:03                 ` H. Peter Anvin
2026-03-23 22:09                   ` Borislav Petkov
2026-03-24  1:16                     ` H. Peter Anvin
2026-03-20 12:50 ` [PATCH v11 4/4] x86/cpu: Clear feature bits whose dependencies were cleared Maciej Wieczor-Retman
2026-03-23 16:35   ` Borislav Petkov
2026-03-23 17:23     ` Maciej Wieczor-Retman
2026-03-23 17:59       ` Borislav Petkov
2026-03-23 18:18         ` Maciej Wieczor-Retman
2026-03-23 18:57         ` H. Peter Anvin [this message]
2026-03-23 19:30           ` Borislav Petkov
2026-03-25  9:33             ` Maciej Wieczor-Retman
2026-03-23 19:33           ` Ahmed S. Darwish

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=55af4420-e230-4f14-a2d3-608f2bc5a412@zytor.com \
    --to=hpa@zytor.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=elena.reshetova@intel.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=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=sohil.mehta@intel.com \
    --cc=tglx@kernel.org \
    --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