Re: [PATCH v9 08/26] x86/fpu/xstate: Introduce helpers to manage the XSTATE buffer dynamically

Bae, Chang Seok
2021-08-30T23:40:06Z

On Aug 30, 2021, at 10:07, Borislav Petkov <bp@alien8.de> wrote:
> On Wed, Aug 18, 2021 at 07:46:55PM +0000, Bae, Chang Seok wrote:
>> No, this non-compacted thing is not for optimization. SDM is not quite clear
>> about the logic behind the non-compacted format -- some state’s offset does
>> not always match with the 'size + offset' of the previous one, even without
>> 64B-alignment. So, the loop is only for the compacted format, not the
>> non-compacted one.
>>
>> It was refactored to use in the new helper to find feature_nr’s start point.
>> If the size is added up here, it is not ‘i’'s start point anymore.
>
> Let's see, we're still talking about this thing, right:
>
> nr = fls64(mask) - 1;
>
> if (!boot_cpu_has(X86_FEATURE_XSAVES))
> return xstate_offsets[nr] + xstate_sizes[nr];
>
> ?
>
> That @mask is "which components reserved in the buffer."
>
> Which buffer? The mask being passed is independent from whatever buffer.
>
> So you need to do a lot more explaining here before this goes anywhere.

Yes, this function that you suggested to rename like
calculate_xstate_buf_size_from_mask() has no input to do with any buffer.

Perhaps, as Dave suggested [1],
"@mask The set of components for which the space is needed."

Along with these,
"calculate_xstate_buf_size_from_mask -- Calculate the amount of space
needed to store an xstate buffer with the given features.”

s/nr/last_feature_nr/

[1]: https://lore.kernel.org/lkml/bb49fdc9-2228-8bd1-bcc5-7c498daf0887@intel.com/

Thanks,
Chang