Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE
@ 2026-07-20 18:47 Rong Zhang
  2026-07-20 19:01 ` Mario Limonciello
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rong Zhang @ 2026-07-20 18:47 UTC (permalink / raw)
  To: Huang Rui, Mario Limonciello, Perry Yuan, K Prateek Nayak,
	Rafael J. Wysocki, Viresh Kumar, Borislav Petkov, Jason Andryuk
  Cc: Michael Kelley, Michael Kelley, linux-pm, linux-kernel,
	Rong Zhang

When booting a VM that simulates or passes-through a relatively new CPU
model, these 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 incorrect, as the CPPC feature is neither supported in a
VM nor disabled by the VM's BIOS.

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.

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.

Fixes: cb817ec6673b ("cpufreq: amd-pstate: show CPPC debug message if CPPC is not supported")
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Rong Zhang <i@rong.moe>
---
Changes in v3:
- Move the check into amd_cppc_supported() and add a pr_debug_once()
  message (thanks K Prateek Nayak and Mario Limonciello)
  - The check is added before the existing family 17h model 0h-2Fh one,
    as print_cpu_info() already shows family, model, and stepping, and
    will help debugging even if the new check overrides the existing
    one, but not vice versa
- Link to v2: https://patch.msgid.link/20260718-amd-pstate-vm-v2-1-6ed5f3b2c89e@rong.moe

Changes in v2:
- Check for X86_FEATURE_HW_PSTATE instead of X86_FEATURE_HYPERVISOR
  (thanks K Prateek Nayak)
- Remove the check against Xen dom0, as it doesn't need the amd-pstate
  driver (thanks Jason Andryuk)
- Reword comments and the commit message
- Remove Gautham R. Shenoy from the To list due to email bounces
- Link to v1: https://patch.msgid.link/20260716-amd-pstate-vm-v1-1-2ac97d3cf6e7@rong.moe
---
 drivers/cpufreq/amd-pstate.c | 6 ++++++
 1 file changed, 6 insertions(+)

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");
+		return false;
+	}
+
 	if ((boot_cpu_data.x86 == 0x17) && (boot_cpu_data.x86_model < 0x30)) {
 		pr_debug_once("CPPC feature is not supported by the processor\n");
 		return false;

---
base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
change-id: 1cc24037-amd-pstate-vm-d6ab4c959bd3

Thanks,
Rong


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE
  2026-07-20 18:47 [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE Rong Zhang
@ 2026-07-20 19:01 ` Mario Limonciello
  2026-07-21  5:16 ` K Prateek Nayak
  2026-07-21  6:10 ` Borislav Petkov
  2 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2026-07-20 19:01 UTC (permalink / raw)
  To: Rong Zhang, Huang Rui, Perry Yuan, K Prateek Nayak,
	Rafael J. Wysocki, Viresh Kumar, Borislav Petkov, Jason Andryuk
  Cc: Michael Kelley, Michael Kelley, linux-pm, linux-kernel



On 7/20/26 13:47, Rong Zhang wrote:
> When booting a VM that simulates or passes-through a relatively new CPU
> model, these 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 incorrect, as the CPPC feature is neither supported in a
> VM nor disabled by the VM's BIOS.
> 
> 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.
> 
> 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.
> 
> Fixes: cb817ec6673b ("cpufreq: amd-pstate: show CPPC debug message if CPPC is not supported")
> Reviewed-by: Michael Kelley <mhklinux@outlook.com>
> Tested-by: Michael Kelley <mhklinux@outlook.com>
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
Acked-by: Mario Limonciello (AMD) <superm1@kernel.org>

I'll get this picked up this week.

> Changes in v3:
> - Move the check into amd_cppc_supported() and add a pr_debug_once()
>    message (thanks K Prateek Nayak and Mario Limonciello)
>    - The check is added before the existing family 17h model 0h-2Fh one,
>      as print_cpu_info() already shows family, model, and stepping, and
>      will help debugging even if the new check overrides the existing
>      one, but not vice versa
> - Link to v2: https://patch.msgid.link/20260718-amd-pstate-vm-v2-1-6ed5f3b2c89e@rong.moe
> 
> Changes in v2:
> - Check for X86_FEATURE_HW_PSTATE instead of X86_FEATURE_HYPERVISOR
>    (thanks K Prateek Nayak)
> - Remove the check against Xen dom0, as it doesn't need the amd-pstate
>    driver (thanks Jason Andryuk)
> - Reword comments and the commit message
> - Remove Gautham R. Shenoy from the To list due to email bounces
> - Link to v1: https://patch.msgid.link/20260716-amd-pstate-vm-v1-1-2ac97d3cf6e7@rong.moe
> ---
>   drivers/cpufreq/amd-pstate.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> 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");
> +		return false;
> +	}
> +
>   	if ((boot_cpu_data.x86 == 0x17) && (boot_cpu_data.x86_model < 0x30)) {
>   		pr_debug_once("CPPC feature is not supported by the processor\n");
>   		return false;
> 
> ---
> base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
> change-id: 1cc24037-amd-pstate-vm-d6ab4c959bd3
> 
> Thanks,
> Rong
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE
  2026-07-20 18:47 [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE Rong Zhang
  2026-07-20 19:01 ` Mario Limonciello
@ 2026-07-21  5:16 ` K Prateek Nayak
  2026-07-21  6:10 ` Borislav Petkov
  2 siblings, 0 replies; 4+ messages in thread
From: K Prateek Nayak @ 2026-07-21  5:16 UTC (permalink / raw)
  To: Rong Zhang, Huang Rui, Mario Limonciello, Perry Yuan,
	Rafael J. Wysocki, Viresh Kumar, Borislav Petkov, Jason Andryuk
  Cc: Michael Kelley, Michael Kelley, linux-pm, linux-kernel

Hello Rong,

On 7/21/2026 12:17 AM, Rong Zhang wrote:
> When booting a VM that simulates or passes-through a relatively new CPU
> model, these 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 incorrect, as the CPPC feature is neither supported in a
> VM nor disabled by the VM's BIOS.
> 
> 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.
> 
> 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.
> 
> Fixes: cb817ec6673b ("cpufreq: amd-pstate: show CPPC debug message if CPPC is not supported")
> Reviewed-by: Michael Kelley <mhklinux@outlook.com>
> Tested-by: Michael Kelley <mhklinux@outlook.com>
> Signed-off-by: Rong Zhang <i@rong.moe>

Thank you for your patience! Feel free to include:

Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>

-- 
Thanks and Regards,
Prateek


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE
  2026-07-20 18:47 [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE Rong Zhang
  2026-07-20 19:01 ` Mario Limonciello
  2026-07-21  5:16 ` K Prateek Nayak
@ 2026-07-21  6:10 ` Borislav Petkov
  2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2026-07-21  6:10 UTC (permalink / raw)
  To: Rong Zhang
  Cc: Huang Rui, Mario Limonciello, Perry Yuan, K Prateek Nayak,
	Rafael J. Wysocki, Viresh Kumar, Jason Andryuk, Michael Kelley,
	Michael Kelley, linux-pm, linux-kernel

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@alien8.de>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-21  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 18:47 [PATCH v3] cpufreq/amd-pstate: Bail out early if !X86_FEATURE_HW_PSTATE Rong Zhang
2026-07-20 19:01 ` Mario Limonciello
2026-07-21  5:16 ` K Prateek Nayak
2026-07-21  6:10 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox