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

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


  • To: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 12 Nov 2025 18:35:32 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=zs56Xkx4v/tlIQ5LvTJU1FgUW1cUPBdnAO4M5Byl1fc=; b=k5nP5Mr+MDq57G6QIk9eOsncT8gY9Dg32B9xW4ljCQLMvYsIUohrHQUGJZHK1oQIKVLvhn0X281MDOAFVLcUrApofxURIL2i4/E6RmUgNBJyBLYLSg7x+KZ2O2NvNCuVAwuB3LsMQQTz4E0MKDaRaLH+GPc1geISFSl+HKvPIXvVCvqZTkWv1JuE2pU0/wEn6RrfELpMebSvgQ5nd4Zv4rxiBe+GBC+6FXMwBrnZvVmqZJ/tcIwyoGqEdPMKFEN/BU1M4jNDaNxEc2lp2+xYIu+PNOatIlQwAQTn8uEuWMuenPNg39pYGQ/iVW18D0CXLHJlhn4q81yE2ZYBRJWq2w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qpGy9EVlfunHxvtSAg5FC5ETvRb0BNGuHCXm5T35q9tmabZsSeR/zjF6VBPkg4Fmb5/nNlv7s6O9FgL554K7JcaHge9IgKImS6Ad841/jRVDtZPgapMSL62buWxucEAeq/3ptT80W9RBAy0QMRQYTYifiSJyHuKx8kjq9PE+Kd59jgSIVRc6lI7rnHldNf3TK5ZDUKDSmrEFxIxaU2dc8wEIFngbDnB4iVyDBIes0e4UTvUn2/l7AwJ4L2Bfq6oEZ2cPgSvg//6KTOJNdh6n/G8MEBWwpxDjQU+PLChI1S/ywB9Et/gqaezEFp5pki00MRZ8TW8uDk9leT4DJJL48g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 12 Nov 2025 16:35:50 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 12.11.25 16:27, Alejandro Vallejo wrote:
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.

I'm planning to resend with below diff applied:

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index c09fb2ba6873..7299cfa90ad5 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4231,7 +4231,7 @@ static int hvm_set_param(struct domain *d, uint32_t 
index, uint64_t value)
             rc = -EINVAL;
         break;
     case HVM_PARAM_VIRIDIAN:
-        if ( !IS_ENABLED(CONFIG_VIRIDIAN) && value )
+        if ( !IS_ENABLED(CONFIG_VIRIDIAN) )
             rc = -ENODEV;
         else if ( (value & ~HVMPV_feature_mask) || !(value & HVMPV_base_freq) )
             rc = -EINVAL;
diff --git a/xen/arch/x86/hvm/viridian/viridian.c 
b/xen/arch/x86/hvm/viridian/viridian.c
index 5fb148b2aa15..90e749ceb581 100644
--- a/xen/arch/x86/hvm/viridian/viridian.c
+++ b/xen/arch/x86/hvm/viridian/viridian.c
@@ -1117,9 +1117,6 @@ static int cf_check viridian_load_domain_ctxt(
     struct viridian_domain *vd = d->arch.hvm.viridian;
     struct hvm_viridian_domain_context ctxt;
- if ( !IS_ENABLED(CONFIG_VIRIDIAN) )
-        return -EILSEQ;
-
     if ( hvm_load_entry_zeroextend(VIRIDIAN_DOMAIN, h, &ctxt) != 0 )
         return -EINVAL;
@@ -1156,9 +1153,6 @@ static int cf_check viridian_load_vcpu_ctxt(
     struct vcpu *v;
     struct hvm_viridian_vcpu_context ctxt;
- if ( !IS_ENABLED(CONFIG_VIRIDIAN) )
-        return -EILSEQ;
-
     if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
     {
         dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",


PS: Not sure I have enough stamina and enthusiasm to continue post v8 version.

--
Best regards,
-grygorii




 


Rackspace

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