Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp372868ybc; Tue, 12 Nov 2019 02:51:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzEB8bki6ATLGBGgzIhsm+JaKYrzcYI13I49eaNe8hs5ohHsZe2vxfZ6OmjUk25/lYt0501 X-Received: by 2002:a17:906:1be9:: with SMTP id t9mr27590284ejg.10.1573555892126; Tue, 12 Nov 2019 02:51:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573555892; cv=none; d=google.com; s=arc-20160816; b=gl4dcH2hZtd7uy0dyOki8cbGoYfJ5Aj4lwXq1sQOCQghCS96rWNUwYvlx0eLrwbhKD auG732ZlFbGhPaX8I4A/cW0rf4udspcSfF6UYeMGSauhdTeTIF1tWT/4HEsTzMpNczfV oU/NJg9rUFNExDXxUzV0i68P0GnF6UE87bxt3J61lyxw4ZTUow2DgCLTYWeNL6kaIVWX FOQxB5Y7rZ4qNSunt5FHm9L/AlTBVKD6T8fL7fnOrZh/lXXz8XUwxwK7jHHCWLxNF3MT 1NlWEHi2ldxgdVwk9IlI3FBulB6UT9PjzepR0ssvYTDX3drVfHitWvsVddDcNYZbyYBI DNGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=ti3bBvAkS5P0fynvqxQDUh1kGYgc6L8GpFZVS7zHnsE=; b=WwVoFeNiA3ez2pbt2BRG/bRXmJBKFLf5wMFJGmA3RdyFitPKHksFroqrLtwTxXdJJS ZePHI60uywy1qkxs3E50kNaVfSM5JXLY0ps9TKylYvtjgEjAo8Q1JuZwzppl8kncQfcx zkU40n+9VZGW3+mXxwJnsfCnanfyaH3W8rQTyWKe3fO2VKUcEz9ypCsSS9QvnOhAWV// MMw62DMTI090dQlDPGKuL62sZNQJ6X++wo7wFxc8tW5764e0VHegI71x0620dd2Sbkee gJXnoichdWCicc+o8YmGtAW73MXjEx6GF2Msuk9P+bhjZeTQWIVqJ3qFHOjUQlhRqWCG +aDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si6990441ede.45.2019.11.12.02.51.07; Tue, 12 Nov 2019 02:51:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbfKLKuL (ORCPT + 99 others); Tue, 12 Nov 2019 05:50:11 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:33275 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbfKLKuK (ORCPT ); Tue, 12 Nov 2019 05:50:10 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iUTkI-0008AW-S1; Tue, 12 Nov 2019 11:50:03 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 7B8141C0084; Tue, 12 Nov 2019 11:50:02 +0100 (CET) Date: Tue, 12 Nov 2019 10:50:02 -0000 From: "tip-bot2 for Andrea Parri" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/hyperv] x86/hyperv: Allow guests to enable InvariantTSC Cc: Andrea Parri , Thomas Gleixner , Michael Kelley , Vitaly Kuznetsov , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191003155200.22022-1-parri.andrea@gmail.com> References: <20191003155200.22022-1-parri.andrea@gmail.com> MIME-Version: 1.0 Message-ID: <157355580216.29376.5207364580446998985.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/hyperv branch of tip: Commit-ID: dce7cd62754b5d4a6e401b8b0769ec94cf971041 Gitweb: https://git.kernel.org/tip/dce7cd62754b5d4a6e401b8b0769ec94cf971041 Author: Andrea Parri AuthorDate: Thu, 03 Oct 2019 17:52:00 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 12 Nov 2019 11:44:21 +01:00 x86/hyperv: Allow guests to enable InvariantTSC If the hardware supports TSC scaling, Hyper-V will set bit 15 of the HV_PARTITION_PRIVILEGE_MASK in guest VMs with a compatible Hyper-V configuration version. Bit 15 corresponds to the AccessTscInvariantControls privilege. If this privilege bit is set, guests can access the HvSyntheticInvariantTscControl MSR: guests can set bit 0 of this synthetic MSR to enable the InvariantTSC feature. After setting the synthetic MSR, CPUID will enumerate support for InvariantTSC. Signed-off-by: Andrea Parri Signed-off-by: Thomas Gleixner Reviewed-by: Michael Kelley Reviewed-by: Vitaly Kuznetsov Link: https://lkml.kernel.org/r/20191003155200.22022-1-parri.andrea@gmail.com --- arch/x86/include/asm/hyperv-tlfs.h | 5 +++++ arch/x86/kernel/cpu/mshyperv.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 7a27056..887b1d6 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -86,6 +86,8 @@ #define HV_X64_ACCESS_FREQUENCY_MSRS BIT(11) /* AccessReenlightenmentControls privilege */ #define HV_X64_ACCESS_REENLIGHTENMENT BIT(13) +/* AccessTscInvariantControls privilege */ +#define HV_X64_ACCESS_TSC_INVARIANT BIT(15) /* * Feature identification: indicates which flags were specified at partition @@ -270,6 +272,9 @@ #define HV_X64_MSR_TSC_EMULATION_CONTROL 0x40000107 #define HV_X64_MSR_TSC_EMULATION_STATUS 0x40000108 +/* TSC invariant control */ +#define HV_X64_MSR_TSC_INVARIANT_CONTROL 0x40000118 + /* * Declare the MSR used to setup pages used to communicate with the hypervisor. */ diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 062f772..6f7c822 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -285,7 +285,12 @@ static void __init ms_hyperv_init_platform(void) machine_ops.shutdown = hv_machine_shutdown; machine_ops.crash_shutdown = hv_machine_crash_shutdown; #endif - mark_tsc_unstable("running on Hyper-V"); + if (ms_hyperv.features & HV_X64_ACCESS_TSC_INVARIANT) { + wrmsrl(HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x1); + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); + } else { + mark_tsc_unstable("running on Hyper-V"); + } /* * Generation 2 instances don't support reading the NMI status from