xen/arch/x86/hvm/hvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
When settings HVM_PARAM_IDENT_PT, skip domain pausing when :
- there is no vcpu
- unrestricted guest capability is used
Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
---
Regarding checking for hvm_paging_enabled(v) (proposed in v2 review), we can't
as hvm_paging_enabled() is vCPU specific, and vCPU 0 may have a different value
to another one.
v3:
- rebased patches with staging
- adjusted formatting
v2:
- rebased patches with staging
xen/arch/x86/hvm/hvm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 9a4147b62e..2981a61cee 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4237,11 +4237,14 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value)
rc = -EINVAL;
break;
case HVM_PARAM_IDENT_PT:
+ v = domain_vcpu(d, 0);
+
/*
* Only actually required for VT-x lacking unrestricted_guest
* capabilities. Short circuit the pause if possible.
*/
- if ( paging_mode_shadow(d) || !using_vmx() )
+ if ( paging_mode_shadow(d) || !using_vmx() || !v ||
+ vmx_unrestricted_guest(v) )
break;
/*
--
2.55.0
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
On 09/09/2026 1:12 pm, Teddy Astie wrote: > When settings HVM_PARAM_IDENT_PT, skip domain pausing when : > - there is no vcpu > - unrestricted guest capability is used > > Signed-off-by: Teddy Astie <teddy.astie@vates.tech> > --- > Regarding checking for hvm_paging_enabled(v) (proposed in v2 review), we can't > as hvm_paging_enabled() is vCPU specific, and vCPU 0 may have a different value > to another one. > > v3: > - rebased patches with staging > - adjusted formatting > > v2: > - rebased patches with staging > > xen/arch/x86/hvm/hvm.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index 9a4147b62e..2981a61cee 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -4237,11 +4237,14 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value) > rc = -EINVAL; > break; > case HVM_PARAM_IDENT_PT: > + v = domain_vcpu(d, 0); > + > /* > * Only actually required for VT-x lacking unrestricted_guest > * capabilities. Short circuit the pause if possible. > */ > - if ( paging_mode_shadow(d) || !using_vmx() ) > + if ( paging_mode_shadow(d) || !using_vmx() || !v || > + vmx_unrestricted_guest(v) ) > break; The comment isn't really correct, and using vmx_unrestricted_guest() isn't really correct either. How about this instead: /* * IDENT_PT is needed only for Nehalem-era VT-x, where EPT is * available but Unrestricted Guest is not. * * The identity pagetable is configured by the toolstack or hvmloader, * and the param needs to move in the migration stream in case the VM * lands on an EPT && !Unrestricted system. * * Nothing, besides recording the value, needs to happen other than * for VT-x EPT && !Unrestricted VMs. * * TODO: Unrestricted Guest should be a domain property not a vCPU * property. */ v = domain_vcpu(d, 0); if ( !using_vmx() || !paging_mode_hap(d) || !v || vmx_unrestricted_guest(v) ) break; The case of no vCPUs isn't very interesting; in that case, pausing the domain is free. We can at least note that the data is in the wrong place, even if we don't fix it yet. ~Andrew
Le 09/09/2026 à 17:35, Andrew Cooper a écrit : > On 09/09/2026 1:12 pm, Teddy Astie wrote: >> When settings HVM_PARAM_IDENT_PT, skip domain pausing when : >> - there is no vcpu >> - unrestricted guest capability is used >> >> Signed-off-by: Teddy Astie <teddy.astie@vates.tech> >> --- >> Regarding checking for hvm_paging_enabled(v) (proposed in v2 review), we can't >> as hvm_paging_enabled() is vCPU specific, and vCPU 0 may have a different value >> to another one. >> >> v3: >> - rebased patches with staging >> - adjusted formatting >> >> v2: >> - rebased patches with staging >> >> xen/arch/x86/hvm/hvm.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c >> index 9a4147b62e..2981a61cee 100644 >> --- a/xen/arch/x86/hvm/hvm.c >> +++ b/xen/arch/x86/hvm/hvm.c >> @@ -4237,11 +4237,14 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value) >> rc = -EINVAL; >> break; >> case HVM_PARAM_IDENT_PT: >> + v = domain_vcpu(d, 0); >> + >> /* >> * Only actually required for VT-x lacking unrestricted_guest >> * capabilities. Short circuit the pause if possible. >> */ >> - if ( paging_mode_shadow(d) || !using_vmx() ) >> + if ( paging_mode_shadow(d) || !using_vmx() || !v || >> + vmx_unrestricted_guest(v) ) >> break; > > The comment isn't really correct, and using vmx_unrestricted_guest() > isn't really correct either. > > How about this instead: > > /* > * IDENT_PT is needed only for Nehalem-era VT-x, where EPT is > * available but Unrestricted Guest is not. > * > * The identity pagetable is configured by the toolstack or hvmloader, > * and the param needs to move in the migration stream in case the VM > * lands on an EPT && !Unrestricted system. > * > * Nothing, besides recording the value, needs to happen other than > * for VT-x EPT && !Unrestricted VMs. > * > * TODO: Unrestricted Guest should be a domain property not a vCPU > * property. > */ > v = domain_vcpu(d, 0); > if ( !using_vmx() || !paging_mode_hap(d) || !v || > vmx_unrestricted_guest(v) ) > break; > I'm ok with it (though regarding paging_mode_hap, I think paging_mode_shadow is prefered here because it will translate into directly 0 if shadow paging is disabled, otherwise we check for PG_HAP_enable, at least, that's what [1] seems to be about). But if we move unrestricted guest as being a domain-wide properly (or alternatively a system-wide one); that could make things simpler. [1] x86/paging: replace !paging_mode_hap() with paging_mode_shadow() > > The case of no vCPUs isn't very interesting; in that case, pausing the > domain is free. We can at least note that the data is in the wrong > place, even if we don't fix it yet. > The check for !v is mostly required for vmx_unrestricted_guest(v) to not dereference NULL. > ~Andrew Teddy
On 09.09.2026 14:12, Teddy Astie wrote: > When settings HVM_PARAM_IDENT_PT, skip domain pausing when : > - there is no vcpu > - unrestricted guest capability is used > > Signed-off-by: Teddy Astie <teddy.astie@vates.tech> Reviewed-by: Jan Beulich <jbeulich@suse.com> > --- > Regarding checking for hvm_paging_enabled(v) (proposed in v2 review), we can't > as hvm_paging_enabled() is vCPU specific, and vCPU 0 may have a different value > to another one. Ah, yes, of course. Jan
© 2016 - 2026 Red Hat, Inc.