Re: [PATCH] cpufreq/amd-pstate: Bail out early in virtual machines and don't warn

From: Rong Zhang

Date: Thu Jul 16 2026 - 14:36:06 EST


Hi K Prateek,

Thanks for reviewing this.

On Thu, 2026-07-16 at 23:30 +0530, K Prateek Nayak wrote:
> Hello Rong,
>
> On 7/15/2026 11:11 PM, Rong Zhang wrote:
> > When booting a virtual machine that simulates or passes-through a
> > relatively new CPUID, one or two warning messages are printed to kmsg:
> >
> > amd_pstate: The CPPC feature is supported but currently disabled by the BIOS.
> > Please enable it if your BIOS has the CPPC option.
> > amd_pstate: the _CPC object is not present in SBIOS or ACPI disabled
> >
> > Technically the check is not wrong and acts as a safetynet that prevents
> > the driver from being registered incorrectly, but the warning messages
> > are noisy and not really helpful, as virtual machines cannot adjust the
> > CPU frequency from the very beginning. Moreover, mentioning BIOS here
> > makes the messages even more confusing.
> >
> > Fix it by bailing out early when running in virtual machines (excluding
> > Xen Dom0).
> >
> > Fixes: cb817ec6673b ("cpufreq: amd-pstate: show CPPC debug message if CPPC is not supported")
> > Signed-off-by: Rong Zhang <i@xxxxxxxx>
> > ---
> > drivers/cpufreq/amd-pstate.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > index a74a4cf99d22..f2115f935318 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -2228,6 +2228,9 @@ static int __init amd_pstate_init(void)
> > if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
> > return -ENODEV;
> >
> > + if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR) && !xen_initial_domain())
> > + return -ENODEV;
> > +
>
> I think, instead of this, you can just check for X86_FEATURE_HW_PSTATE.
>
> Using check_amd_hwpstate_cpu() from drivers/cpufreq/acpi-cpufreq.c
> here should be sufficient to know if the platform supports frequency
> scaling or not.
>
> If it does and _CPC object is missing, there is a good chance CPPC is
> disabled in BIOS.

Thanks a lot for your suggestion! It makes a lot of sense to me and
sounds promising. I will try the approach in v2.

>
> KVM doesn't expose X86_FEATURE_HW_PSTATE to guest. I'm not sure if
> Xen does.

As Jason said:

With Xen, the Xen hypervisor itself controls CPPC. dom0
(xen_initial_domain()) doesn't need the amd-pstate driver.

I think we don't need to worry about Xen.

@Michael, if you have the time, could you test if Hyper-V exposes
X86_FEATURE_HW_PSTATE (i.e., 0x80000007/edx bit 7)?

Thanks,
Rong

>
> > /* show debug message only if CPPC is not supported */
> > if (!amd_cppc_supported())
> > return -EOPNOTSUPP;