[PATCH v10 10/12] x86/resctrl: Introduce erdt_cpu_has() and erdt_support()

From: Chen Yu

Date: Thu Nov 05 2026 - 05:51:25 EST


Introduce erdt_cpu_has() to verify if a specific RDT feature is backed by an
ERDT table. A feature is only reported as ERDT backed when the CPU enumerates it
via CPUID and firmware describes it in the ERDT table (and its sub-tables).
erdt_cpu_has() also considers userspace input like "rdt=!cmt". Similar to
rdt_cpu_has(), erdt_cpu_has() expects an x86 feature flag as parameter.

Introduce erdt_support() as a helper called by erdt_cpu_has() to check whether
the ERDT firmware supports a given feature.

erdt_support() deliberately claims no feature yet and returns false. Features
should be added to erdt_support() as their MMIO implementations are introduced.

Suggested-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
Tested-by: Hongyu Ning <hongyu.ning@xxxxxxxxxxxxxxx>
---
Changes since v9:
- Drop the erdt_get_scale() context: the ERDT scale is now introduced
after this patch by "x86/resctrl: Add the ERDT CMT scale". No code
change. (Reinette Chatre)

arch/x86/kernel/cpu/resctrl/core.c | 13 +++++++++++--
arch/x86/kernel/cpu/resctrl/erdt.c | 5 +++++
arch/x86/kernel/cpu/resctrl/internal.h | 2 ++
3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index a2b012c94680..c71d6626c330 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -873,9 +873,8 @@ static int __init set_rdt_options(char *str)
}
__setup("rdt", set_rdt_options);

-bool rdt_cpu_has(int flag)
+static bool apply_rdt_options(int flag, bool ret)
{
- bool ret = boot_cpu_has(flag);
struct rdt_options *o;

if (!ret)
@@ -893,6 +892,16 @@ bool rdt_cpu_has(int flag)
return ret;
}

+bool rdt_cpu_has(int flag)
+{
+ return apply_rdt_options(flag, boot_cpu_has(flag));
+}
+
+bool erdt_cpu_has(int flag)
+{
+ return apply_rdt_options(flag, boot_cpu_has(flag) && erdt_support(flag));
+}
+
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
{
if (!rdt_cpu_has(X86_FEATURE_BMEC))
diff --git a/arch/x86/kernel/cpu/resctrl/erdt.c b/arch/x86/kernel/cpu/resctrl/erdt.c
index ef7f51fde838..107d599bf586 100644
--- a/arch/x86/kernel/cpu/resctrl/erdt.c
+++ b/arch/x86/kernel/cpu/resctrl/erdt.c
@@ -36,6 +36,11 @@ static u16 first_rmdd_domain_id;
/* Largest RMID that is valid in every ERDT domain. */
static unsigned int erdt_max_rmid;

+bool erdt_support(int flag)
+{
+ return false;
+}
+
static void __iomem *erdt_ioremap(resource_size_t base, u32 num_pages, const char *desc)
{
void __iomem *addr;
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 527e3ac91b26..fe8a4c1dd46b 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -291,6 +291,8 @@ static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resour
static inline bool intel_handle_aet_option(bool force_off, char *tok) { return false; }
#endif

+bool erdt_cpu_has(int flag);
+bool erdt_support(int flag);
void erdt_init(void);
void erdt_exit(void);
bool erdt_try_bind_domain(int cpu);
--
2.25.1