Re: [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE

From: Borislav Petkov

Date: Tue Jul 21 2026 - 02:11:08 EST


On Tue, Jul 21, 2026 at 02:47:22AM +0800, Rong Zhang wrote:
> The CPPC feature is disabled by the hypervisor as it makes no sense to
> expose them to guests. It creates a paradox that the same kernel both
> disables CPPC as a hypervisor (KVM) and warns about it being disabled
> as a guest.

There's no paradox - the same kernel can be a guest or a hypervisor. Just drop
this silly paragraph.

> X86_FEATURE_HW_PSTATE indicates if the processor supports frequency
> scaling or not. It is disabled on virtualized platforms (namely, KVM and
> Hyper-V have been reported to do so) and is always set on physical
> platforms that support frequency scaling.
>
> Check for X86_FEATURE_HW_PSTATE as a prerequisite and bail out early if
> it's unsupported. A debug message is also added to help debug driver
> loading issues.

You don't need to explain the patch - that is visible from the diff...
hopefully.

> Fixes: cb817ec6673b ("cpufreq: amd-pstate: show CPPC debug message if CPPC is not supported")

Fixes, schmixes. The only thing this patch "fixes" is some silly annoyance
about a print getting issued in a guest. You can boot randconfig builds as
a guest and see all kinds of messages getting issued because the HV doesn't
emulate the hardware. Are you going to whack-a-mole them too?

Pff.

> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index a74a4cf99d22..b0b651380732 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -2167,6 +2167,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
> };
>
> /*
> + * Processors without frequency scaling support can't do CPPC.
> * CPPC function is not supported for family ID 17H with model_ID ranging from 0x10 to 0x2F.
> * show the debug message that helps to check if the CPU has CPPC support for loading issue.
> */
> @@ -2175,6 +2176,11 @@ static bool amd_cppc_supported(void)
> struct cpuinfo_x86 *c = &cpu_data(0);
> bool warn = false;
>
> + if (!cpu_feature_enabled(X86_FEATURE_HW_PSTATE)) {
> + pr_debug_once("frequency scaling is not supported by the processor\n");

So now you have a second print here. Who is going to fix that one?! /facepalm.

> + return false;
> + }

In any case:

Acked-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>

but only after the commit message sensation-seeking is tamed into what this
really does.

Lemme try with a one-liner in the title and commit message:

"cpufreq/amd-pstate: Prevent the driver from loading on unsupported hardware

... this check also prevents the driver from loading in guests and thus not
confuse users with misleading prints."

That's it - no need to overengineer it.

HTH.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette