All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Durrant, Paul" <pdurrant@amazon.com>
To: Wei Liu <wl@xen.org>,
	Xen Development List <xen-devel@lists.xenproject.org>
Cc: "Wei Liu" <liuwe@microsoft.com>, "Paul Durrant" <paul@xen.org>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Michael Kelley" <mikelley@microsoft.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 5/4] x86/viridian: drop a wrong invalid value from reference TSC implementation
Date: Sat, 21 Dec 2019 12:06:59 +0000	[thread overview]
Message-ID: <affb8b6f87f744ec865101401d4f9131@EX13D32EUC003.ant.amazon.com> (raw)
In-Reply-To: <20191220212103.4192-1-liuwe@microsoft.com>

> -----Original Message-----
> From: Wei Liu <wei.liu.xen@gmail.com> On Behalf Of Wei Liu
> Sent: 20 December 2019 21:21
> To: Xen Development List <xen-devel@lists.xenproject.org>
> Cc: Durrant, Paul <pdurrant@amazon.com>; Michael Kelley
> <mikelley@microsoft.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 5/4] 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>
> ---
>  xen/arch/x86/hvm/viridian/time.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/viridian/time.c
> b/xen/arch/x86/hvm/viridian/time.c
> index 6b2d745f3a..b8280a1a60 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,7 +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
> */
> +    if ( seq == 0 ) /* Avoid 'invalid' value */
>          seq = 1;
> 
>      p->tsc_sequence = seq;

Now that we're just dealing with 0, I think the code would be neater as:

seq = p->tsc_sequence + 1;
p->tsc_sequence = seq ? seq : 1; /* Avoid 'invalid' value 0 */

  Paul



> --
> 2.20.1


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

      reply	other threads:[~2019-12-21 12:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 19:51 [Xen-devel] [PATCH 0/4] Clean up viridian code Wei Liu
2019-12-20 19:51 ` [Xen-devel] [PATCH 1/4] x86/viridian: drop duplicate defines from private.h and viridian.c Wei Liu
2019-12-21 12:19   ` Durrant, Paul
2019-12-20 19:51 ` [Xen-devel] [PATCH 2/4] x86/viridian: drop private copy of HV_REFERENCE_TSC_PAGE in time.c Wei Liu
2019-12-21 12:20   ` Durrant, Paul
2019-12-20 19:51 ` [Xen-devel] [PATCH 3/4] x86: provide and use hv_tsc_scale Wei Liu
2019-12-21 12:27   ` Durrant, Paul
2019-12-20 19:51 ` [Xen-devel] [PATCH 4/4] x86: move viridian_guest_os_id_msr to hyperv-tlfs.h Wei Liu
2019-12-21 12:28   ` Durrant, Paul
2019-12-20 21:21 ` [Xen-devel] [PATCH 5/4] x86/viridian: drop a wrong invalid value from reference TSC implementation Wei Liu
2019-12-21 12:06   ` Durrant, Paul [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=affb8b6f87f744ec865101401d4f9131@EX13D32EUC003.ant.amazon.com \
    --to=pdurrant@amazon.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=liuwe@microsoft.com \
    --cc=mikelley@microsoft.com \
    --cc=paul@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.