|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] x86/hvm: Don't save or load HVM context of a domain with no vCPUs
On 18.11.2026 08:02, Lin Liu wrote:
> XEN_DOMCTL_createdomain allocates d->vcpu[] but the vCPUs themselves are
> only created by a later XEN_DOMCTL_max_vcpus. In that window
> XEN_DOMCTL_gethvmcontext{,_partial} on the domain reach the per-domain
> save handlers with d->vcpu[0] == NULL. A dom0 tool polling xen-hvmctx
> across all domains while a VM was being restored took the host down:
>
> (XEN) HVM d25 save: PIC
> (XEN) RIP: e008:[<ffff82d04030dc98>]
> arch/x86/hvm/vpic.c#vpic_save+0x8/0x8f
> (XEN) rdi: 0000000000000000
> (XEN) Xen call trace:
> (XEN) [<ffff82d04030dc98>] R arch/x86/hvm/vpic.c#vpic_save+0x8/0x8f
> (XEN) [<ffff82d04021009f>] S arch/x86/hvm/save.c#hvm_save.cold+0x9b/0xf7
> (XEN) [<ffff82d04036d99c>] S arch_do_domctl+0x1a2c/0x28a6
> (XEN) [<ffff82d04025341a>] S do_domctl+0x139a/0x1642
> (XEN) [<ffff82d04033331e>] S pv_hypercall+0x3ae/0x59a
> (XEN) [<ffff82d0402003b5>] S lstar_enter+0x105/0x10a
> (XEN)
> (XEN) Panic on CPU 0:
> (XEN) FATAL PAGE FAULT
> (XEN) [error_code=0000]
> (XEN) Faulting linear address: 0000000000000018
>
> XEN_DOMCTL_sethvmcontext has the same problem on the load side, e.g.
> pit_load() uses d->vcpu[0] for the guest time.
>
> Refuse to save or load the whole context until vCPU 0 exists, and look up
> the vCPU in hvm_save_one() with domain_vcpu(), failing with -ENOENT as
> for other absent vCPUs.
>
> Fixes: d0d8980138c4 ("x86/hvm: remove redundant save functions")
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Lin Liu <lin.liu01@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
with ...
> --- a/xen/arch/x86/hvm/save.c
> +++ b/xen/arch/x86/hvm/save.c
> @@ -139,12 +139,11 @@ int hvm_save_one(struct domain *d, unsigned int
> typecode, unsigned int instance,
> !hvm_sr_handlers[typecode].save )
> return -EINVAL;
>
> - if ( hvm_sr_handlers[typecode].kind != HVMSR_PER_VCPU )
> - v = d->vcpu[0];
> - else if ( instance >= d->max_vcpus || !d->vcpu[instance] )
> + /* Per-domain records are saved via vCPU 0, absent before max_vcpus. */
> + v = domain_vcpu(d, hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU
> + ? instance : 0);
... this wrapped differently (happy to adjust while committing):
v = domain_vcpu(d,
hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU
? instance : 0);
or
v = domain_vcpu(d,
hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU ? instance
: 0);
When an argument is too long to fit on a line, I don't think it should share
a line with any earlier (or later) arguments.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |