Re: [PATCH] x86/fpu: Use consistent test for X86_FEATURE_XSAVES

From: Borislav Petkov
Date: Wed Feb 03 2021 - 11:00:56 EST


On Wed, Feb 03, 2021 at 07:40:07AM -0800, Dave Hansen wrote:
> On 2/3/21 3:23 AM, Borislav Petkov wrote:
> >> -/*
> >> - * 'XSAVES' implies two different things:
> >> - * 1. saving of supervisor/system state
> >> - * 2. using the compacted format
> >> - *
> >> - * Use this function when dealing with the compacted format so
> >> - * that it is obvious which aspect of 'XSAVES' is being handled
> >> - * by the calling code.
> > @dhansen, are you still hung up on that "obvious aspect" or can we kill
> > this?
>
> I still want the compacted-format handling code to be marked. You can
> do that with new comments:
>
> /* Note: XSAVES always uses compacted format: */
> if (boot_cpu_has(X86_FEATURE_XSAVES)) {
>
> or, leave it as-is:
>
> if (using_compacted_format()) {
> ...
>
> Otherwise, we assume that every human being that looks at this code
> *KNOWS* that XSAVES==compacted. That's not a great assumption.

Well, the reason why I reacted to this is because I was looking at
using_compacted_format() - aha this, checks X86_FEATURE_XSAVES - but
then other code paths in fpu/ check X86_FEATURE_XSAVES directly. And
this is confusing, making me wonder why is that special oneliner there.
Sure, the comment above it says why...

I guess if you wanna keep it, then we need another oneliner for 1. or
really do comments at each call site.

Hmm.

--
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg