Re: [PATCH v11 4/4] x86/cpu: Clear feature bits whose dependencies were cleared

From: Ahmed S. Darwish

Date: Mon Mar 23 2026 - 15:34:15 EST


On Mon, 23 Mar 2026, H. Peter Anvin wrote:
>
> 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'm posting the CPUID patch queue tomorrow. It has all the X86_FEATURE
words (synthetic and hardware-backed) modeled and mapped by x86-cpuid-db.

These XMLs are definitely the right place to encode the dependencies, as
there is already different types of generators in the project.

The series cover letter tomorrow will cover a lot of details on this.

Thanks!
Ahmed