From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>,
"Roger Pau Monné" <roger@xenproject.org>
Subject: [PATCH 03/13] x86/altp2m: don't blindly assume vCPU-s exist
Date: Thu, 26 Nov 2026 14:37:12 +0100 [thread overview]
Message-ID: <ffc99af3-01e9-478e-af05-a1fe7b45fd91@suse.com> (raw)
In-Reply-To: <1ea6d02b-8fba-4b1e-969c-033d6a7be233@suse.com>
Checking hypercall inputs against just d->max_vcpus doesn't suffice, as
the hypercall may be issued ahead of vCPU-s being created. Use
domain_vcpu() to also cover other eventualities.
Fixes: 3e828f882a6b ("x86/altp2m: Allow setting the #VE info page for an arbitrary VCPU")
Fixes: 9b97818c3d58 ("x86/altp2m: add altp2m_vcpu_disable_notify")
Reported-by: Roger Pau Monné <roger.pau@amd.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4697,10 +4697,9 @@ static int do_altp2m_op(
case HVMOP_altp2m_vcpu_enable_notify:
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, a.u.enable_notify.vcpu_id);
- if ( a.u.enable_notify.pad ||
- a.u.enable_notify.vcpu_id >= d->max_vcpus )
+ if ( a.u.enable_notify.pad || !v )
{
rc = -EINVAL;
break;
@@ -4712,17 +4711,15 @@ static int do_altp2m_op(
break;
}
- v = d->vcpu[a.u.enable_notify.vcpu_id];
-
rc = altp2m_vcpu_enable_ve(v, _gfn(a.u.enable_notify.gfn));
break;
}
case HVMOP_altp2m_vcpu_disable_notify:
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, a.u.enable_notify.vcpu_id);
- if ( a.u.disable_notify.vcpu_id >= d->max_vcpus )
+ if ( !v )
{
rc = -EINVAL;
break;
@@ -4734,8 +4731,6 @@ static int do_altp2m_op(
break;
}
- v = d->vcpu[a.u.enable_notify.vcpu_id];
-
altp2m_vcpu_disable_ve(v);
break;
}
next prev parent reply other threads:[~2026-11-26 13:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
2026-11-26 13:35 ` [PATCH 01/13] x86/gdbsx: don't blindly assume vCPU 0 exists Jan Beulich
2026-11-26 13:36 ` [PATCH 02/13] x86/passthrough: don't blindly assume vCPU-s exist Jan Beulich
2026-11-26 13:37 ` Jan Beulich [this message]
2026-12-02 6:38 ` [PATCH 03/13] x86/altp2m: " Stephen Cheng
2026-12-02 7:41 ` Jan Beulich
2026-11-26 13:37 ` [PATCH 04/13] domctl: use domain_vcpu() in XEN_DOMCTL_{g,s}etvcpucontext handling Jan Beulich
2026-11-26 13:38 ` [PATCH 05/13] vm-event: use domain_vcpu() in domctl handling Jan Beulich
2026-11-26 13:38 ` [PATCH 06/13] numa: use domain_vcpu() in domain_to_node() Jan Beulich
2026-11-26 13:39 ` [PATCH 07/13] x86/time: use domain_vcpu() in tsc_set_info() Jan Beulich
2026-11-26 13:39 ` [PATCH 08/13] x86/paging: use domain_vcpu() in paging_domctl() Jan Beulich
2026-11-26 13:40 ` [PATCH 09/13] x86/dm: use domain_vcpu() Jan Beulich
2026-11-26 13:41 ` [PATCH 10/13] x86/HVM/MTRR: " Jan Beulich
2026-11-26 13:41 ` [PATCH 11/13] x86/HVM: introduce hvm_load_vcpu_instance() Jan Beulich
2026-11-26 13:43 ` Jan Beulich
2026-11-26 13:42 ` [PATCH 12/13] x86/vPMU: use domain_vcpu() Jan Beulich
2026-11-26 13:42 ` [PATCH 13/13] x86/domctl: use domain_vcpu() to handle various sub-ops Jan Beulich
2026-12-02 6:32 ` [PATCH 00/13] make better use of domain_vcpu() Stephen Cheng
2026-12-02 7:34 ` 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=ffc99af3-01e9-478e-af05-a1fe7b45fd91@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger@xenproject.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.