From: "Roger Pau Monné" <roger@xenproject.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Teddy Astie <teddy.astie@vates.tech>,
Anthony PERARD <anthony.perard@vates.tech>,
Michal Orzel <michal.orzel@amd.com>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2] xen/vcpu: ensure no write when runstate handler is NULL
Date: Mon, 26 Oct 2026 14:58:24 +0100 [thread overview]
Message-ID: <at9cgI2cIaS6nMAp@Mac.lan> (raw)
In-Reply-To: <47d6f426-6751-4a32-a187-2fb8a5347091@suse.com>
On Mon, Oct 26, 2026 at 02:06:48PM +0100, Jan Beulich wrote:
> On 23.10.2026 18:17, Roger Pau Monne wrote:
> > --- a/xen/arch/x86/x86_64/domain.c
> > +++ b/xen/arch/x86/x86_64/domain.c
> > @@ -58,6 +58,11 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
> > rc = 0;
> > guest_from_compat_handle(v->runstate_guest.compat, area.addr.h);
> >
> > + /* NULL handle is deregistering the address. */
> > + if ( compat_handle_is_null(area.addr.h) )
> > + break;
> > +
> > + /* Update the newly-registered runstate area, best-effort. */
> > if ( v == current )
> > {
> > XLAT_vcpu_runstate_info(&info, &v->runstate);
>
> While likely unnecessary in this x86-only handling, ...
>
> > --- a/xen/common/domain.c
> > +++ b/xen/common/domain.c
> > @@ -2330,6 +2330,11 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
> > rc = 0;
> > runstate_guest(v) = area.addr.h;
> >
> > + /* NULL handle is deregistering the address. */
> > + if ( guest_handle_is_null(area.addr.h) )
> > + break;
> > +
> > + /* Update the newly-registered runstate area, best-effort. */
> > if ( v == current )
> > {
> > __copy_to_guest(runstate_guest(v), &v->runstate, 1);
>
> ... if we make null an official "de-register", then imo the earlier
> guest_handle_okay() also wants bypassing in the null case. An arch
> could - in principle - reject a null handle.
Yes, it could en theory be possible, albeit I think it's very unlikely
we gain anything similar to x86 PV elsewhere. Would you be OK with:
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 6b52713518da..b41be89cd0b9 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2324,12 +2324,21 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
if ( copy_from_guest(&area, arg, 1) )
break;
+ /* NULL handle is deregistering the address. */
+ if ( guest_handle_is_null(area.addr.h) )
+ {
+ runstate_guest(v) = area.addr.h;
+ rc = 0;
+ break;
+ }
+
if ( !guest_handle_okay(area.addr.h, 1) )
break;
rc = 0;
runstate_guest(v) = area.addr.h;
+ /* Update the newly-registered runstate area, best-effort. */
if ( v == current )
{
__copy_to_guest(runstate_guest(v), &v->runstate, 1);
Thanks, Roger.
next prev parent reply other threads:[~2026-10-26 13:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 16:17 [PATCH v2] xen/vcpu: ensure no write when runstate handler is NULL Roger Pau Monne
2026-10-23 17:28 ` Andrew Cooper
2026-10-26 13:06 ` Jan Beulich
2026-10-26 13:58 ` Roger Pau Monné [this message]
2026-10-26 14:05 ` Jan Beulich
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=at9cgI2cIaS6nMAp@Mac.lan \
--to=roger@xenproject.org \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=teddy.astie@vates.tech \
--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.