2021-11-04 05:22:14

by Srinivas Pandruvada

[permalink] [raw]
Subject: [PATCH] cpufreq: intel_pstate: Fix unchecked MSR 0x773 access

It is possible that on some platforms HWP interrupts are disabled. In
that case accessing MSR 0x773 will result in warning.

So check X86_FEATURE_HWP_NOTIFY feature to access MSR 0x773. The other
places in code where this MSR is accessed, already checks this feature
except during disable path called during cpufreq offline and suspend
callbacks.

Fixes: 57577c996d73 ("cpufreq: intel_pstate: Process HWP Guaranteed change notification")
Reported-by: Steven Rostedt <[email protected]>
Signed-off-by: Srinivas Pandruvada <[email protected]>
---
drivers/cpufreq/intel_pstate.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 349ddbaef796..1e6898dc76b6 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1620,6 +1620,9 @@ static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
{
unsigned long flags;

+ if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
+ return;
+
/* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */
wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);

--
2.31.1


2021-11-04 13:34:41

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: intel_pstate: Fix unchecked MSR 0x773 access

On Wed, 3 Nov 2021 22:19:25 -0700
Srinivas Pandruvada <[email protected]> wrote:

> It is possible that on some platforms HWP interrupts are disabled. In
> that case accessing MSR 0x773 will result in warning.
>
> So check X86_FEATURE_HWP_NOTIFY feature to access MSR 0x773. The other
> places in code where this MSR is accessed, already checks this feature
> except during disable path called during cpufreq offline and suspend
> callbacks.
>
> Fixes: 57577c996d73 ("cpufreq: intel_pstate: Process HWP Guaranteed change notification")
> Reported-by: Steven Rostedt <[email protected]>

I added this patch on top of the above commit and I verified that the issue
goes away. And just to confirm, I removed the patch, and the issue
reappeared.

Tested-by: Steven Rostedt (VMware) <[email protected]>

-- Steve


> Signed-off-by: Srinivas Pandruvada <[email protected]>
> ---
> drivers/cpufreq/intel_pstate.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 349ddbaef796..1e6898dc76b6 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1620,6 +1620,9 @@ static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
> {
> unsigned long flags;
>
> + if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
> + return;
> +
> /* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */
> wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);
>

2021-11-04 14:21:45

by Srinivas Pandruvada

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: intel_pstate: Fix unchecked MSR 0x773 access

On Thu, 2021-11-04 at 09:30 -0400, Steven Rostedt wrote:
> On Wed,  3 Nov 2021 22:19:25 -0700
> Srinivas Pandruvada <[email protected]> wrote:
>
> > It is possible that on some platforms HWP interrupts are disabled.
> > In
> > that case accessing MSR 0x773 will result in warning.
> >
> > So check X86_FEATURE_HWP_NOTIFY feature to access MSR 0x773. The
> > other
> > places in code where this MSR is accessed, already checks this
> > feature
> > except during disable path called during cpufreq offline and
> > suspend
> > callbacks.
> >
> > Fixes: 57577c996d73 ("cpufreq: intel_pstate: Process HWP Guaranteed
> > change notification")
> > Reported-by: Steven Rostedt <[email protected]>
>
> I added this patch on top of the above commit and I verified that the
> issue
> goes away. And just to confirm, I removed the patch, and the issue
> reappeared.
>
> Tested-by: Steven Rostedt (VMware) <[email protected]>
>
Thanks for the test.
Sorry again for the mess up.

-Srinivas

> -- Steve
>
>
> > Signed-off-by: Srinivas Pandruvada <
> > [email protected]>
> > ---
> >  drivers/cpufreq/intel_pstate.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/cpufreq/intel_pstate.c
> > b/drivers/cpufreq/intel_pstate.c
> > index 349ddbaef796..1e6898dc76b6 100644
> > --- a/drivers/cpufreq/intel_pstate.c
> > +++ b/drivers/cpufreq/intel_pstate.c
> > @@ -1620,6 +1620,9 @@ static void
> > intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
> >  {
> >         unsigned long flags;
> >  
> > +       if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
> > +               return;
> > +
> >         /* wrmsrl_on_cpu has to be outside spinlock as this can
> > result in IPC */
> >         wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);
> >  
>


2021-11-04 18:54:08

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: intel_pstate: Fix unchecked MSR 0x773 access

On Thu, Nov 4, 2021 at 3:17 PM Srinivas Pandruvada
<[email protected]> wrote:
>
> On Thu, 2021-11-04 at 09:30 -0400, Steven Rostedt wrote:
> > On Wed, 3 Nov 2021 22:19:25 -0700
> > Srinivas Pandruvada <[email protected]> wrote:
> >
> > > It is possible that on some platforms HWP interrupts are disabled.
> > > In
> > > that case accessing MSR 0x773 will result in warning.
> > >
> > > So check X86_FEATURE_HWP_NOTIFY feature to access MSR 0x773. The
> > > other
> > > places in code where this MSR is accessed, already checks this
> > > feature
> > > except during disable path called during cpufreq offline and
> > > suspend
> > > callbacks.
> > >
> > > Fixes: 57577c996d73 ("cpufreq: intel_pstate: Process HWP Guaranteed
> > > change notification")
> > > Reported-by: Steven Rostedt <[email protected]>
> >
> > I added this patch on top of the above commit and I verified that the
> > issue
> > goes away. And just to confirm, I removed the patch, and the issue
> > reappeared.
> >
> > Tested-by: Steven Rostedt (VMware) <[email protected]>
> >
> Thanks for the test.
> Sorry again for the mess up.
>
> -Srinivas
>
> > -- Steve
> >
> >
> > > Signed-off-by: Srinivas Pandruvada <
> > > [email protected]>
> > > ---
> > > drivers/cpufreq/intel_pstate.c | 3 +++
> > > 1 file changed, 3 insertions(+)
> > >
> > > diff --git a/drivers/cpufreq/intel_pstate.c
> > > b/drivers/cpufreq/intel_pstate.c
> > > index 349ddbaef796..1e6898dc76b6 100644
> > > --- a/drivers/cpufreq/intel_pstate.c
> > > +++ b/drivers/cpufreq/intel_pstate.c
> > > @@ -1620,6 +1620,9 @@ static void
> > > intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
> > > {
> > > unsigned long flags;
> > >
> > > + if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
> > > + return;
> > > +
> > > /* wrmsrl_on_cpu has to be outside spinlock as this can
> > > result in IPC */
> > > wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);
> > >

Applied as 5.16-rc material, thanks!