Re: [PATCH v4 4/8] x86/fpu/xstate: Differentiate default features for host and guest FPUs
From: Chao Gao
Date: Tue Apr 01 2025 - 23:16:36 EST
On Tue, Apr 01, 2025 at 10:18:07AM -0700, Chang S. Bae wrote:
>On 3/18/2025 8:31 AM, Chao Gao wrote:
>>
>> @@ -807,9 +811,11 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)
>> /* Clean out dynamic features from default */
>> fpu_kernel_cfg.default_features = fpu_kernel_cfg.max_features;
>> fpu_kernel_cfg.default_features &= ~XFEATURE_MASK_USER_DYNAMIC;
>> + fpu_kernel_cfg.guest_default_features = fpu_kernel_cfg.default_features;
>> fpu_user_cfg.default_features = fpu_user_cfg.max_features;
>> fpu_user_cfg.default_features &= ~XFEATURE_MASK_USER_DYNAMIC;
>> + fpu_user_cfg.guest_default_features = fpu_user_cfg.default_features;
>
>And you'll add up this on patch7:
>
> + /* Clean out guest-only features from default */
> + fpu_kernel_cfg.default_features &= ~XFEATURE_MASK_SUPERVISOR_GUEST;
>
>
>I'm not sure this overall hunk is entirely clear.
I agree that this hunk is unclear, and your version is much better.
>
>
>Taking a step back, we currently define three types of xfeature sets:
>
> 1. 'default_features' in a task-inlined buffer
> 2. 'max_features' in an extended buffer
> 3. 'independent_features' in a separate buffer (only for LBR)
>
>The VCPU fpstate has so far followed (1) and (2). Now, since we're
>introducing divergence at (1), you've named it guest_default_features:
>
> 'default_features' < 'guest_default_features' < 'max_features'
>
>I don’t see a strong reason against introducing this new field, as 'guest'
>already implies the VCPU state. However, rather than directly modifying or
>extending struct fpu_state_config — which may not align well with VCPU FPU
>properties — a dedicated struct could provide a cleaner and more structured
>alternative:
>
> struct vcpu_fpu_config {
> unsigned int size;
> unsigned int user_size;
> u64 features;
> u64 user_features;
> } guest_default_cfg;
Your suggestion looks good to me, and I can definitely incorporate the change
in the next version. Thanks a lot, Chang.