[PATCH v5 2/3] arm_mpam: resctrl: Only enable CDP on a resource that supports it

From: Jinjie Ruan

Date: Wed Nov 18 2026 - 06:36:03 EST


resctrl_arch_set_cdp_enabled() allows enabling CDP on a cache level
that has no MPAM cache controls (e.g. mounting with -o cdpl2 when only
L3 is capable). This turns on system-wide CDP emulation without halving
the CLOSID count, causing upper control groups to map to PARTIDs beyond
mpam_partid_max. Accessing these out-of-range PARTIDs indexes past
internal arrays and triggers MSMONCFG_ID_RANGE, disabling MPAM.

Reject enabling CDP if the resource is not cdp_capable, matching x86.
Only the enable path is checked since unmount disables CDP on both
cache levels.

Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
Link: https://sashiko.dev/#/bug/linux-05c19551-0bba-4a06-aa2c-3c90fab5853d
Suggested-by: Ben Horgan <ben.horgan@xxxxxxx>
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
---
v5:
- Rmove alloc_capable check.
- Remove the unnecessary stable version.
- Simplfify the commit message.
---
drivers/resctrl/mpam_resctrl.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index aa3b3a093857..24d5b2fa4bca 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -213,6 +213,9 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
if (enable && mpam_partid_max < 1)
return -EINVAL;

+ if (enable && !mpam_resctrl_controls[rid].resctrl_res.cdp_capable)
+ return -EINVAL;
+
/*
* resctrl_arch_set_cdp_enabled() is only called with enable set to
* false on error and unmount.
--
2.34.1