* [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access
@ 2024-05-31 23:00 Srinivas Pandruvada
2024-06-03 16:03 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2024-05-31 23:00 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, Srinivas Pandruvada, Sebastian Andrzej Siewior
Fix unchecked MSR access error for processors with no HWP support. On
such processors, maximum frequency can be changed by the system firmware
using ACPI event ACPI_PROCESSOR_NOTIFY_HIGEST_PERF_CHANGED. This results
in accessing HWP MSR 0x771.
Call Trace:
<TASK>
generic_exec_single+0x58/0x120
smp_call_function_single+0xbf/0x110
rdmsrl_on_cpu+0x46/0x60
intel_pstate_get_hwp_cap+0x1b/0x70
intel_pstate_update_limits+0x2a/0x60
acpi_processor_notify+0xb7/0x140
acpi_ev_notify_dispatch+0x3b/0x60
HWP MSR 0x771 can be only read on a CPU which supports HWP and enabled.
Hence intel_pstate_get_hwp_cap() can only be called when hwp_active is
true.
Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Closes: https://lore.kernel.org/linux-pm/20240529155740.Hq2Hw7be@linutronix.de/
Fixes: e8217b4bece3 ("cpufreq: intel_pstate: Update the maximum CPU frequency consistently")
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 4b986c044741..65d3f79104bd 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1153,7 +1153,8 @@ static void intel_pstate_update_policies(void)
static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
struct cpufreq_policy *policy)
{
- intel_pstate_get_hwp_cap(cpudata);
+ if (hwp_active)
+ intel_pstate_get_hwp_cap(cpudata);
policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access
2024-05-31 23:00 [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access Srinivas Pandruvada
@ 2024-06-03 16:03 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2024-06-03 16:03 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, viresh.kumar, linux-pm, linux-kernel, Sebastian Andrzej Siewior
On Sat, Jun 1, 2024 at 1:00 AM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> Fix unchecked MSR access error for processors with no HWP support. On
> such processors, maximum frequency can be changed by the system firmware
> using ACPI event ACPI_PROCESSOR_NOTIFY_HIGEST_PERF_CHANGED. This results
> in accessing HWP MSR 0x771.
>
> Call Trace:
> <TASK>
> generic_exec_single+0x58/0x120
> smp_call_function_single+0xbf/0x110
> rdmsrl_on_cpu+0x46/0x60
> intel_pstate_get_hwp_cap+0x1b/0x70
> intel_pstate_update_limits+0x2a/0x60
> acpi_processor_notify+0xb7/0x140
> acpi_ev_notify_dispatch+0x3b/0x60
>
> HWP MSR 0x771 can be only read on a CPU which supports HWP and enabled.
> Hence intel_pstate_get_hwp_cap() can only be called when hwp_active is
> true.
>
> Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Closes: https://lore.kernel.org/linux-pm/20240529155740.Hq2Hw7be@linutronix.de/
> Fixes: e8217b4bece3 ("cpufreq: intel_pstate: Update the maximum CPU frequency consistently")
> Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> drivers/cpufreq/intel_pstate.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 4b986c044741..65d3f79104bd 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1153,7 +1153,8 @@ static void intel_pstate_update_policies(void)
> static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
> struct cpufreq_policy *policy)
> {
> - intel_pstate_get_hwp_cap(cpudata);
> + if (hwp_active)
> + intel_pstate_get_hwp_cap(cpudata);
>
> policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
> cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
> --
Applied as 6.10-rc material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-03 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-31 23:00 [PATCH] cpufreq: intel_pstate: Fix unchecked HWP MSR access Srinivas Pandruvada
2024-06-03 16:03 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®