[kernel] cpufreq/intel_pstate: Add function to check that all MSR's are valid (rhbz 922923)

Dave Jones davej at fedoraproject.org
Tue Mar 19 19:05:29 UTC 2013


commit 6f9fa1acc9d60aa1aadb0dc4a8d07fd4227f5a46
Author: Dave Jones <davej at redhat.com>
Date:   Tue Mar 19 15:05:22 2013 -0400

    cpufreq/intel_pstate: Add function to check that all MSR's are valid (rhbz 922923)

 cpufreq-intel-pstate-validate-msrs.patch |   56 ++++++++++++++++++++++++++++++
 kernel.spec                              |    8 ++++
 2 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/cpufreq-intel-pstate-validate-msrs.patch b/cpufreq-intel-pstate-validate-msrs.patch
new file mode 100644
index 0000000..0a790a0
--- /dev/null
+++ b/cpufreq-intel-pstate-validate-msrs.patch
@@ -0,0 +1,56 @@
+commit 866111646f2c5d4c6c25e2bb97f5c61c3992defb
+Author: Dirk Brandewie <dirk.brandewie at gmail.com>
+Date:   Mon Mar 18 16:55:02 2013 -0700
+
+    cpufreq/intel_pstate: Add function to check that all MSR's 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.
+    
+    Signed-off-by: Dirk Brandewie <dirk.brandewie at gmail.com>
+
+--- linux-3.9.0-0.rc3.git0.2.fc19.x86_64/drivers/cpufreq/intel_pstate.c~	2013-03-19 14:54:33.489581718 -0400
++++ linux-3.9.0-0.rc3.git0.2.fc19.x86_64/drivers/cpufreq/intel_pstate.c	2013-03-19 14:55:09.667523730 -0400
+@@ -752,6 +752,30 @@ static struct cpufreq_driver intel_pstat
+ 
+ static int __initdata no_load;
+ 
++static int intel_pstate_msrs_not_valid(void)
++{
++	/* Check that all the msr's we are using are valid. */
++	u64 aperf, mperf, tmp;
++
++	rdmsrl(MSR_IA32_APERF, aperf);
++	rdmsrl(MSR_IA32_MPERF, mperf);
++
++	if (!intel_pstate_min_pstate() ||
++		!intel_pstate_max_pstate() ||
++		!intel_pstate_turbo_pstate())
++		return -ENODEV;
++
++	rdmsrl(MSR_IA32_APERF, tmp);
++	if (!(tmp - aperf))
++		return -ENODEV;
++
++	rdmsrl(MSR_IA32_MPERF, tmp);
++	if (!(tmp - mperf))
++		return -ENODEV;
++
++	return 0;
++}
++
+ static int __init intel_pstate_init(void)
+ {
+ 	int cpu, rc = 0;
+@@ -764,6 +788,9 @@ static int __init intel_pstate_init(void
+ 	if (!id)
+ 		return -ENODEV;
+ 
++	if (intel_pstate_msrs_not_valid())
++		return -ENODEV;
++
+ 	pr_info("Intel P-state driver initializing.\n");
+ 
+ 	all_cpu_data = vmalloc(sizeof(void *) * num_possible_cpus());
diff --git a/kernel.spec b/kernel.spec
index 9ce9a94..59d3bd2 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -751,6 +751,8 @@ Patch22000: weird-root-dentry-name-debug.patch
 #selinux ptrace child permissions
 Patch22001: selinux-apply-different-permission-to-ptrace-child.patch
 
+Patch23000: cpufreq-intel-pstate-validate-msrs.patch
+
 # END OF PATCH DEFINITIONS
 
 %endif
@@ -1416,6 +1418,9 @@ ApplyPatch weird-root-dentry-name-debug.patch
 #selinux ptrace child permissions
 ApplyPatch selinux-apply-different-permission-to-ptrace-child.patch
 
+# rhbz 922923
+ApplyPatch cpufreq-intel-pstate-validate-msrs.patch
+
 #rhbz 859485
 ApplyPatch vt-Drop-K_OFF-for-VC_MUTE.patch
 
@@ -2285,6 +2290,9 @@ fi
 #                 ||----w |
 #                 ||     ||
 %changelog
+* Tue Mar 19 2013 Dave Jones <davej at redhat.com>
+- cpufreq/intel_pstate: Add function to check that all MSR's are valid (rhbz 922923)
+
 * Mon Mar 18 2013 Dave Jones <davej at redhat.com> - 3.9.0-0.rc3.git0.4
 - s390x config option changes from Dan HorĂ¡k <dan at danny.cz>
    - enable PCI


More information about the scm-commits mailing list