Re: [PATCH] x86/fpu/xstate: clear XSAVE features if DISABLED_MASK set

From: Borislav Petkov
Date: Wed May 31 2023 - 17:29:21 EST


On Wed, May 31, 2023 at 08:18:34PM +0000, Sean Christopherson wrote:
> Assert that the to-be-checked bit passed to cpu_feature_enabled() is a
> compile-time constant instead of applying the DISABLED_MASK_BIT_SET()
> logic if and only if the bit is a constant. Conditioning the check on
> the bit being constant instead of requiring the bit to be constant could
> result in compiler specific kernel behavior, e.g. running on hardware that
> supports a disabled feature would return %false if the compiler resolved
> the bit to a constant, but %true if not.

Uff, more mirroring CPUID inconsistencies.

So *actually*, we should clear all those build-time disabled bits from
x86_capability so that this doesn't happen.

> All current usage of cpu_feature_enabled() specifies a hardcoded
> X86_FEATURE_* flag, so this *should* be a glorified nop.

Also, pls add here the exact example which prompted this as I'm sure we
will forget why this was done.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette