From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Grygorii Strashko <grygorii_strashko@epam.com>,
Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Sergiy Kibrik <Sergiy_Kibrik@epam.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Paul Durrant <paul@xen.org>,
Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Subject: Re: [PATCH v5] x86: make Viridian support optional
Date: Wed, 15 Oct 2025 10:00:01 +0200 [thread overview]
Message-ID: <aO9UgQ3J27hVgGIa@Mac.lan> (raw)
In-Reply-To: <afe544d3-575c-44e8-9068-8c79f69d6175@epam.com>
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@epam.com>
> > > > > +
> > > > > + 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)
> > > - 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.
> Sure. Just have to ask for clarification what to return:
> -EOPNOTSUPP (my choise) vs -EINVAL.
Let me add Jan also to the To: field so we get consensus in one round.
I won't use EINVAL, because that's returned for deprecated parameters
also, and when the passed Viridian feature mask is invalid.
EOPNOTSUPP is also returned for non-implemented hypercalls, so I'm not
sure whether it could cause confusion here, as the hypercall is
implemented, it's just the param that's not supported if
build-disabled. Maybe ENODEV or ENXIO?
Thanks, Roger.
next prev parent reply other threads:[~2025-10-15 8:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-30 12:52 [PATCH v5] x86: make Viridian support optional Grygorii Strashko
2025-10-08 16:04 ` Jan Beulich
2025-10-09 16:33 ` Grygorii Strashko
2025-10-10 5:22 ` Jan Beulich
2025-10-13 10:01 ` Alejandro Vallejo
2025-10-13 11:06 ` Jan Beulich
2025-10-15 5:58 ` Demi Marie Obenour
2025-10-17 15:52 ` Alejandro Vallejo
2025-10-19 1:21 ` Demi Marie Obenour
2025-10-20 8:44 ` Roger Pau Monné
2025-10-20 9:57 ` Marek Marczykowski-Górecki
2025-10-13 12:17 ` Roger Pau Monné
2025-10-14 13:24 ` Grygorii Strashko
2025-10-14 14:38 ` Roger Pau Monné
2025-10-14 15:48 ` Grygorii Strashko
2025-10-15 8:00 ` Roger Pau Monné [this message]
2025-10-15 8:03 ` Jan Beulich
2025-10-16 21:40 ` Grygorii Strashko
2025-10-16 22:38 ` Marek Marczykowski-Górecki
2025-10-17 6:01 ` Jan Beulich
2025-10-17 6:51 ` Marek Marczykowski-Górecki
2025-10-17 7:38 ` Roger Pau Monné
2025-10-21 11:04 ` 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=aO9UgQ3J27hVgGIa@Mac.lan \
--to=roger.pau@citrix.com \
--cc=Sergiy_Kibrik@epam.com \
--cc=alejandro.garciavallejo@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=grygorii_strashko@epam.com \
--cc=jbeulich@suse.com \
--cc=paul@xen.org \
--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.