All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
To: Jan Beulich <jbeulich@suse.com>,
	Grygorii Strashko <grygorii_strashko@epam.com>
Cc: "Sergiy Kibrik" <Sergiy_Kibrik@epam.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Paul Durrant" <paul@xen.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Jason Andryuk" <jason.andryuk@amd.com>
Subject: Re: [XEN][PATCH v7] x86: make Viridian support optional
Date: Wed, 12 Nov 2025 15:27:45 +0100	[thread overview]
Message-ID: <DE6SC2RG21IK.20ONZLHO187R5@amd.com> (raw)
In-Reply-To: <b829a9dc-ed1d-45f9-a56f-ec288e0d5523@suse.com>

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



  reply	other threads:[~2025-11-12 14:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 16:17 [XEN][PATCH v7] x86: make Viridian support optional Grygorii Strashko
2025-10-31 21:43 ` Jason Andryuk
2025-11-06 11:35 ` Jan Beulich
2025-11-06 13:42   ` Grygorii Strashko
2025-11-06 13:47     ` Jan Beulich
2025-11-11 18:25       ` Grygorii Strashko
2025-11-12  6:40         ` Jan Beulich
2025-11-12 14:27           ` Alejandro Vallejo [this message]
2025-11-12 16:35             ` Grygorii Strashko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DE6SC2RG21IK.20ONZLHO187R5@amd.com \
    --to=alejandro.garciavallejo@amd.com \
    --cc=Sergiy_Kibrik@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=grygorii_strashko@epam.com \
    --cc=jason.andryuk@amd.com \
    --cc=jbeulich@suse.com \
    --cc=paul@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.