k...@linuxonhyperv.com writes:

> +
> +static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page 
> *tsc_pg,
> +                                    u64 *cur_tsc)
> +{
> +     u64     scale, offset;
> +     u32     sequence;
> +
> +     /*
> +      * The protocol for reading Hyper-V TSC page is specified in Hypervisor
> +      * Top-Level Functional Specification.  To get the reference time we
> +      * must do the following:
> +      * - READ ReferenceTscSequence
> +      *   A special '0' value indicates the time source is unreliable and we
> +      *   need to use something else.
> +      * - ReferenceTime =
> +      *     ((HWclock val) * ReferenceTscScale) >> 64) + ReferenceTscOffset
> +      * - READ ReferenceTscSequence again. In case its value has changed
> +      *   since our first reading we need to discard ReferenceTime and repeat
> +      *   the whole sequence as the hypervisor was updating the page in
> +      *   between.
> +      */
> +     do {
> +             sequence = READ_ONCE(tsc_pg->tsc_sequence);

(sorry if this was already discussed before)

Current x86 code doing this actually checks for '0' here (note the
comment about this special value above):

                sequence = READ_ONCE(tsc_pg->tsc_sequence);
                if (!sequence)
                        return U64_MAX;

Was it removed intentionally (and we need to fix the comment then)? 

-- 
Vitaly
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to