diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c index bdfc6fc750..9ca8259c0d 100644 --- a/xen/arch/x86/hvm/hpet.c +++ b/xen/arch/x86/hvm/hpet.c @@ -506,11 +506,13 @@ const struct hvm_mmio_handler hpet_mmio_handler = { static int hpet_save(struct domain *d, hvm_domain_context_t *h) { HPETState *hp = domain_vhpet(d); + struct vcpu *v = pt_global_vcpu_target(d); int rc; uint64_t guest_time; write_lock(&hp->lock); - guest_time = guest_time_hpet(hp); + guest_time = (v->arch.hvm_vcpu.guest_time ?: hvm_get_guest_time(v)) / + STIME_PER_HPET_TICK; /* Write the proper value into the main counter */ if ( hpet_enabled(hp) ) diff --git a/xen/arch/x86/hvm/pmtimer.c b/xen/arch/x86/hvm/pmtimer.c index 6ad2797986..0f79e84953 100644 --- a/xen/arch/x86/hvm/pmtimer.c +++ b/xen/arch/x86/hvm/pmtimer.c @@ -250,10 +250,12 @@ static int pmtimer_save(struct domain *d, hvm_domain_context_t *h) spin_lock(&s->lock); - /* Update the counter to the guest's current time. We always save - * with the domain paused, so the saved time should be after the - * last_gtime, but just in case, make sure we only go forwards */ - x = ((s->vcpu->arch.hvm_vcpu.guest_time - s->last_gtime) * s->scale) >> 32; + /* + * Update the counter to the guest's current time. Make sure it only + * goes forwards. + */ + x = (((s->vcpu->arch.hvm_vcpu.guest_time ?: hvm_get_guest_time(s->vcpu)) - + s->last_gtime) * s->scale) >> 32; if ( x < 1UL<<31 ) s->pm.tmr_val += x; if ( (s->pm.tmr_val & TMR_VAL_MSB) != msb )