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

Re: [XEN][PATCH v7] x86: make Viridian support optional


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Wed, 12 Nov 2025 15:27:45 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wGuOmNpP5yyZ1l/CrpgcvPM7sz1OuSZiU/VII2toOT4=; b=mTJYomaYpxU9Pw4x93QhH4Iozy09TwmWmoXhiO6HvHzoCd/V+kC99tCRX+tGAhOLXWwZfcGdOci6YswQZRUpcrfEhEg2MaGP0Myq2L7cOPwKE9P+8Bzj9l6HAPYNIg2NLirUDHhQvmEErl/qgbHtwa5975wCz9X/A9qWDJlU/8Y6ZHbF5Nw9HTB0P0C/XKbF48FSGdKEkXdoLE4Z0C8gLg5Cf5FDpQneE7l9XDbFgE/NCWVedoeGyHDfcWW3j9h+iz6CH2S/Qg8cHYZgyt2RdLBJUQrFSCkhuo0Y+MBwnqrR19swxdjCUCc1/6Oq9mgv3+ffOchBk3LFo79XXKmkXg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WtQ5wVd9yZEiSZheeyJ5pKbr1U2RujyAFRCT5LaoQcJqOzaxWqdJCZ+iqrmOFWowS3rrgwOjvHPD9aanikyU/urKjE9lLLQSpV7a0CaHN85hYXl361iO79iwi6xGXEcUMU6fPIKk6dkFvidAktubFsZJ13PBXxffx/7z9YUfTafmgr2BLyRYxJWhQTEo/3xxqW/2fW3o/S6zA8zVhlKpQHbC7LzsC2dYuek0UrFjJruSV3Eh1vXBo+vE9du4NHGy9uVkNmmIM3mtH52DR8xNyPwuBbR/0Hsay6rbVLoizTUn6q5BlkHjriuNLavshYRr2kPZBsVnVFBBrokE/Y2Iaw==
  • Cc: Sergiy Kibrik <Sergiy_Kibrik@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>
  • Delivery-date: Wed, 12 Nov 2025 14:28:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed Nov 12, 2025 at 7:40 AM CET, Jan Beulich wrote:
> On 11.11.2025 19:25, Grygorii Strashko wrote:
>> On 06.11.25 15:47, Jan Beulich wrote:
>>> On 06.11.2025 14:42, Grygorii Strashko wrote:
>>>> On 06.11.25 13:35, Jan Beulich wrote:
>>>>> On 31.10.2025 17:17, Grygorii Strashko wrote:
>>>>>> --- a/xen/arch/x86/hvm/hvm.c
>>>>>> +++ b/xen/arch/x86/hvm/hvm.c
>>>>>> @@ -4231,8 +4231,9 @@ static int hvm_set_param(struct domain *d, 
>>>>>> uint32_t index, uint64_t value)
>>>>>>                rc = -EINVAL;
>>>>>>            break;
>>>>>>        case HVM_PARAM_VIRIDIAN:
>>>>>> -        if ( (value & ~HVMPV_feature_mask) ||
>>>>>> -             !(value & HVMPV_base_freq) )
>>>>>> +        if ( !IS_ENABLED(CONFIG_VIRIDIAN) && value )
>>>>>> +            rc = -ENODEV;
>>>>>> +        else if ( (value & ~HVMPV_feature_mask) || !(value & 
>>>>>> HVMPV_base_freq) )
>>>>>>                rc = -EINVAL;
>>>>>
>>>>> I find the check for value to be (non-)zero a little dubious here: If any 
>>>>> caller
>>>>> passed in 0, it would get back -EINVAL anyway. Imo -ENODEV would be more 
>>>>> suitable
>>>>> in that case as well. Things would be different if 0 was a valid value to 
>>>>> pass in.
>>>>
>>>> The idea was to distinguish between "Feature enabled, Invalid parameter" 
>>>> and "Feature disabled".
>>> "
>>> But you don't, or else the addition would need to live after the -EINVAL 
>>> checks.
>>> I also question the utility of knowing "parameter was invalid" when the 
>>> feature
>>> isn't available anyway.
>> 
>> My understanding here - I need to drop non-zero "value" check.
>> will be:
>> 
>>     case HVM_PARAM_VIRIDIAN:
>>         if ( !IS_ENABLED(CONFIG_VIRIDIAN) )
>>             rc = -ENODEV;
>>         else if ( (value & ~HVMPV_feature_mask) || !(value & 
>> HVMPV_base_freq) )
>>             rc = -EINVAL;
>>         break;
>
> Yes, or alternatively
>
>     case HVM_PARAM_VIRIDIAN:
>         if ( (value & ~HVMPV_feature_mask) || !(value & HVMPV_base_freq) )
>             rc = -EINVAL;
>         else if ( !IS_ENABLED(CONFIG_VIRIDIAN) )
>             rc = -ENODEV;
>         break;
>
> Both have their up- and down-sides.
>
> Jan

We should aim for Grygorii's form, imo. If anything because it eliminates
the second else-if on !VIRIDIAN, leading to a marginal binary size reduction.

There's no value in validation when viridian support just isn't there.

Cheers,
Alejandro




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.