Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq / intel_pstate: Add function to check that all MSRs are valid

Some VMs seem to try to implement some MSRs but not all the registers
the driver needs. Check to make sure all the MSR that we need are
available. If any of the required MSRs are not available refuse to
load.

References: https://bugzilla.redhat.com/show_bug.cgi?id=922923
Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Dirk Brandewie and committed by
Rafael J. Wysocki
b563b4e3 8bb96604

+26
+26
drivers/cpufreq/intel_pstate.c
··· 752 752 753 753 static int __initdata no_load; 754 754 755 + static int intel_pstate_msrs_not_valid(void) 756 + { 757 + /* Check that all the msr's we are using are valid. */ 758 + u64 aperf, mperf, tmp; 759 + 760 + rdmsrl(MSR_IA32_APERF, aperf); 761 + rdmsrl(MSR_IA32_MPERF, mperf); 762 + 763 + if (!intel_pstate_min_pstate() || 764 + !intel_pstate_max_pstate() || 765 + !intel_pstate_turbo_pstate()) 766 + return -ENODEV; 767 + 768 + rdmsrl(MSR_IA32_APERF, tmp); 769 + if (!(tmp - aperf)) 770 + return -ENODEV; 771 + 772 + rdmsrl(MSR_IA32_MPERF, tmp); 773 + if (!(tmp - mperf)) 774 + return -ENODEV; 775 + 776 + return 0; 777 + } 755 778 static int __init intel_pstate_init(void) 756 779 { 757 780 int cpu, rc = 0; ··· 785 762 786 763 id = x86_match_cpu(intel_pstate_cpu_ids); 787 764 if (!id) 765 + return -ENODEV; 766 + 767 + if (intel_pstate_msrs_not_valid()) 788 768 return -ENODEV; 789 769 790 770 pr_info("Intel P-state driver initializing.\n");