From patchwork Sun Dec 22 23:20:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11307707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 569B417EE for ; Sun, 22 Dec 2019 23:22:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30DE9206CB for ; Sun, 22 Dec 2019 23:22:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dCepD/sP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30DE9206CB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijAWl-0004Nc-PX; Sun, 22 Dec 2019 23:20:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijAWk-0004NX-Eh for xen-devel@lists.xenproject.org; Sun, 22 Dec 2019 23:20:46 +0000 X-Inumbo-ID: abba8c04-2511-11ea-b6f1-bc764e2007e4 Received: from mail-wr1-x444.google.com (unknown [2a00:1450:4864:20::444]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id abba8c04-2511-11ea-b6f1-bc764e2007e4; Sun, 22 Dec 2019 23:20:41 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id z3so14892700wru.3 for ; Sun, 22 Dec 2019 15:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4iY5LVyaAwL0gYA7x7G9RR7noTcF6nrPiSr/rUqWtRQ=; b=dCepD/sP9qHmVqVOQviK+S0nwllSjCJr5ZSscJn61a3HYgXTAFPiS3U5lWae4Xxh+H qYsLYDUmQVK+GrmUeN64G3p2Lu+r9qg3eRJBWvlNbvyVT3mUpMQJqomH9UHL7qRK1c0N JgYxCLLxWoIj6fDgLjKFXuz6C1fmLWO8s2Lae06GcJ+urK7YC2jRtiE7aG+cGNZQ2Rme ZutYPzcGJonSyt2cbvoUxD84t1Kl+YFlq1Bb5ATE5hwUq09T/S7TWvyQ01Z4tlvaeyC2 KskW/FqQxozobdZ33QuQOaucOPe2ta/e2RI9cDv9eIX8Oru4GghaYlRzRtuaOSZhvJ3p rs1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4iY5LVyaAwL0gYA7x7G9RR7noTcF6nrPiSr/rUqWtRQ=; b=Df4ztu0L7kBvghxU8fBQLssxxFM5xBO9H5ylDeETsNOHbGTlVIOQM8ebzDwimmIq7K fi9rL5JxkjQMKpIwE64Sv/Bwjr3xPx4UdG4bqJaF71uz9YSHN2vTzUWg4LsrY10OqxtP BrqeVyBXbB6FnIUutD7KSKKoJ/SJgkKZYBqjpUewmuORRq28vTS6pY/82tBkbq6eGdzy GjIkTu5RVQHn70/AE+DlPA0YhfvESPKIjcKp/dD+Qf+nK4iDx28SHAQq1h/uZaZufOeF 4U/e6LaIwqYjuAWS6OTTJIYXif2W7MQLc9c+XEAa1XTdjbcMRQA3R5rawLDVTRgZfg7U 2lvA== X-Gm-Message-State: APjAAAUze0PbKUtp9M+Qn1A/l9wUBpXmI+Zq7w9KZ917B/IIzQwq2oSO 1CBenH5T+b7anz/zPxGq2wDFpsuB X-Google-Smtp-Source: APXvYqxXO5fkORIasCIKFsqEizwh2cBiqac6wBuGubs592SlPuRKzpR2UiXHGkHE5Qv+4kMAwhI2yQ== X-Received: by 2002:adf:e8ca:: with SMTP id k10mr27261504wrn.50.1577056840945; Sun, 22 Dec 2019 15:20:40 -0800 (PST) Received: from debian.mshome.net (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id h2sm19925613wrt.45.2019.12.22.15.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2019 15:20:40 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 22 Dec 2019 23:20:33 +0000 Message-Id: <20191222232035.31613-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191222232035.31613-1-liuwe@microsoft.com> References: <20191222232035.31613-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/3] x86/viridian: drop a wrong invalid value from reference TSC implementation X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Paul Durrant , Andrew Cooper , Paul Durrant , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 Reviewed-by: Paul Durrant --- 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)