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

Re: [PATCH v5] x86: make Viridian support optional


  • To: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 17 Oct 2025 09:38:31 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=whW7G34Y5RFo8eebljx+NifytIjRAh5GJs46kktfN5I=; b=elUxEO3Bn728swSOfdNwt8bGq7S7nrV88kOr9RS/iGxJjRE3jb7qh94nuVuPtIg6IqSrYDg4DBMkf9LLDDr6SQmThojjxMAgzRMQnMptdC6q9h9rNbW3I40p25SOyLnomxB5iHRlVMbj4cxFqLCzYEk02IW1/KP4ZKT1K93fYi75JGz/Fef1CHkDy2e2KuKW6iwpFOVKe0WL/s9Dty23NvCgHU3ByzrAl8A3mAyjg8oOuWS1/rqYBwrxxetLON/qQZNkPMQ8mHJnZ4Eal6pAhvVYjfvBFKapio3UkQktvZuzkJQ895U2Ki3CsZ/71s0pXOf9psyaqcCu5XLelt5J0Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XosFa8+jhCzsQuNnybZHomVCAKGrSEDXVYLQ23sMVt1Ze46iNewYJqYe7pQLH+1WF9+iCFaaFnLI/UwKaQqcVxr4DtAiwzt9OUZ3N5gvUR38qIo3EIQ5hpxAhBrO4XYmAFCxDu+MFmLs+wNpBlHUXxH1qkJv0xwQSHbY0zhGoowBDDCofHa3FcGe6G2Kl7Sodcw0bfj35wWzd61ycdCtpp9bGnev+mhmdDkxTFdDgBUUIKNyY6lLi5miNYX4ToNv9asitGfDdlIKWGAhwr8S2zkRwuP6nLrCUcs9q7VnUPhOJX/KeOWeBtjtwa878aCIGtLmvnf96fdR1YKrrS+tJw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Sergiy Kibrik <Sergiy_Kibrik@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Delivery-date: Fri, 17 Oct 2025 07:38:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Oct 17, 2025 at 12:40:33AM +0300, Grygorii Strashko wrote:
> 
> 
> On 15.10.25 11:00, Roger Pau Monné wrote:
> > On Tue, Oct 14, 2025 at 06:48:23PM +0300, Grygorii Strashko wrote:
> > > 
> > > 
> > > On 14.10.25 17:38, Roger Pau Monné wrote:
> > > > On Tue, Oct 14, 2025 at 04:24:53PM +0300, Grygorii Strashko wrote:
> > > > > On 13.10.25 15:17, Roger Pau Monné wrote:
> > > > > > On Tue, Sep 30, 2025 at 12:52:16PM +0000, Grygorii Strashko wrote:
> > > > > > > From: Sergiy Kibrik <Sergiy_Kibrik@xxxxxxxx>
> > > > > > > +
> > > > > > > +   If unsure, say Y.
> > > > > > > +
> > > > > > >     config MEM_PAGING
> > > > > > >           bool "Xen memory paging support (UNSUPPORTED)" if 
> > > > > > > UNSUPPORTED
> > > > > > >           depends on VM_EVENT
> > > > > > > diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile
> > > > > > > index 6ec2c8f2db56..736eb3f966e9 100644
> > > > > > > --- a/xen/arch/x86/hvm/Makefile
> > > > > > > +++ b/xen/arch/x86/hvm/Makefile
> > > > > > > @@ -1,6 +1,6 @@
> > > > > > >     obj-$(CONFIG_AMD_SVM) += svm/
> > > > > > >     obj-$(CONFIG_INTEL_VMX) += vmx/
> > > > > > > -obj-y += viridian/
> > > > > > > +obj-$(CONFIG_VIRIDIAN) += viridian/
> > > > > > >     obj-y += asid.o
> > > > > > >     obj-y += dm.o
> > > > > > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> > > > > > > index 23bd7f078a1d..95a80369b9b8 100644
> > > > > > > --- a/xen/arch/x86/hvm/hvm.c
> > > > > > > +++ b/xen/arch/x86/hvm/hvm.c
> > > > > > > @@ -701,9 +701,12 @@ int hvm_domain_initialise(struct domain *d,
> > > > > > >         if ( hvm_tsc_scaling_supported )
> > > > > > >             d->arch.hvm.tsc_scaling_ratio = 
> > > > > > > hvm_default_tsc_scaling_ratio;
> > > > > > > -    rc = viridian_domain_init(d);
> > > > > > > -    if ( rc )
> > > > > > > -        goto fail2;
> > > > > > > +    if ( is_viridian_domain(d) )
> > > > > > > +    {
> > > > > > > +        rc = viridian_domain_init(d);
> > > > > > > +        if ( rc )
> > > > > > > +            goto fail2;
> > > > > > > +    }
> > > > > > 
> > > > > > Are you sure this works as expected?
> > > > > > 
> > > > > > The viridian_feature_mask() check is implemented using an HVM param,
> > > > > > and hence can only be possibly set after the domain object is 
> > > > > > created.
> > > > > > AFAICT is_viridian_domain(d) will unconditionally return false when
> > > > > > called from domain_create() context, because the HVM params cannot
> > > > > > possibly be set ahead of the domain being created.
> > > > > 
> > > > > You are right. Thanks for the this catch.
> > > > > 
> > > > > Taking above into account above, it seems Jan's proposal to convert 
> > > > > below
> > > > > viridian APIs into wrappers for VIRIDIAN=n case is right way to move 
> > > > > forward:
> > > > > 
> > > > > int viridian_vcpu_init(struct vcpu *v);
> > > > > int viridian_domain_init(struct domain *d);
> > > > > void viridian_vcpu_deinit(struct vcpu *v);
> > > > > void viridian_domain_deinit(struct domain *d);
> > > > > 
> > > > > Right?
> > > > 
> > > > Possibly. If you don't want to introduce a XEN_DOMCTL_createdomain
> > > > flag you need to exclusively use the Kconfig option to decide whether
> > > > the Viridian related structs must be allocated.  IOW: you could also
> > > > solve it by using IS_ENABLED(CONFIG_VIRIDIAN) instead of
> > > > is_viridian_domain() for most of the calls here.
> > > > 
> > > > The wrapper option might be better IMO, rather than adding
> > > > IS_ENABLED(CONFIG_VIRIDIAN) around.
> > > 
> > > I'll do wrappers - less if(s) in common HVM code.
> > > 
> > > > 
> > > > > [1] https://patchwork.kernel.org/comment/26595213/
> > > > > 
> > > > > > 
> > > > > > If you want to do anything like this you will possibly need to
> > > > > > introduce a new flag to XEN_DOMCTL_createdomain to signal whether 
> > > > > > the
> > > > > > domain has Viridian extensions are enabled or not, so that it's know
> > > > > > in the context where domain_create() gets called.
> > > > > 
> > > > > In my opinion, it might be good not to go so far within this 
> > > > > submission.
> > > > > - It's not intended  to change existing behavior of neither Xen nor 
> > > > > toolstack
> > > > >     for VIRIDIAN=y (default)
> 
> [1]
> 
> > > > > - just optout Viridian support when not needed.
> > > > 
> > > > OK, that's fine.
> > > > 
> > > > On further request though: if Viridian is build-time disabled in
> > > > Kconfig, setting or fetching HVM_PARAM_VIRIDIAN should return -ENODEV
> > > > or similar error.  I don't think this is done as part of this patch.
> > 
> > Another bit I've noticed, you will need to adjust write_hvm_params()
> > so it can tolerate xc_hvm_param_get() returning an error when
> > HVM_PARAM_VIRIDIAN is not implemented by the hypervisor.
> > 
> > Implementing the Viridian features using an HVM parameter was a bad
> > approach probably.
> 
> I've just realized how toolstack need to be modified and all consequences...
> Have to try to push back a little bit:
> 
> VIRIDIAN=n: Now HVM_PARAM_VIRIDIAN will be R/W with functionality NOP.
> 
> I'd prefer avoid modifying toolstack if possible.
> 
> How about sanitizing HVM_PARAM_VIRIDIAN to be RAZ/WI for VIRIDIAN=n?

I've been thinking more into it, and we must still allow writes/reads
to it, otherwise migration would fail when restoring a stream that
contains a Viridian record, even if Viridian is not enabled for the
domain.  Right now the HVM param is unconditionally part of the
migration stream, even when Viridian is not enabled.

I think Xen could return an error when VIRIDIAN = n and a non-zero
value is passed to HVM_PARAM_VIRIDIAN?

That shouldn't require any changes to the toolstack, as when Viridian
is not enabled the toolstack will just set HVM_PARAM_VIRIDIAN = 0.  It
would however still fail if toolstack attempts HVM_PARAM_VIRIDIAN != 0
and Viridian has been build time disabled.

Thanks, Roger.



 


Rackspace

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