Skip to content

Commit

Permalink
cpufreq / intel_pstate: Add function to check that all MSRs are valid
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dirk Brandewie authored and Rafael J. Wysocki committed Mar 25, 2013
1 parent 8bb9660 commit b563b4e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions drivers/cpufreq/intel_pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,29 @@ static struct cpufreq_driver intel_pstate_driver = {

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;
Expand All @@ -764,6 +787,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());
Expand Down

0 comments on commit b563b4e

Please sign in to comment.