Re: [PATCH v7 1/6] x86/fpu/xstate: Differentiate default features for host and guest FPUs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 21, 2025 at 09:49:48AM -0700, Sean Christopherson wrote:
>On Mon, May 12, 2025, Chao Gao wrote:
>> @@ -772,6 +776,21 @@ static void __init fpu__init_disable_system_xstate(unsigned int legacy_size)
>>  	fpstate_reset(x86_task_fpu(current));
>>  }
>>  
>> +static void __init init_default_features(u64 kernel_max_features, u64 user_max_features)
>> +{
>> +	u64 kfeatures = kernel_max_features;
>> +	u64 ufeatures = user_max_features;
>> +
>> +	/* Default feature sets should not include dynamic xfeatures. */
>> +	kfeatures &= ~XFEATURE_MASK_USER_DYNAMIC;
>> +	ufeatures &= ~XFEATURE_MASK_USER_DYNAMIC;
>> +
>> +	fpu_kernel_cfg.default_features = kfeatures;
>> +	fpu_user_cfg.default_features   = ufeatures;
>> +
>> +	guest_default_cfg.features      = kfeatures;
>> +}
>> +
>>  /*
>>   * Enable and initialize the xsave feature.
>>   * Called once per system bootup.
>> @@ -854,12 +873,8 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)
>>  	fpu_user_cfg.max_features = fpu_kernel_cfg.max_features;
>>  	fpu_user_cfg.max_features &= XFEATURE_MASK_USER_SUPPORTED;
>>  
>> -	/* 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_user_cfg.default_features = fpu_user_cfg.max_features;
>> -	fpu_user_cfg.default_features &= ~XFEATURE_MASK_USER_DYNAMIC;
>> +	/* Now, given maximum feature set, determine default values */
>> +	init_default_features(fpu_kernel_cfg.max_features, fpu_user_cfg.max_features);
>
>Passing in max_features is rather odd.  I assume the intent is to capture the
>dependencies, but that falls apart by the end of series as the guest features
>are initialized as:
>
>	guest_default_cfg.features      = kfeatures | xfeatures_mask_guest_supervisor();
>
>where xfeatures_mask_guest_supervisor() sneakily consumes fpu_kernel_cfg.max_features,
>the very field this patch deliberately avoids consuming directly.
>
>  static inline u64 xfeatures_mask_guest_supervisor(void)
>  {
>	return fpu_kernel_cfg.max_features & XFEATURE_MASK_GUEST_SUPERVISOR;
>  }
>

Indeed, it is odd. And your suggestion looks good to me. Thanks.

I will fix this and the comment issue you pointed out and post a new version.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux