[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/hvm/hpet: avoid 'small' time diff test on resume



>>> On 29.05.19 at 15:09, <paul.durrant@xxxxxxxxxx> wrote:
> I notice that we seemingly don't handle main counter wrap in the HPET code.
> The spec. says that timers should fire at the point the counter wraps at the
> timer's width. I think the need for the 'small' time test would go away if
> this was implemented, but that's for another day.

Oh, indeed. I wasn't even (actively) aware of this. (I haven't been able to
spot a statement to this effect though for wrapping of a 64-bit timer, just
32-bit ones.)

> @@ -273,10 +273,13 @@ static void hpet_set_timer(HPETState *h, unsigned int 
> tn,
>       * Detect time values set in the past. This is hard to do for 32-bit
>       * comparators as the timer does not have to be set that far in the 
> future
>       * for the counter difference to wrap a 32-bit signed integer. We fudge
> -     * by looking for a 'small' time value in the past.
> +     * by looking for a 'small' time value in the past. However, if we
> +     * are resuming from suspend, treat any wrap as past since the value
> +     * is unlikely to be 'small'.
>       */

"resuming" and "suspend" are at best ambiguous - to me the terms
relate more to ACPI S-states than to migrate/save/restore. Could
I get you to agree to using "restoring after migration" or some such?

With this in mind - is a new bool parameter needed at all? Can't you
instead key this off of vhpet_domain(h)->creation_finished?

>      if ( (int64_t)diff < 0 )
> -        diff = (timer_is_32bit(h, tn) && (-diff > HPET_TINY_TIME_SPAN))
> +        diff = (timer_is_32bit(h, tn) && (-diff > HPET_TINY_TIME_SPAN) &&
> +                !resume)

Logically I would see the new part of the condition go first, but that's
really minor as all three checks are sufficiently cheap.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.