diff mbox series

[1/3] x86/viridian: drop a wrong invalid value from reference TSC implementation

Message ID 20191222232035.31613-2-liuwe@microsoft.com (mailing list archive)
State New, archived
Headers show
Series More viridian code cleanup | expand

Commit Message

Wei Liu Dec. 22, 2019, 11:20 p.m. UTC
The only invalid value mentioned in Hyper-V TLFS 5.0c is 0. Michael
Kelley confirmed that 0xFFFFFFFF was never used [0].

[0] https://lists.xen.org/archives/html/xen-devel/2019-12/msg01564.html

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
 xen/arch/x86/hvm/viridian/time.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Comments

Paul Durrant Dec. 23, 2019, 8:36 a.m. UTC | #1
V2?

> -----Original Message-----
> From: Wei Liu <wei.liu.xen@gmail.com> On Behalf Of Wei Liu
> Sent: 22 December 2019 23:21
> To: Xen Development List <xen-devel@lists.xenproject.org>
> Cc: Michael Kelley <mikelley@microsoft.com>; Durrant, Paul
> <pdurrant@amazon.com>; Wei Liu <liuwe@microsoft.com>; Paul Durrant
> <paul@xen.org>; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <andrew.cooper3@citrix.com>; Wei Liu <wl@xen.org>; Roger Pau Monné
> <roger.pau@citrix.com>
> Subject: [PATCH 1/3] x86/viridian: drop a wrong invalid value from
> reference TSC implementation
> 
> The only invalid value mentioned in Hyper-V TLFS 5.0c is 0. Michael
> Kelley confirmed that 0xFFFFFFFF was never used [0].
> 
> [0] https://lists.xen.org/archives/html/xen-devel/2019-12/msg01564.html
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Reviewed-by: Paul Durrant <paul@xen.org>

> ---
>  xen/arch/x86/hvm/viridian/time.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/viridian/time.c
> b/xen/arch/x86/hvm/viridian/time.c
> index 6b2d745f3a..0f1cd9e208 100644
> --- a/xen/arch/x86/hvm/viridian/time.c
> +++ b/xen/arch/x86/hvm/viridian/time.c
> @@ -45,14 +45,9 @@ static void update_reference_tsc(const struct domain
> *d, bool initialize)
>      if ( !host_tsc_is_safe() || d->arch.vtsc )
>      {
>          /*
> -         * The specification states that valid values of TscSequence
> range
> -         * from 0 to 0xFFFFFFFE. The value 0xFFFFFFFF is used to indicate
> -         * this mechanism is no longer a reliable source of time and that
> -         * the VM should fall back to a different source.
> -         *
> -         * Server 2012 (6.2 kernel) and 2012 R2 (6.3 kernel) actually
> -         * violate the spec. and rely on a value of 0 to indicate that
> this
> -         * enlightenment should no longer be used.
> +         * The value 0 is used to indicate this mechanism is no longer a
> +         * reliable source of time and that the VM should fall back to a
> +         * different source.
>           */
>          p->tsc_sequence = 0;
> 
> @@ -77,10 +72,7 @@ static void update_reference_tsc(const struct domain
> *d, bool initialize)
>      smp_wmb();
> 
>      seq = p->tsc_sequence + 1;
> -    if ( seq == 0xFFFFFFFF || seq == 0 ) /* Avoid both 'invalid' values
> */
> -        seq = 1;
> -
> -    p->tsc_sequence = seq;
> +    p->tsc_sequence = seq ? seq : 1; /* Avoid 'invalid' value 0 */
>  }
> 
>  static uint64_t trc_val(const struct domain *d, int64_t offset)
> --
> 2.20.1
diff mbox series

Patch

diff --git a/xen/arch/x86/hvm/viridian/time.c b/xen/arch/x86/hvm/viridian/time.c
index 6b2d745f3a..0f1cd9e208 100644
--- a/xen/arch/x86/hvm/viridian/time.c
+++ b/xen/arch/x86/hvm/viridian/time.c
@@ -45,14 +45,9 @@  static void update_reference_tsc(const struct domain *d, bool initialize)
     if ( !host_tsc_is_safe() || d->arch.vtsc )
     {
         /*
-         * The specification states that valid values of TscSequence range
-         * from 0 to 0xFFFFFFFE. The value 0xFFFFFFFF is used to indicate
-         * this mechanism is no longer a reliable source of time and that
-         * the VM should fall back to a different source.
-         *
-         * Server 2012 (6.2 kernel) and 2012 R2 (6.3 kernel) actually
-         * violate the spec. and rely on a value of 0 to indicate that this
-         * enlightenment should no longer be used.
+         * The value 0 is used to indicate this mechanism is no longer a
+         * reliable source of time and that the VM should fall back to a
+         * different source.
          */
         p->tsc_sequence = 0;
 
@@ -77,10 +72,7 @@  static void update_reference_tsc(const struct domain *d, bool initialize)
     smp_wmb();
 
     seq = p->tsc_sequence + 1;
-    if ( seq == 0xFFFFFFFF || seq == 0 ) /* Avoid both 'invalid' values */
-        seq = 1;
-
-    p->tsc_sequence = seq;
+    p->tsc_sequence = seq ? seq : 1; /* Avoid 'invalid' value 0 */
 }
 
 static uint64_t trc_val(const struct domain *d, int64_t offset)