[PATCH v14 02/24] x86/resctrl: Check if monitoring features are supported

From: Tony Luck

Date: Mon Oct 19 2026 - 16:54:14 EST


Both Intel and AMD manuals say that software must first check
CPUID(0x7,0x0).EBX[12] (X86_FEATURE_CQM) to see if any resource monitoring
features are supported before checking for resource specific features
supported in subleaves. The L3 resource monitoring features are further gated
by CPUID(0xF,0x0).EDX[1] (X86_FEATURE_CQM_LLC).

resctrl enables L3 monitoring based only on the individual monitoring
features. It can thus enable L3 monitoring on a system that does not report
support for resource monitoring.

Do not enable L3 monitoring unless both X86_FEATURE_CQM and X86_FEATURE_CQM_LLC
are supported. This also applies to assignable counters, which rely on the
RMID count and scale enumerated in CPUID leaf 0xF.

Fixes: cbc82b172638 ("x86: Add support for Intel Cache QoS Monitoring (CQM) detection")
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
Reviewed-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Tested-by: Tested-by: Chen Yu <yu.c.chen@xxxxxxxxx>
---
v14:
Maintainer note: No need to backport this fix. No issues have been seen
from this failure to follow the exact enumeration process in the manual.

Move maintainer note after the "---"
Put the X86_FEATURE_* parenthetical comments back (without "Linux")
s/monitoring features/resource monitoring features/g
Add Reinette RB tag
Add problem paragraph between context and solution.
Add Chen Yu Tested-by tag
---
arch/x86/kernel/cpu/resctrl/core.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 55214d6fdc49..34ca3c7cc046 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -968,6 +968,14 @@ static __init bool get_rdt_mon_resources(void)
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
bool ret = false;

+ /* Any monitoring at all? */
+ if (!cpu_feature_enabled(X86_FEATURE_CQM))
+ return false;
+
+ /* Any of the L3 monitoring features? */
+ if (!cpu_feature_enabled(X86_FEATURE_CQM_LLC))
+ return false;
+
if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) {
resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL);
ret = true;
--
2.56.0