platform/x86: intel-uncore-freq: Prevent driver loading in guests
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Wed, 27 Apr 2022 10:03:04 +0000 (03:03 -0700)
committerHans de Goede <hdegoede@redhat.com>
Wed, 27 Apr 2022 14:55:54 +0000 (16:55 +0200)
Loading this driver in guests results in unchecked MSR access error for
MSR 0x620.

There is no use of reading and modifying package/die scope uncore MSRs
in guests. So check for CPU feature X86_FEATURE_HYPERVISOR to prevent
loading of this driver in guests.

Fixes: dbce412a7733 ("platform/x86/intel-uncore-freq: Split common and enumeration part")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215870
Suggested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20220427100304.2562990-1-srinivas.pandruvada@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c

index c61f804dd44e820ac65563517b5f1a1a2d02a685..8f9c571d725789ecd4f3e47388b7f86dcdfef403 100644 (file)
@@ -212,6 +212,9 @@ static int __init intel_uncore_init(void)
        const struct x86_cpu_id *id;
        int ret;
 
+       if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
+               return -ENODEV;
+
        id = x86_match_cpu(intel_uncore_cpu_ids);
        if (!id)
                return -ENODEV;