From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753550AbdFVNmL (ORCPT ); Thu, 22 Jun 2017 09:42:11 -0400 Received: from terminus.zytor.com ([65.50.211.136]:43491 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbdFVNmH (ORCPT ); Thu, 22 Jun 2017 09:42:07 -0400 Date: Thu, 22 Jun 2017 06:40:56 -0700 From: tip-bot for Vitaly Kuznetsov Message-ID: Cc: mingo@kernel.org, jloeser@microsoft.com, hpa@zytor.com, haiyangz@microsoft.com, sthemmin@microsoft.com, vkuznets@redhat.com, kys@microsoft.com, lprosek@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: lprosek@redhat.com, kys@microsoft.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, jloeser@microsoft.com, mingo@kernel.org, haiyangz@microsoft.com, vkuznets@redhat.com, sthemmin@microsoft.com In-Reply-To: <20170622100730.18112-3-vkuznets@redhat.com> References: <20170622100730.18112-3-vkuznets@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/hyperv] x86/hyperv: Read TSC frequency from a synthetic MSR Git-Commit-ID: 71c2a2d0a81f096a2932fccb39a500116fece554 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 71c2a2d0a81f096a2932fccb39a500116fece554 Gitweb: http://git.kernel.org/tip/71c2a2d0a81f096a2932fccb39a500116fece554 Author: Vitaly Kuznetsov AuthorDate: Thu, 22 Jun 2017 18:07:30 +0800 Committer: Thomas Gleixner CommitDate: Thu, 22 Jun 2017 15:35:12 +0200 x86/hyperv: Read TSC frequency from a synthetic MSR It was found that SMI_TRESHOLD of 50000 is not enough for Hyper-V guests in nested environment and falling back to counting jiffies is not an option for Gen2 guests as they don't have PIT. As Hyper-V provides TSC frequency in a synthetic MSR we can just use this information instead of doing a error prone calibration. Reported-and-tested-by: Ladi Prosek Signed-off-by: Vitaly Kuznetsov Signed-off-by: Thomas Gleixner Cc: Stephen Hemminger Cc: Haiyang Zhang Cc: Jork Loeser Cc: devel@linuxdriverproject.org Cc: "K. Y. Srinivasan" Link: http://lkml.kernel.org/r/20170622100730.18112-3-vkuznets@redhat.com --- arch/x86/kernel/cpu/mshyperv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 3563c8e..70e717f 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -161,6 +161,15 @@ static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs) } #endif +static unsigned long hv_get_tsc_khz(void) +{ + unsigned long freq; + + rdmsrl(HV_X64_MSR_TSC_FREQUENCY, freq); + + return freq / 1000; +} + static void __init ms_hyperv_init_platform(void) { int hv_host_info_eax; @@ -193,6 +202,12 @@ static void __init ms_hyperv_init_platform(void) hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF); } + if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS && + ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) { + x86_platform.calibrate_tsc = hv_get_tsc_khz; + x86_platform.calibrate_cpu = hv_get_tsc_khz; + } + #ifdef CONFIG_X86_LOCAL_APIC if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS && ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {