x86/hyperv: Check frequency MSRs presence according to the specification
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 22 Jun 2017 10:07:29 +0000 (18:07 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 22 Jun 2017 13:35:11 +0000 (15:35 +0200)
Hyper-V TLFS specifies two bits which should be checked before accessing
frequency MSRs:

- AccessFrequencyMsrs (BIT(11) in EAX) which indicates if we have access to
  frequency MSRs.
- FrequencyMsrsAvailable (BIT(8) in EDX) which indicates is these MSRs are
  present.

Rename and specify these bits accordingly.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Ladi Prosek <lprosek@redhat.com>
Cc: Jork Loeser <jloeser@microsoft.com>
Cc: devel@linuxdriverproject.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Link: http://lkml.kernel.org/r/20170622100730.18112-2-vkuznets@redhat.com
arch/x86/include/uapi/asm/hyperv.h
arch/x86/kernel/cpu/mshyperv.c

index 432df4b1baecc59162d69f6307383d46166e1cb7..f4fef5a24ebd15782c240f84394ac896c7f33c7b 100644 (file)
 #define HV_X64_MSR_REFERENCE_TSC               0x40000021
 
 /*
- * There is a single feature flag that signifies the presence of the MSR
- * that can be used to retrieve both the local APIC Timer frequency as
- * well as the TSC frequency.
+ * There is a single feature flag that signifies if the partition has access
+ * to MSRs with local APIC and TSC frequencies.
  */
-
-/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is available */
-#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11)
-
-/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */
-#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11)
+#define HV_X64_ACCESS_FREQUENCY_MSRS           (1 << 11)
 
 /*
  * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
@@ -73,6 +67,9 @@
   */
 #define HV_X64_MSR_STAT_PAGES_AVAILABLE                (1 << 8)
 
+/* Frequency MSRs available */
+#define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE    (1 << 8)
+
 /* Crash MSR available */
 #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE (1 << 10)
 
index 04cb8d34ccb803ae4a788b4d313c522e23118380..3563c8e6c01404559391976e37ba7921fa571ab2 100644 (file)
@@ -194,7 +194,8 @@ static void __init ms_hyperv_init_platform(void)
        }
 
 #ifdef CONFIG_X86_LOCAL_APIC
-       if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
+       if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS &&
+           ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) {
                /*
                 * Get the APIC frequency.
                 */