From patchwork Wed Dec 18 14:42:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11300891 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 3FCAA6C1 for ; Wed, 18 Dec 2019 14:43:50 +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 1B9492176D for ; Wed, 18 Dec 2019 14:43:50 +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="oke5Nffe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B9492176D 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 1ihaXX-0004WU-V7; Wed, 18 Dec 2019 14:43:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihaXW-0004W2-QY for xen-devel@lists.xenproject.org; Wed, 18 Dec 2019 14:43:02 +0000 X-Inumbo-ID: a460e7ac-21a4-11ea-88e7-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a460e7ac-21a4-11ea-88e7-bc764e2007e4; Wed, 18 Dec 2019 14:42:41 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id t14so2164911wmi.5 for ; Wed, 18 Dec 2019 06:42:40 -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=6Vd6PP8AckWCOyX3MeDYFFjlcFWcHwSKdkFKPIDjNB4=; b=oke5NffeGeU70Vq8ItC6n0NPGJUBbIGwh8X2f7bznCgJ6s8L5eVMEe+gqtQowltKjk dqf+KJQF3/qvZdcG2Nenb1gjEXnMMDbuJDcrlqX+5gwKtGm0PBu932lUBet0DH1YnKol yV0w84pcfgizMSrrhMGqszdHGpXFiI97RoUZipCTOG8xBgOf/akGF99VVu+vUocmmxid 1caV1wzOwoN6+GV7JBFH3LLFi5ofJbqtcuuqe1XXs11pkgiV3oz6uX3iXAF48GY689aZ UxqoX1XgE/GbwcWZzFG3yDOGALXKW9PhhKbCb+NlL11pVUc7Otk0FoqZ1PiSJqo1bE/J 7grg== 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=6Vd6PP8AckWCOyX3MeDYFFjlcFWcHwSKdkFKPIDjNB4=; b=lLQgwNYVYBGGKNX3YQTthzsxfuAwQXrOfzWU7Cb9BnhWIn+yUEeHDC8hsAoy3umfqc FhhuXvNfHoy4GzWCZCfn4yK4Tjd2DAPEOPj3H3AiazCHmFxyVN/m2NxzOPxMirlGGfSk n5kHCgT/+txv+IbrUL6M7ZW04fYpWiUwdSovbcKleKxVN/0IqMFIUxvDT4GH97vmAm9F fVORjp/c6+XFQSCHMH5jBy3CX1i0DjCkvpPao/UYH6k31Bxx1xO+sE+/D22mNMNGTCLo 2S75b1S2mHp04C5W4I6HEe4Om77KTuJKZmE7mFkf+y9j1buSEHfAqx1nL4mJplvysNWp 8MLA== X-Gm-Message-State: APjAAAV7xKBA2Q1APgCcEunVwraPIh2ebJv+DkO9TZW9QkGewe2sS1V6 meB+yMAC/5tF03KEo2iMKZjlM9at X-Google-Smtp-Source: APXvYqxpK/gC6kKfnUPqB/il3cC7HdKa111mDwNkAX+JcxViCXZeuw8HRcyJmClgZZVELgQk/bGbtg== X-Received: by 2002:a7b:c5d8:: with SMTP id n24mr3613054wmk.124.1576680159897; Wed, 18 Dec 2019 06:42:39 -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 p17sm2724894wmk.30.2019.12.18.06.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2019 06:42:39 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 18 Dec 2019 14:42:31 +0000 Message-Id: <20191218144233.15372-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191218144233.15372-1-liuwe@microsoft.com> References: <20191218144233.15372-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 4/6] x86/viridian: drop private copy of HV_REFERENCE_TSC_PAGE in time.c 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" Use the one defined in hyperv-tlfs.h instead. No functional change intended. Signed-off-by: Wei Liu --- xen/arch/x86/hvm/viridian/time.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/hvm/viridian/time.c b/xen/arch/x86/hvm/viridian/time.c index 6ddca29b29..33c15782e4 100644 --- a/xen/arch/x86/hvm/viridian/time.c +++ b/xen/arch/x86/hvm/viridian/time.c @@ -13,19 +13,11 @@ #include #include +#include #include #include "private.h" -typedef struct _HV_REFERENCE_TSC_PAGE -{ - uint32_t TscSequence; - uint32_t Reserved1; - uint64_t TscScale; - int64_t TscOffset; - uint64_t Reserved2[509]; -} HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE; - static void update_reference_tsc(const struct domain *d, bool initialize) { struct viridian_domain *vd = d->arch.hvm.viridian; @@ -41,18 +33,18 @@ static void update_reference_tsc(const struct domain *d, bool initialize) * This enlightenment must be disabled is the host TSC is not invariant. * However it is also disabled if vtsc is true (which means rdtsc is * being emulated). This generally happens when guest TSC freq and host - * TSC freq don't match. The TscScale value could be adjusted to cope + * TSC freq don't match. The tsc_scale value could be adjusted to cope * with this, allowing vtsc to be turned off, but support for this is * not yet present in the hypervisor. Thus is it is possible that * migrating a Windows VM between hosts of differing TSC frequencies * may result in large differences in guest performance. Any jump in * TSC due to migration down-time can, however, be compensated for by - * setting the TscOffset value (see below). + * setting the tsc_offset value (see below). */ if ( !host_tsc_is_safe() || d->arch.vtsc ) { /* - * The specification states that valid values of TscSequence range + * The specification states that valid values of tsc_sequence 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. @@ -61,7 +53,7 @@ static void update_reference_tsc(const struct domain *d, bool initialize) * violate the spec. and rely on a value of 0 to indicate that this * enlightenment should no longer be used. */ - p->TscSequence = 0; + p->tsc_sequence = 0; printk(XENLOG_G_INFO "d%d: VIRIDIAN REFERENCE_TSC: invalidated\n", d->domain_id); @@ -72,29 +64,29 @@ static void update_reference_tsc(const struct domain *d, bool initialize) * The guest will calculate reference time according to the following * formula: * - * ReferenceTime = ((RDTSC() * TscScale) >> 64) + TscOffset + * ReferenceTime = ((RDTSC() * tsc_scale) >> 64) + tsc_offset * * Windows uses a 100ns tick, so we need a scale which is cpu * ticks per 100ns shifted left by 64. * The offset value is calculated on restore after migration and * ensures that Windows will not see a large jump in ReferenceTime. */ - p->TscScale = ((10000ul << 32) / d->arch.tsc_khz) << 32; - p->TscOffset = trc->off; + p->tsc_scale = ((10000ul << 32) / d->arch.tsc_khz) << 32; + p->tsc_offset = trc->off; smp_wmb(); - seq = p->TscSequence + 1; + seq = p->tsc_sequence + 1; if ( seq == 0xFFFFFFFF || seq == 0 ) /* Avoid both 'invalid' values */ seq = 1; - p->TscSequence = seq; + p->tsc_sequence = seq; } /* * The specification says: "The partition reference time is computed * by the following formula: * - * ReferenceTime = ((VirtualTsc * TscScale) >> 64) + TscOffset + * ReferenceTime = ((VirtualTsc * tsc_scale) >> 64) + tsc_offset * * The multiplication is a 64 bit multiplication, which results in a * 128 bit number which is then shifted 64 times to the right to obtain