Re: [PATCH v9 2/5] x86/cpuid: Add generic table for cpuid dependencies

From: Thomas Gleixner
Date: Sun Oct 08 2017 - 04:36:52 EST


On Fri, 6 Oct 2017, Andi Kleen wrote:

> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> Some CPUID features depend on other features. Currently it's
> possible to to clear dependent features, but not clear the base features,
> which can cause various interesting problems.
>
> This patch implements a generic table to describe dependencies
> between CPUID features, to be used by all code that clears
> CPUID.
>
> Some subsystems (like XSAVE) had an own implementation of this,
> but it's better to do it all in a single place for everyone.
>
> Then clear_cpu_cap and setup_clear_cpu_cap always look up
> this table and clear all dependencies too.
>
> This is intended to be a practical table: only for features
> that make sense to clear. If someone for example clears FPU,
> or other features that are essentially part of the required
> base feature set, not much is going to work. Handling
> that is right now out of scope. We're only handling
> features which can be usefully cleared.
>
> v2: Add EXPORT_SYMBOL for clear_cpu_cap for lguest
> v3:
> Fix handling of depending issues
> Fix dups in the table (Jonathan McDowell)
> v4:
> Remove EXPORT_SYMBOL again as lguest is gone
> Restructure dependencies as feature, dependency (Thomas Gleixner)
> Move some code from header file to C file and turn macros into inlines (dito)
> Simplify if conditions (dito)
> Add missing dependency for AVX512F->AVX
> v5:
> Remove redundant dependency for AVX512F->XSAVE (Thomas Gleixner)
> Add missing dependency for XMM->FXSR (Thomas Gleixner)
> v6:
> Add SHA_NI->XMM and FXSR_OPT->FXSAVE dependencies
> Cc: Jonathan McDowell <noodles@xxxxxxxx>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>

Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>