Re: [PATCH v3 05/21] x86/fpu/xstate: Add a new variable to indicate dynamic user states

From: Bae, Chang Seok
Date: Fri Jan 15 2021 - 14:48:33 EST


On Jan 15, 2021, at 05:39, Borislav Petkov <bp@xxxxxxx> wrote:
> On Wed, Dec 23, 2020 at 07:57:01AM -0800, Chang S. Bae wrote:
>> The perf has a buffer that is allocated on demand. The states saved in the
>
> What's "the perf"? I hope to find out when I countinue reading…

Maybe it was better to write ‘Linux perf (tools)’ [1] here. Sorry for the
confusion.

>> diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h
>> index 24bf8d3f559a..6ce8350672c2 100644
>> --- a/arch/x86/include/asm/fpu/xstate.h
>> +++ b/arch/x86/include/asm/fpu/xstate.h
>> @@ -56,7 +56,7 @@
>> * - Don't set the bit corresponding to the dynamic supervisor feature in
>> * IA32_XSS at run time, since it has been set at boot time.
>> */
>> -#define XFEATURE_MASK_DYNAMIC (XFEATURE_MASK_LBR)
>> +#define XFEATURE_MASK_SUPERVISOR_DYNAMIC (XFEATURE_MASK_LBR)
>
> Is XFEATURE_MASK_USER_DYNAMIC coming too?

Instead of the new define, I thought the new variable --
xfeatures_mask_user_dynamic, as its value needs to be determined at boot
time.

PATCH13/21 has the routine:

xfeatures_mask_all &= fpu__get_supported_xfeatures_mask();
- /* Do not support the dynamically allocated buffer yet. */
xfeatures_mask_user_dynamic = 0;

+ for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
+ u64 feature_mask = BIT_ULL(i);
+
+ if (!(xfeatures_mask_user() & feature_mask))
+ continue;
+
+ if (xfeature_disable_supported(i))
+ xfeatures_mask_user_dynamic |= feature_mask;
+ }
+

Thanks,
Chang

[1] https://en.wikipedia.org/wiki/Perf_(Linux)