* [PATCH 00/13] make better use of domain_vcpu()
@ 2026-11-26 12:48 Jan Beulich
2026-11-26 13:35 ` [PATCH 01/13] x86/gdbsx: don't blindly assume vCPU 0 exists Jan Beulich
` (13 more replies)
0 siblings, 14 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 12:48 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
I.e. reduce the number of instances where we access d->vcpu[] directly.
The series doesn't cover all cases, just a fair part. I think there are
no inter-dependencies between the individual patches.
01: x86/gdbsx: don't blindly assume vCPU 0 exists
02: x86/passthrough: don't blindly assume vCPU-s exist
03: x86/altp2m: don't blindly assume vCPU-s exist
04: domctl: use domain_vcpu() in XEN_DOMCTL_{g,s}etvcpucontext handling
05: vm-event: use domain_vcpu() in domctl handling
06: numa: use domain_vcpu() in domain_to_node()
07: x86/time: use domain_vcpu() in tsc_set_info()
08: x86/paging: use domain_vcpu() in paging_domctl()
09: x86/dm: use domain_vcpu()
10: x86/HVM/MTRR: use domain_vcpu()
11: x86/HVM: introduce hvm_load_vcpu_instance()
12: x86/vPMU: use domain_vcpu()
13: x86/domctl: use domain_vcpu() to handle various sub-ops
Jan
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 01/13] x86/gdbsx: don't blindly assume vCPU 0 exists
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
@ 2026-11-26 13:35 ` Jan Beulich
2026-11-26 13:36 ` [PATCH 02/13] x86/passthrough: don't blindly assume vCPU-s exist Jan Beulich
` (12 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:35 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné, Elena Ufimtseva
For the PV case, pass domain_vcpu()'s result into the low-level function,
and refuse the lookup there when pgd3val wasn't provided and the vCPU
doesn't exist. Additionally also check whether CR3 was ever set.
For the HVM case, simply use domain_vcpu() in the low-level helper and
bail if the result is NULL.
Fixes: 61f2a440299c ("gdbsx: a gdbserver stub for xen")
Reported-by: Roger Pau Monné <roger.pau@amd.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/gdbsx.c
+++ b/xen/arch/x86/gdbsx.c
@@ -30,11 +30,15 @@ typedef unsigned char dbgbyte_t;
static mfn_t
dbg_hvm_va2mfn(dbgva_t vaddr, struct domain *dp, int toaddr, gfn_t *gfn)
{
+ struct vcpu *v = domain_vcpu(dp, 0);
mfn_t mfn;
uint32_t pfec = PFEC_page_present;
p2m_type_t gfntype;
- *gfn = _gfn(paging_gva_to_gfn(dp->vcpu[0], vaddr, &pfec));
+ if ( !v )
+ return INVALID_MFN;
+
+ *gfn = _gfn(paging_gva_to_gfn(v, vaddr, &pfec));
if ( gfn_eq(*gfn, INVALID_GFN) )
return INVALID_MFN;
@@ -65,17 +69,21 @@ dbg_hvm_va2mfn(dbgva_t vaddr, struct dom
* Returns: mfn for the given (pv guest) vaddr
*/
static mfn_t
-dbg_pv_va2mfn(dbgva_t vaddr, struct domain *dp, uint64_t pgd3val)
+dbg_pv_va2mfn(dbgva_t vaddr, const struct vcpu *v, uint64_t pgd3val)
{
l4_pgentry_t l4e, *l4t;
l3_pgentry_t l3e, *l3t;
l2_pgentry_t l2e, *l2t;
l1_pgentry_t l1e, *l1t;
- unsigned long cr3 = (pgd3val ? pgd3val : dp->vcpu[0]->arch.cr3);
- mfn_t mfn = maddr_to_mfn(cr3_pa(cr3));
+ mfn_t mfn;
if ( pgd3val == 0 )
{
+ if ( !v || !v->arch.cr3 )
+ return INVALID_MFN;
+
+ mfn = maddr_to_mfn(cr3_pa(v->arch.cr3));
+
l4t = map_domain_page(mfn);
l4e = l4t[l4_table_offset(vaddr)];
unmap_domain_page(l4t);
@@ -91,6 +99,8 @@ dbg_pv_va2mfn(dbgva_t vaddr, struct doma
(l3e_get_flags(l3e) & _PAGE_PSE) )
return INVALID_MFN;
}
+ else
+ mfn = maddr_to_mfn(cr3_pa(pgd3val));
l2t = map_domain_page(mfn);
l2e = l2t[l2_table_offset(vaddr)];
@@ -125,7 +135,7 @@ static unsigned int dbg_rw_guest_mem(str
mfn = (is_hvm_domain(dp)
? dbg_hvm_va2mfn(addr, dp, toaddr, &gfn)
- : dbg_pv_va2mfn(addr, dp, pgd3));
+ : dbg_pv_va2mfn(addr, domain_vcpu(dp, 0), pgd3));
if ( mfn_eq(mfn, INVALID_MFN) )
break;
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 02/13] x86/passthrough: don't blindly assume vCPU-s exist
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 ` Jan Beulich
2026-11-26 13:37 ` [PATCH 03/13] x86/altp2m: " Jan Beulich
` (11 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:36 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Teddy Astie
First, pirq_guest_bind() really only needs a vCPU to establish IRQ
affinity, and it already has fallback logic which can be used if the vCPU
passed in is NULL. Have the caller pass in a (guaranteed non-NULL) domain
pointer, making the vCPU one optional.
Reported-by: Roger Pau Monné <roger.pau@amd.com>
While altering pirq_guest_bind()'s signature also convert its boolean
parameter to bool.
Further, while generally hvm_girq_dest_2_vcpu_id() would return only IDs
of valid vCPU-s, for a single-vCPU guest it would return 0 no matter
whether that vCPU was created already. Use domain_vcpu() when consuming
the return value; subsequent code already deals with the pointer being
NULL.
Fixes: fbe487b996b5 ("PCI passthru: VT-d I/O hooks")
Fixes: 85715f4bc7c9 ("MSI 5/6: add MSI support to passthrough HVM domain")
Fixes: ("")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I'll fill the missing Fixes: when xenbits is willing to work again.
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -1627,14 +1627,15 @@ int pirq_shared(struct domain *d, int pi
return shared;
}
-int pirq_guest_bind(struct vcpu *v, struct pirq *pirq, int will_share)
+int pirq_guest_bind(struct domain *d, const struct vcpu *v, struct pirq *pirq,
+ bool will_share)
{
struct irq_desc *desc;
irq_guest_action_t *action, *newaction = NULL;
unsigned int max_nr_guests = will_share ? irq_max_guests : 1;
int rc = 0;
- WARN_ON(!rw_is_write_locked(&v->domain->event_lock));
+ WARN_ON(!rw_is_write_locked(&d->event_lock));
BUG_ON(!local_irq_is_enabled());
retry:
@@ -1651,7 +1652,7 @@ int pirq_guest_bind(struct vcpu *v, stru
{
printk(XENLOG_G_INFO
"Cannot bind IRQ%d to dom%d. In use by '%s'.\n",
- pirq->pirq, v->domain->domain_id, desc->action->name);
+ pirq->pirq, d->domain_id, desc->action->name);
rc = -EBUSY;
goto unlock_out;
}
@@ -1666,7 +1667,7 @@ int pirq_guest_bind(struct vcpu *v, stru
xfree(newaction);
printk(XENLOG_G_INFO
"Cannot bind IRQ%d to dom%d. Out of memory.\n",
- pirq->pirq, v->domain->domain_id);
+ pirq->pirq, d->domain_id);
return -ENOMEM;
}
@@ -1690,7 +1691,7 @@ int pirq_guest_bind(struct vcpu *v, stru
{
const cpumask_t *affinity = NULL;
- if ( !opt_noirqbalance )
+ if ( !opt_noirqbalance && v )
affinity = cpumask_of(v->processor);
else if ( !cpumask_intersects(desc->affinity, &cpu_online_map) )
{
@@ -1710,7 +1711,7 @@ int pirq_guest_bind(struct vcpu *v, stru
else if ( !will_share || !action->shareable )
{
printk(XENLOG_G_INFO "Cannot bind IRQ%d to dom%d. %s.\n",
- pirq->pirq, v->domain->domain_id,
+ pirq->pirq, d->domain_id,
will_share ? "Others do not share"
: "Will not share with others");
rc = -EBUSY;
@@ -1734,17 +1735,17 @@ int pirq_guest_bind(struct vcpu *v, stru
printk(XENLOG_G_INFO
"Cannot bind IRQ%d to %pd: already at max share %u"
" (increase with irq-max-guests= option)\n",
- pirq->pirq, v->domain, irq_max_guests);
+ pirq->pirq, d, irq_max_guests);
rc = -EBUSY;
goto unlock_out;
}
- action->guest[action->nr_guests++] = v->domain;
+ action->guest[action->nr_guests++] = d;
if ( action->ack_type != ACKTYPE_NONE )
- set_pirq_eoi(v->domain, pirq->pirq);
+ set_pirq_eoi(d, pirq->pirq);
else
- clear_pirq_eoi(v->domain, pirq->pirq);
+ clear_pirq_eoi(d, pirq->pirq);
unlock_out:
spin_unlock_irq(&desc->lock);
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -718,7 +718,7 @@ static int evtchn_bind_pirq(evtchn_bind_
info->evtchn = port;
rc = (!is_hvm_domain(d)
- ? pirq_guest_bind(v, info,
+ ? pirq_guest_bind(d, v, info,
!!(bind->flags & BIND_PIRQ__WILL_SHARE))
: 0);
if ( rc != 0 )
--- a/xen/drivers/passthrough/x86/hvm.c
+++ b/xen/drivers/passthrough/x86/hvm.c
@@ -315,7 +315,7 @@ int pt_irq_create_bind(
*/
pirq_dpci->dom = d;
/* bind after hvm_irq_dpci is setup to avoid race with irq handler*/
- rc = pirq_guest_bind(d->vcpu[0], info, 0);
+ rc = pirq_guest_bind(d, d->vcpu[0], info, 0);
if ( rc == 0 && pt_irq_bind->u.msi.gtable )
{
rc = msixtbl_pt_register(d, info, pt_irq_bind->u.msi.gtable);
@@ -375,7 +375,7 @@ int pt_irq_create_bind(
pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id;
pirq_dpci->gmsi.posted = false;
- vcpu = (dest_vcpu_id >= 0) ? d->vcpu[dest_vcpu_id] : NULL;
+ vcpu = (dest_vcpu_id >= 0) ? domain_vcpu(d, dest_vcpu_id) : NULL;
if ( iommu_intpost )
{
if ( delivery_mode == dest_LowestPrio )
@@ -527,7 +527,7 @@ int pt_irq_create_bind(
}
/* Deal with gsi for legacy devices */
- rc = pirq_guest_bind(d->vcpu[0], info, share);
+ rc = pirq_guest_bind(d, d->vcpu[0], info, share);
if ( unlikely(rc) )
{
/*
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -184,7 +184,8 @@ void pirq_cleanup_check(struct pirq *pir
extern void pirq_guest_eoi(struct pirq *pirq);
extern void desc_guest_eoi(struct irq_desc *desc, struct pirq *pirq);
extern int pirq_guest_unmask(struct domain *d);
-extern int pirq_guest_bind(struct vcpu *v, struct pirq *pirq, int will_share);
+extern int pirq_guest_bind(struct domain *d, const struct vcpu *v,
+ struct pirq *pirq, bool will_share);
extern void pirq_guest_unbind(struct domain *d, struct pirq *pirq);
extern void pirq_set_affinity(struct domain *d, int pirq,
const cpumask_t *mask);
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 03/13] x86/altp2m: don't blindly assume vCPU-s exist
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
2026-12-02 6:38 ` Stephen Cheng
2026-11-26 13:37 ` [PATCH 04/13] domctl: use domain_vcpu() in XEN_DOMCTL_{g,s}etvcpucontext handling Jan Beulich
` (10 subsequent siblings)
13 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:37 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
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;
}
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 04/13] domctl: use domain_vcpu() in XEN_DOMCTL_{g,s}etvcpucontext handling
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (2 preceding siblings ...)
2026-11-26 13:37 ` [PATCH 03/13] x86/altp2m: " Jan Beulich
@ 2026-11-26 13:37 ` Jan Beulich
2026-11-26 13:38 ` [PATCH 05/13] vm-event: use domain_vcpu() in domctl handling Jan Beulich
` (9 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:37 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -606,12 +606,10 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
case XEN_DOMCTL_setvcpucontext:
{
vcpu_guest_context_u c = { .nat = NULL };
- unsigned int vcpu = op->u.vcpucontext.vcpu;
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, op->u.vcpucontext.vcpu);
ret = -EINVAL;
- if ( (d == current->domain) || /* no domain_pause() */
- (vcpu >= d->max_vcpus) || ((v = d->vcpu[vcpu]) == NULL) )
+ if ( !v || d == current->domain ) /* no domain_pause() */
break;
if ( guest_handle_is_null(op->u.vcpucontext.ctxt) )
@@ -792,12 +790,10 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
case XEN_DOMCTL_getvcpucontext:
{
vcpu_guest_context_u c = { .nat = NULL };
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, op->u.vcpucontext.vcpu);
ret = -EINVAL;
- if ( op->u.vcpucontext.vcpu >= d->max_vcpus ||
- (v = d->vcpu[op->u.vcpucontext.vcpu]) == NULL ||
- v == current ) /* no vcpu_pause() */
+ if ( !v || v == current ) /* no vcpu_pause() */
goto getvcpucontext_out;
ret = -ENODATA;
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 05/13] vm-event: use domain_vcpu() in domctl handling
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (3 preceding siblings ...)
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 ` Jan Beulich
2026-11-26 13:38 ` [PATCH 06/13] numa: use domain_vcpu() in domain_to_node() Jan Beulich
` (8 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:38 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org; +Cc: Tamas K Lengyel
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -622,7 +622,7 @@ int vm_event_domctl(struct domain *d, st
return 0;
}
- if ( unlikely(d->vcpu == NULL) || unlikely(d->vcpu[0] == NULL) )
+ if ( unlikely(!domain_vcpu(d, 0)) )
{
gdprintk(XENLOG_INFO,
"Memory event op on a domain (%u) with no vcpus\n",
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 06/13] numa: use domain_vcpu() in domain_to_node()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (4 preceding siblings ...)
2026-11-26 13:38 ` [PATCH 05/13] vm-event: use domain_vcpu() in domctl handling Jan Beulich
@ 2026-11-26 13:38 ` Jan Beulich
2026-11-26 13:39 ` [PATCH 07/13] x86/time: use domain_vcpu() in tsc_set_info() Jan Beulich
` (7 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:38 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -23,9 +23,10 @@ typedef uint8_t nodeid_t;
#define vcpu_to_node(v) (cpu_to_node((v)->processor))
-#define domain_to_node(d) \
- (((d)->vcpu != NULL && (d)->vcpu[0] != NULL) \
- ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE)
+#define domain_to_node(d) ({ \
+ const struct vcpu *v_ = domain_vcpu(d, 0); \
+ v_ ? vcpu_to_node(v_) : NUMA_NO_NODE; \
+})
/* The following content can be used when NUMA feature is enabled */
#ifdef CONFIG_NUMA
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 07/13] x86/time: use domain_vcpu() in tsc_set_info()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (5 preceding siblings ...)
2026-11-26 13:38 ` [PATCH 06/13] numa: use domain_vcpu() in domain_to_node() Jan Beulich
@ 2026-11-26 13:39 ` Jan Beulich
2026-11-26 13:39 ` [PATCH 08/13] x86/paging: use domain_vcpu() in paging_domctl() Jan Beulich
` (6 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:39 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -3076,12 +3076,16 @@ int tsc_set_info(struct domain *d,
d->arch.incarnation = incarnation + 1;
if ( is_hvm_domain(d) )
{
+ struct vcpu *v;
+
if ( hvm_tsc_scaling_supported && !d->arch.vtsc )
d->arch.hvm.tsc_scaling_ratio =
hvm_get_tsc_scaling_ratio(d->arch.tsc_khz);
hvm_set_rdtsc_exiting(d, d->arch.vtsc);
- if ( d->vcpu && d->vcpu[0] && incarnation == 0 )
+
+ v = domain_vcpu(d, 0);
+ if ( v && !incarnation )
{
/*
* set_tsc_offset() is called from hvm_vcpu_initialise() before
@@ -3092,8 +3096,7 @@ int tsc_set_info(struct domain *d,
* will sync their TSC to BSP's sync_tsc.
*/
d->arch.hvm.sync_tsc = rdtsc();
- hvm_set_tsc_offset(d->vcpu[0],
- d->vcpu[0]->arch.hvm.cache_tsc_offset);
+ hvm_set_tsc_offset(v, v->arch.hvm.cache_tsc_offset);
}
}
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 08/13] x86/paging: use domain_vcpu() in paging_domctl()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (6 preceding siblings ...)
2026-11-26 13:39 ` [PATCH 07/13] x86/time: use domain_vcpu() in tsc_set_info() Jan Beulich
@ 2026-11-26 13:39 ` Jan Beulich
2026-11-26 13:40 ` [PATCH 09/13] x86/dm: use domain_vcpu() Jan Beulich
` (5 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:39 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -668,7 +668,7 @@ int paging_domctl(struct domain *d, stru
return -EINVAL;
}
- if ( unlikely(d->vcpu == NULL) || unlikely(d->vcpu[0] == NULL) )
+ if ( unlikely(!domain_vcpu(d, 0)) )
{
gdprintk(XENLOG_DEBUG, "Paging op on a domain (%u) with no vcpus\n",
d->domain_id);
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 09/13] x86/dm: use domain_vcpu()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (7 preceding siblings ...)
2026-11-26 13:39 ` [PATCH 08/13] x86/paging: use domain_vcpu() in paging_domctl() Jan Beulich
@ 2026-11-26 13:40 ` Jan Beulich
2026-11-26 13:41 ` [PATCH 10/13] x86/HVM/MTRR: " Jan Beulich
` (4 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:40 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -54,7 +54,7 @@ static int track_dirty_vram(struct domai
if ( d->is_dying )
return -ESRCH;
- if ( !d->max_vcpus || !d->vcpu[0] )
+ if ( !domain_vcpu(d, 0) )
return -EINVAL;
if ( DIV_ROUND_UP(nr_frames, BITS_PER_BYTE) > buf->size )
@@ -302,9 +302,9 @@ static int set_mem_type(struct domain *d
static int inject_event(struct domain *d,
const struct xen_dm_op_inject_event *data)
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, data->vcpuid);
- if ( data->vcpuid >= d->max_vcpus || !(v = d->vcpu[data->vcpuid]) )
+ if ( !v )
return -EINVAL;
if ( cmpxchg(&v->arch.hvm.inject_event.vector,
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 10/13] x86/HVM/MTRR: use domain_vcpu()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (8 preceding siblings ...)
2026-11-26 13:40 ` [PATCH 09/13] x86/dm: use domain_vcpu() Jan Beulich
@ 2026-11-26 13:41 ` Jan Beulich
2026-11-26 13:41 ` [PATCH 11/13] x86/HVM: introduce hvm_load_vcpu_instance() Jan Beulich
` (3 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:41 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -689,7 +689,7 @@ int hvm_set_mem_pinned_cacheattr(struct
finish:
if ( flush )
memory_type_changed(d);
- else if ( d->vcpu && d->vcpu[0] )
+ else if ( domain_vcpu(d, 0) )
p2m_memory_type_changed(d);
return rc;
@@ -735,13 +735,12 @@ static int cf_check hvm_save_mtrr_msr(st
static int cf_check hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
{
- unsigned int vcpuid, i;
- struct vcpu *v;
+ unsigned int vcpuid = hvm_load_instance(h), i;
+ struct vcpu *v = domain_vcpu(d, vcpuid);
struct mtrr_state *m;
struct hvm_hw_mtrr hw_mtrr;
- vcpuid = hvm_load_instance(h);
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
d->domain_id, vcpuid);
@@ -788,8 +787,8 @@ HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save
void memory_type_changed(struct domain *d)
{
- if ( cache_flush_permitted(d) &&
- d->vcpu && d->vcpu[0] && p2m_memory_type_changed(d) &&
+ if ( cache_flush_permitted(d) && domain_vcpu(d, 0) &&
+ p2m_memory_type_changed(d) &&
/*
* Do the p2m type-change, but skip the cache flush if the domain is
* not yet running. The check for creation_finished must strictly be
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 11/13] x86/HVM: introduce hvm_load_vcpu_instance()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (9 preceding siblings ...)
2026-11-26 13:41 ` [PATCH 10/13] x86/HVM/MTRR: " Jan Beulich
@ 2026-11-26 13:41 ` Jan Beulich
2026-11-26 13:43 ` Jan Beulich
2026-11-26 13:42 ` [PATCH 12/13] x86/vPMU: use domain_vcpu() Jan Beulich
` (2 subsequent siblings)
13 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:41 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
Use this to remove open-coding of domain_vcpu().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
lapic_load_{hidden,regs}() are left alone, as I fear analysis tools would
otherwise pick on the missing NULL checks.
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -364,15 +364,14 @@ static int cf_check vmce_save_vcpu_ctxt(
static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
{
- unsigned int vcpuid = hvm_load_instance(h);
- struct vcpu *v;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
struct hvm_vmce_vcpu ctxt;
int err;
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
err = -EINVAL;
}
else
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -804,14 +804,13 @@ static int cf_check hvm_save_tsc_adjust(
static int cf_check hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h)
{
- unsigned int vcpuid = hvm_load_instance(h);
- struct vcpu *v;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
struct hvm_tsc_adjust ctxt;
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
@@ -1018,18 +1017,16 @@ unsigned long hvm_cr4_guest_valid_bits(c
static int cf_check hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
{
const struct cpu_policy *p = d->arch.cpu_policy;
- unsigned int vcpuid = hvm_load_instance(h);
- struct vcpu *v;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
struct hvm_hw_cpu ctxt;
struct segment_register seg;
const char *errstr;
unsigned long valid;
- /* Which vcpu is this? */
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%u has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
@@ -1267,19 +1264,17 @@ CHECK_FIELD_(struct, xsave_hdr, reserved
static int cf_check hvm_load_cpu_xsave_states(
struct domain *d, hvm_domain_context_t *h)
{
- unsigned int vcpuid, size;
+ unsigned int size;
int err;
- struct vcpu *v;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
struct hvm_hw_cpu_xsave *ctxt;
const struct hvm_save_descriptor *desc;
unsigned int i, desc_start, desc_length;
- /* Which vcpu is this? */
- vcpuid = hvm_load_instance(h);
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
@@ -1298,14 +1293,14 @@ static int cf_check hvm_load_cpu_xsave_s
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore: not enough data left to read xsave descriptor\n",
- d->domain_id, vcpuid);
+ d->domain_id, v->vcpu_id);
return -ENODATA;
}
if ( desc->length + sizeof (*desc) > h->size - h->cur)
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore: not enough data left to read %u xsave bytes\n",
- d->domain_id, vcpuid, desc->length);
+ d->domain_id, v->vcpu_id, desc->length);
return -ENODATA;
}
if ( desc->length < offsetof(struct hvm_hw_cpu_xsave, save_area) +
@@ -1313,7 +1308,7 @@ static int cf_check hvm_load_cpu_xsave_s
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore mismatch: xsave length %u < %zu\n",
- d->domain_id, vcpuid, desc->length,
+ d->domain_id, v->vcpu_id, desc->length,
offsetof(struct hvm_hw_cpu_xsave,
save_area) + XSTATE_AREA_MIN_SIZE);
return -EINVAL;
@@ -1331,7 +1326,7 @@ static int cf_check hvm_load_cpu_xsave_s
printk(XENLOG_G_WARNING
"HVM%d.%d restore: inconsistent xsave state (feat=%#"PRIx64
" accum=%#"PRIx64" xcr0=%#"PRIx64" bv=%#"PRIx64" err=%d)\n",
- d->domain_id, vcpuid, ctxt->xfeature_mask, ctxt->xcr0_accum,
+ d->domain_id, v->vcpu_id, ctxt->xfeature_mask, ctxt->xcr0_accum,
ctxt->xcr0, ctxt->save_area.xsave_hdr.xstate_bv, err);
return err;
}
@@ -1350,13 +1345,13 @@ static int cf_check hvm_load_cpu_xsave_s
{
printk(XENLOG_G_WARNING
"HVM%d.%u restore mismatch: xsave length %#x > %#x (non-zero data at %#x)\n",
- d->domain_id, vcpuid, desc->length, size, i);
+ d->domain_id, v->vcpu_id, desc->length, size, i);
return -EOPNOTSUPP;
}
}
printk(XENLOG_G_WARNING
"HVM%d.%u restore mismatch: xsave length %#x > %#x\n",
- d->domain_id, vcpuid, desc->length, size);
+ d->domain_id, v->vcpu_id, desc->length, size);
/* Rewind desc_length to ignore the extraneous zeros. */
desc_length = size;
}
@@ -1365,14 +1360,14 @@ static int cf_check hvm_load_cpu_xsave_s
{
printk(XENLOG_G_WARNING
"HVM%d.%u restore: compressed xsave state not supported\n",
- d->domain_id, vcpuid);
+ d->domain_id, v->vcpu_id);
return -EOPNOTSUPP;
}
else if ( desc_length != size )
{
printk(XENLOG_G_WARNING
"HVM%d.%u restore mismatch: xsave length %#x != %#x\n",
- d->domain_id, vcpuid, desc_length, size);
+ d->domain_id, v->vcpu_id, desc_length, size);
return -EINVAL;
}
/* Checking finished */
@@ -1481,15 +1476,15 @@ static int cf_check hvm_save_cpu_msrs(st
static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h)
{
- unsigned int i, vcpuid = hvm_load_instance(h);
- struct vcpu *v;
+ unsigned int i;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
const struct hvm_save_descriptor *desc;
struct hvm_msr *ctxt;
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
@@ -1499,21 +1494,21 @@ static int cf_check hvm_load_cpu_msrs(st
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore: not enough data left to read MSR descriptor\n",
- d->domain_id, vcpuid);
+ d->domain_id, v->vcpu_id);
return -ENODATA;
}
if ( desc->length + sizeof (*desc) > h->size - h->cur)
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore: not enough data left to read %u MSR bytes\n",
- d->domain_id, vcpuid, desc->length);
+ d->domain_id, v->vcpu_id, desc->length);
return -ENODATA;
}
if ( desc->length < HVM_CPU_MSR_SIZE(1) )
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore mismatch: MSR length %u < %zu\n",
- d->domain_id, vcpuid, desc->length, HVM_CPU_MSR_SIZE(1));
+ d->domain_id, v->vcpu_id, desc->length, HVM_CPU_MSR_SIZE(1));
return -EINVAL;
}
@@ -1525,7 +1520,7 @@ static int cf_check hvm_load_cpu_msrs(st
{
printk(XENLOG_G_WARNING
"HVM%d.%d restore mismatch: MSR length %u != %zu\n",
- d->domain_id, vcpuid, desc->length,
+ d->domain_id, v->vcpu_id, desc->length,
HVM_CPU_MSR_SIZE(ctxt->count));
return -EOPNOTSUPP;
}
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -735,15 +735,15 @@ static int cf_check hvm_save_mtrr_msr(st
static int cf_check hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
{
- unsigned int vcpuid = hvm_load_instance(h), i;
- struct vcpu *v = domain_vcpu(d, vcpuid);
+ unsigned int i;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
struct mtrr_state *m;
struct hvm_hw_mtrr hw_mtrr;
if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
--- a/xen/arch/x86/hvm/viridian/viridian.c
+++ b/xen/arch/x86/hvm/viridian/viridian.c
@@ -1152,14 +1152,13 @@ static int cf_check viridian_save_vcpu_c
static int cf_check viridian_load_vcpu_ctxt(
struct domain *d, hvm_domain_context_t *h)
{
- unsigned int vcpuid = hvm_load_instance(h);
- struct vcpu *v;
+ struct vcpu *v = hvm_load_vcpu_instance(d, h);
struct hvm_viridian_vcpu_context ctxt;
- if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
+ if ( !v )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1577,16 +1577,17 @@ static void lapic_load_fixup(struct vlap
}
-static int lapic_check_common(const struct domain *d, unsigned int vcpuid)
+static int lapic_check_common(const struct domain *d,
+ const hvm_domain_context_t *h)
{
if ( !has_vlapic(d) )
return -ENODEV;
/* Which vlapic to load? */
- if ( !domain_vcpu(d, vcpuid) )
+ if ( !hvm_load_vcpu_instance(d, h) )
{
dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vCPU %u\n",
- d->domain_id, vcpuid);
+ d->domain_id, hvm_load_instance(h));
return -EINVAL;
}
@@ -1596,9 +1597,8 @@ static int lapic_check_common(const stru
static int cf_check lapic_check_hidden(const struct domain *d,
hvm_domain_context_t *h)
{
- unsigned int vcpuid = hvm_load_instance(h);
struct hvm_hw_lapic s;
- int rc = lapic_check_common(d, vcpuid);
+ int rc = lapic_check_common(d, h);
if ( rc )
return rc;
@@ -1638,10 +1638,9 @@ static int cf_check lapic_load_hidden(st
static int cf_check lapic_check_regs(const struct domain *d,
hvm_domain_context_t *h)
{
- unsigned int vcpuid = hvm_load_instance(h);
int rc;
- if ( (rc = lapic_check_common(d, vcpuid)) )
+ if ( (rc = lapic_check_common(d, h)) )
return rc;
if ( !hvm_get_entry(LAPIC_REGS, h) )
--- a/xen/arch/x86/include/asm/hvm/save.h
+++ b/xen/arch/x86/include/asm/hvm/save.h
@@ -6,8 +6,8 @@
#ifndef __XEN_HVM_SAVE_H__
#define __XEN_HVM_SAVE_H__
-#include <xen/types.h>
#include <xen/init.h>
+#include <xen/sched.h>
#include <public/xen.h>
#include <public/hvm/save.h>
@@ -97,6 +97,13 @@ static inline unsigned int hvm_load_inst
return d->instance;
}
+/* Unmarshalling: Wrapper around the above for per-vCPU instances. */
+static inline struct vcpu *hvm_load_vcpu_instance(
+ const struct domain *d, const struct hvm_domain_context *h)
+{
+ return domain_vcpu(d, hvm_load_instance(h));
+}
+
/* Handler types for different types of save-file entry.
* The save handler may save multiple instances of a type into the buffer;
* the load handler will be called once for each instance found when
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 12/13] x86/vPMU: use domain_vcpu()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (10 preceding siblings ...)
2026-11-26 13:41 ` [PATCH 11/13] x86/HVM: introduce hvm_load_vcpu_instance() Jan Beulich
@ 2026-11-26 13:42 ` 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
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:42 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -564,15 +564,14 @@ void vpmu_destroy(struct vcpu *v)
static int pvpmu_init(struct domain *d, xen_pmu_params_t *params)
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, params->vcpu);
struct vpmu_struct *vpmu;
struct page_info *page;
uint64_t gfn = params->val;
- if ( (params->vcpu >= d->max_vcpus) || (d->vcpu[params->vcpu] == NULL) )
+ if ( !v )
return -EINVAL;
- v = d->vcpu[params->vcpu];
vpmu = vcpu_vpmu(v);
if ( !vpmu_available(v) )
@@ -615,12 +614,11 @@ static int pvpmu_init(struct domain *d,
static void pvpmu_finish(struct domain *d, xen_pmu_params_t *params)
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, params->vcpu);
- if ( (params->vcpu >= d->max_vcpus) || (d->vcpu[params->vcpu] == NULL) )
+ if ( !v )
return;
- v = d->vcpu[params->vcpu];
if ( v != current )
vcpu_pause(v);
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 13/13] x86/domctl: use domain_vcpu() to handle various sub-ops
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (11 preceding siblings ...)
2026-11-26 13:42 ` [PATCH 12/13] x86/vPMU: use domain_vcpu() Jan Beulich
@ 2026-11-26 13:42 ` Jan Beulich
2026-12-02 6:32 ` [PATCH 00/13] make better use of domain_vcpu() Stephen Cheng
13 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:42 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné
If for nothing else, then to reduce the number of open-coded d->vcpu[]
accesses.
No functional change intended.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -573,11 +573,10 @@ long arch_do_domctl(
case XEN_DOMCTL_sendtrigger:
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, domctl->u.sendtrigger.vcpu);
ret = -ESRCH;
- if ( domctl->u.sendtrigger.vcpu >= d->max_vcpus ||
- (v = d->vcpu[domctl->u.sendtrigger.vcpu]) == NULL )
+ if ( !v )
break;
switch ( domctl->u.sendtrigger.trigger )
@@ -789,11 +788,10 @@ long arch_do_domctl(
case XEN_DOMCTL_get_ext_vcpucontext:
{
struct xen_domctl_ext_vcpucontext *evc = &domctl->u.ext_vcpucontext;
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, evc->vcpu);
ret = -ESRCH;
- if ( (evc->vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[evc->vcpu]) == NULL) )
+ if ( !v )
break;
if ( domctl->cmd == XEN_DOMCTL_get_ext_vcpucontext )
@@ -912,15 +910,14 @@ long arch_do_domctl(
case XEN_DOMCTL_debug_op:
{
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, domctl->u.debug_op.vcpu);
ret = -EOPNOTSUPP;
if ( !IS_ENABLED(CONFIG_HVM) )
break;
ret = -EINVAL;
- if ( (domctl->u.debug_op.vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[domctl->u.debug_op.vcpu]) == NULL) )
+ if ( !v )
break;
ret = -EINVAL;
@@ -943,15 +940,14 @@ long arch_do_domctl(
case XEN_DOMCTL_getvcpuextstate:
{
struct xen_domctl_vcpuextstate *evc = &domctl->u.vcpuextstate;
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, evc->vcpu);
uint32_t offset = 0;
#define PV_XSAVE_HDR_SIZE (2 * sizeof(uint64_t))
#define PV_XSAVE_SIZE(xcr0) (PV_XSAVE_HDR_SIZE + xstate_uncompressed_size(xcr0))
ret = -ESRCH;
- if ( (evc->vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[evc->vcpu]) == NULL) )
+ if ( !v )
goto vcpuextstate_out;
ret = -EINVAL;
@@ -1148,7 +1144,7 @@ long arch_do_domctl(
{
struct xen_domctl_vcpu_msrs *vmsrs = &domctl->u.vcpu_msrs;
struct xen_domctl_vcpu_msr msr = {};
- struct vcpu *v;
+ struct vcpu *v = domain_vcpu(d, vmsrs->vcpu);
static const uint32_t msrs_to_send[] = {
MSR_SPEC_CTRL,
MSR_INTEL_MISC_FEATURES_ENABLES,
@@ -1161,8 +1157,7 @@ long arch_do_domctl(
uint32_t nr_msrs = ARRAY_SIZE(msrs_to_send);
ret = -ESRCH;
- if ( (vmsrs->vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[vmsrs->vcpu]) == NULL) )
+ if ( !v )
break;
ret = -EINVAL;
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 11/13] x86/HVM: introduce hvm_load_vcpu_instance()
2026-11-26 13:41 ` [PATCH 11/13] x86/HVM: introduce hvm_load_vcpu_instance() Jan Beulich
@ 2026-11-26 13:43 ` Jan Beulich
0 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-11-26 13:43 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné, Paul Durrant
On 26.11.2026 14:41, Jan Beulich wrote:
> Use this to remove open-coding of domain_vcpu().
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> lapic_load_{hidden,regs}() are left alone, as I fear analysis tools would
> otherwise pick on the missing NULL checks.
I'm sorry, I should have Cc-ed Paul as well.
Jan
> --- a/xen/arch/x86/cpu/mcheck/vmce.c
> +++ b/xen/arch/x86/cpu/mcheck/vmce.c
> @@ -364,15 +364,14 @@ static int cf_check vmce_save_vcpu_ctxt(
>
> static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
> {
> - unsigned int vcpuid = hvm_load_instance(h);
> - struct vcpu *v;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> struct hvm_vmce_vcpu ctxt;
> int err;
>
> - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> + if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> err = -EINVAL;
> }
> else
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -804,14 +804,13 @@ static int cf_check hvm_save_tsc_adjust(
>
> static int cf_check hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h)
> {
> - unsigned int vcpuid = hvm_load_instance(h);
> - struct vcpu *v;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> struct hvm_tsc_adjust ctxt;
>
> - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> + if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> @@ -1018,18 +1017,16 @@ unsigned long hvm_cr4_guest_valid_bits(c
> static int cf_check hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
> {
> const struct cpu_policy *p = d->arch.cpu_policy;
> - unsigned int vcpuid = hvm_load_instance(h);
> - struct vcpu *v;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> struct hvm_hw_cpu ctxt;
> struct segment_register seg;
> const char *errstr;
> unsigned long valid;
>
> - /* Which vcpu is this? */
> - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> + if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%u has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> @@ -1267,19 +1264,17 @@ CHECK_FIELD_(struct, xsave_hdr, reserved
> static int cf_check hvm_load_cpu_xsave_states(
> struct domain *d, hvm_domain_context_t *h)
> {
> - unsigned int vcpuid, size;
> + unsigned int size;
> int err;
> - struct vcpu *v;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> struct hvm_hw_cpu_xsave *ctxt;
> const struct hvm_save_descriptor *desc;
> unsigned int i, desc_start, desc_length;
>
> - /* Which vcpu is this? */
> - vcpuid = hvm_load_instance(h);
> - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> + if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> @@ -1298,14 +1293,14 @@ static int cf_check hvm_load_cpu_xsave_s
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore: not enough data left to read xsave descriptor\n",
> - d->domain_id, vcpuid);
> + d->domain_id, v->vcpu_id);
> return -ENODATA;
> }
> if ( desc->length + sizeof (*desc) > h->size - h->cur)
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore: not enough data left to read %u xsave bytes\n",
> - d->domain_id, vcpuid, desc->length);
> + d->domain_id, v->vcpu_id, desc->length);
> return -ENODATA;
> }
> if ( desc->length < offsetof(struct hvm_hw_cpu_xsave, save_area) +
> @@ -1313,7 +1308,7 @@ static int cf_check hvm_load_cpu_xsave_s
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore mismatch: xsave length %u < %zu\n",
> - d->domain_id, vcpuid, desc->length,
> + d->domain_id, v->vcpu_id, desc->length,
> offsetof(struct hvm_hw_cpu_xsave,
> save_area) + XSTATE_AREA_MIN_SIZE);
> return -EINVAL;
> @@ -1331,7 +1326,7 @@ static int cf_check hvm_load_cpu_xsave_s
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore: inconsistent xsave state (feat=%#"PRIx64
> " accum=%#"PRIx64" xcr0=%#"PRIx64" bv=%#"PRIx64" err=%d)\n",
> - d->domain_id, vcpuid, ctxt->xfeature_mask, ctxt->xcr0_accum,
> + d->domain_id, v->vcpu_id, ctxt->xfeature_mask, ctxt->xcr0_accum,
> ctxt->xcr0, ctxt->save_area.xsave_hdr.xstate_bv, err);
> return err;
> }
> @@ -1350,13 +1345,13 @@ static int cf_check hvm_load_cpu_xsave_s
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%u restore mismatch: xsave length %#x > %#x (non-zero data at %#x)\n",
> - d->domain_id, vcpuid, desc->length, size, i);
> + d->domain_id, v->vcpu_id, desc->length, size, i);
> return -EOPNOTSUPP;
> }
> }
> printk(XENLOG_G_WARNING
> "HVM%d.%u restore mismatch: xsave length %#x > %#x\n",
> - d->domain_id, vcpuid, desc->length, size);
> + d->domain_id, v->vcpu_id, desc->length, size);
> /* Rewind desc_length to ignore the extraneous zeros. */
> desc_length = size;
> }
> @@ -1365,14 +1360,14 @@ static int cf_check hvm_load_cpu_xsave_s
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%u restore: compressed xsave state not supported\n",
> - d->domain_id, vcpuid);
> + d->domain_id, v->vcpu_id);
> return -EOPNOTSUPP;
> }
> else if ( desc_length != size )
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%u restore mismatch: xsave length %#x != %#x\n",
> - d->domain_id, vcpuid, desc_length, size);
> + d->domain_id, v->vcpu_id, desc_length, size);
> return -EINVAL;
> }
> /* Checking finished */
> @@ -1481,15 +1476,15 @@ static int cf_check hvm_save_cpu_msrs(st
>
> static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h)
> {
> - unsigned int i, vcpuid = hvm_load_instance(h);
> - struct vcpu *v;
> + unsigned int i;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> const struct hvm_save_descriptor *desc;
> struct hvm_msr *ctxt;
>
> - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> + if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> @@ -1499,21 +1494,21 @@ static int cf_check hvm_load_cpu_msrs(st
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore: not enough data left to read MSR descriptor\n",
> - d->domain_id, vcpuid);
> + d->domain_id, v->vcpu_id);
> return -ENODATA;
> }
> if ( desc->length + sizeof (*desc) > h->size - h->cur)
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore: not enough data left to read %u MSR bytes\n",
> - d->domain_id, vcpuid, desc->length);
> + d->domain_id, v->vcpu_id, desc->length);
> return -ENODATA;
> }
> if ( desc->length < HVM_CPU_MSR_SIZE(1) )
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore mismatch: MSR length %u < %zu\n",
> - d->domain_id, vcpuid, desc->length, HVM_CPU_MSR_SIZE(1));
> + d->domain_id, v->vcpu_id, desc->length, HVM_CPU_MSR_SIZE(1));
> return -EINVAL;
> }
>
> @@ -1525,7 +1520,7 @@ static int cf_check hvm_load_cpu_msrs(st
> {
> printk(XENLOG_G_WARNING
> "HVM%d.%d restore mismatch: MSR length %u != %zu\n",
> - d->domain_id, vcpuid, desc->length,
> + d->domain_id, v->vcpu_id, desc->length,
> HVM_CPU_MSR_SIZE(ctxt->count));
> return -EOPNOTSUPP;
> }
> --- a/xen/arch/x86/hvm/mtrr.c
> +++ b/xen/arch/x86/hvm/mtrr.c
> @@ -735,15 +735,15 @@ static int cf_check hvm_save_mtrr_msr(st
>
> static int cf_check hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
> {
> - unsigned int vcpuid = hvm_load_instance(h), i;
> - struct vcpu *v = domain_vcpu(d, vcpuid);
> + unsigned int i;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> struct mtrr_state *m;
> struct hvm_hw_mtrr hw_mtrr;
>
> if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> --- a/xen/arch/x86/hvm/viridian/viridian.c
> +++ b/xen/arch/x86/hvm/viridian/viridian.c
> @@ -1152,14 +1152,13 @@ static int cf_check viridian_save_vcpu_c
> static int cf_check viridian_load_vcpu_ctxt(
> struct domain *d, hvm_domain_context_t *h)
> {
> - unsigned int vcpuid = hvm_load_instance(h);
> - struct vcpu *v;
> + struct vcpu *v = hvm_load_vcpu_instance(d, h);
> struct hvm_viridian_vcpu_context ctxt;
>
> - if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> + if ( !v )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -1577,16 +1577,17 @@ static void lapic_load_fixup(struct vlap
> }
>
>
> -static int lapic_check_common(const struct domain *d, unsigned int vcpuid)
> +static int lapic_check_common(const struct domain *d,
> + const hvm_domain_context_t *h)
> {
> if ( !has_vlapic(d) )
> return -ENODEV;
>
> /* Which vlapic to load? */
> - if ( !domain_vcpu(d, vcpuid) )
> + if ( !hvm_load_vcpu_instance(d, h) )
> {
> dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vCPU %u\n",
> - d->domain_id, vcpuid);
> + d->domain_id, hvm_load_instance(h));
> return -EINVAL;
> }
>
> @@ -1596,9 +1597,8 @@ static int lapic_check_common(const stru
> static int cf_check lapic_check_hidden(const struct domain *d,
> hvm_domain_context_t *h)
> {
> - unsigned int vcpuid = hvm_load_instance(h);
> struct hvm_hw_lapic s;
> - int rc = lapic_check_common(d, vcpuid);
> + int rc = lapic_check_common(d, h);
>
> if ( rc )
> return rc;
> @@ -1638,10 +1638,9 @@ static int cf_check lapic_load_hidden(st
> static int cf_check lapic_check_regs(const struct domain *d,
> hvm_domain_context_t *h)
> {
> - unsigned int vcpuid = hvm_load_instance(h);
> int rc;
>
> - if ( (rc = lapic_check_common(d, vcpuid)) )
> + if ( (rc = lapic_check_common(d, h)) )
> return rc;
>
> if ( !hvm_get_entry(LAPIC_REGS, h) )
> --- a/xen/arch/x86/include/asm/hvm/save.h
> +++ b/xen/arch/x86/include/asm/hvm/save.h
> @@ -6,8 +6,8 @@
> #ifndef __XEN_HVM_SAVE_H__
> #define __XEN_HVM_SAVE_H__
>
> -#include <xen/types.h>
> #include <xen/init.h>
> +#include <xen/sched.h>
> #include <public/xen.h>
> #include <public/hvm/save.h>
>
> @@ -97,6 +97,13 @@ static inline unsigned int hvm_load_inst
> return d->instance;
> }
>
> +/* Unmarshalling: Wrapper around the above for per-vCPU instances. */
> +static inline struct vcpu *hvm_load_vcpu_instance(
> + const struct domain *d, const struct hvm_domain_context *h)
> +{
> + return domain_vcpu(d, hvm_load_instance(h));
> +}
> +
> /* Handler types for different types of save-file entry.
> * The save handler may save multiple instances of a type into the buffer;
> * the load handler will be called once for each instance found when
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/13] make better use of domain_vcpu()
2026-11-26 12:48 [PATCH 00/13] make better use of domain_vcpu() Jan Beulich
` (12 preceding siblings ...)
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 ` Stephen Cheng
2026-12-02 7:34 ` Jan Beulich
13 siblings, 1 reply; 19+ messages in thread
From: Stephen Cheng @ 2026-12-02 6:32 UTC (permalink / raw)
To: jbeulich
Cc: xen-devel, Stephen Cheng, Andrew Cooper, Roger Pau Monné,
Teddy Astie, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Tamas K Lengyel
On 26/11/2026 12:48, Jan Beulich wrote:
> I.e. reduce the number of instances where we access d->vcpu[] directly.
> The series doesn't cover all cases, just a fair part. I think there are
> no inter-dependencies between the individual patches.
>
> [...]
> 04: domctl: use domain_vcpu() in XEN_DOMCTL_{g,s}etvcpucontext handling
> 05: vm-event: use domain_vcpu() in domctl handling
> 06: numa: use domain_vcpu() in domain_to_node()
> 07: x86/time: use domain_vcpu() in tsc_set_info()
> 08: x86/paging: use domain_vcpu() in paging_domctl()
> 09: x86/dm: use domain_vcpu()
> 10: x86/HVM/MTRR: use domain_vcpu()
> 11: x86/HVM: introduce hvm_load_vcpu_instance()
> 12: x86/vPMU: use domain_vcpu()
> 13: x86/domctl: use domain_vcpu() to handle various sub-ops
One small thing: 11 does not apply without 10, since its mtrr.c hunk
is on top of 10's change to hvm_load_mtrr_msr(). Maybe 10 could leave
that function alone, as 11 rewrites it anyway.
I checked 04-10, 12 and 13 against the old code. In each of them the
new domain_vcpu() check covers the cases the old open-coded check did.
For patches 04-10, 12 and 13:
Reviewed-by: Stephen Cheng <stephen.cheng@citrix.com>
Stephen
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 03/13] x86/altp2m: don't blindly assume vCPU-s exist
2026-11-26 13:37 ` [PATCH 03/13] x86/altp2m: " Jan Beulich
@ 2026-12-02 6:38 ` Stephen Cheng
2026-12-02 7:41 ` Jan Beulich
0 siblings, 1 reply; 19+ messages in thread
From: Stephen Cheng @ 2026-12-02 6:38 UTC (permalink / raw)
To: jbeulich
Cc: xen-devel, Stephen Cheng, Andrew Cooper, Roger Pau Monné,
Teddy Astie
On 26/11/2026 13:37, Jan Beulich wrote:
> [...]
> 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 )
I think this should be a.u.disable_notify.vcpu_id, probably a copy and
paste accident.
With that changed:
Reviewed-by: Stephen Cheng <stephen.cheng@citrix.com>
Stephen
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/13] make better use of domain_vcpu()
2026-12-02 6:32 ` [PATCH 00/13] make better use of domain_vcpu() Stephen Cheng
@ 2026-12-02 7:34 ` Jan Beulich
0 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-12-02 7:34 UTC (permalink / raw)
To: Stephen Cheng
Cc: xen-devel, Andrew Cooper, Roger Pau Monné, Teddy Astie,
Julien Grall, Stefano Stabellini, Anthony PERARD, Michal Orzel,
Tamas K Lengyel
On 02.12.2026 07:32, Stephen Cheng wrote:
> On 26/11/2026 12:48, Jan Beulich wrote:
>> I.e. reduce the number of instances where we access d->vcpu[] directly.
>> The series doesn't cover all cases, just a fair part. I think there are
>> no inter-dependencies between the individual patches.
>>
>> [...]
>> 04: domctl: use domain_vcpu() in XEN_DOMCTL_{g,s}etvcpucontext handling
>> 05: vm-event: use domain_vcpu() in domctl handling
>> 06: numa: use domain_vcpu() in domain_to_node()
>> 07: x86/time: use domain_vcpu() in tsc_set_info()
>> 08: x86/paging: use domain_vcpu() in paging_domctl()
>> 09: x86/dm: use domain_vcpu()
>> 10: x86/HVM/MTRR: use domain_vcpu()
>> 11: x86/HVM: introduce hvm_load_vcpu_instance()
>> 12: x86/vPMU: use domain_vcpu()
>> 13: x86/domctl: use domain_vcpu() to handle various sub-ops
>
> One small thing: 11 does not apply without 10, since its mtrr.c hunk
> is on top of 10's change to hvm_load_mtrr_msr(). Maybe 10 could leave
> that function alone, as 11 rewrites it anyway.
Right, I did notice the double change to the function, but I wasn't
bothered enough to do something about it. If anything, patches 10 and
11 should be swapped, such that the description of what is now 10
wouldn't be inaccurate (as to leaving one case unaddressed). I'm not
sure though whether that would be worthwhile the effort.
> I checked 04-10, 12 and 13 against the old code. In each of them the
> new domain_vcpu() check covers the cases the old open-coded check did.
>
> For patches 04-10, 12 and 13:
> Reviewed-by: Stephen Cheng <stephen.cheng@citrix.com>
Thanks.
Jan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 03/13] x86/altp2m: don't blindly assume vCPU-s exist
2026-12-02 6:38 ` Stephen Cheng
@ 2026-12-02 7:41 ` Jan Beulich
0 siblings, 0 replies; 19+ messages in thread
From: Jan Beulich @ 2026-12-02 7:41 UTC (permalink / raw)
To: Stephen Cheng; +Cc: xen-devel, Andrew Cooper, Roger Pau Monné, Teddy Astie
On 02.12.2026 07:38, Stephen Cheng wrote:
> On 26/11/2026 13:37, Jan Beulich wrote:
>> [...]
>> 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 )
>
> I think this should be a.u.disable_notify.vcpu_id, probably a copy and
> paste accident.
Not quite. You zapped the other hunk following this one:
@@ -4749,8 +4746,6 @@ static int do_altp2m_op(
break;
}
- v = d->vcpu[a.u.enable_notify.vcpu_id];
-
altp2m_vcpu_disable_ve(v);
break;
}
I did actually _move_ its array index to the function invocation. And while
doing so I did notice it's "enable" there, but (not looking at the other
field use) implied that "enable" and "disable" use the same struct.
> With that changed:
> Reviewed-by: Stephen Cheng <stephen.cheng@citrix.com>
Thanks. I've also amended the description accordingly.
Jan
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-12-02 7:41 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 03/13] x86/altp2m: " Jan Beulich
2026-12-02 6:38 ` 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
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.