Message ID | 20241212154000.330467-3-Dave.Martin@arm.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Introduce flexible CLOSID/RMID translation | expand |
diff --git a/drivers/platform/arm64/mpam/mpam_resctrl.c b/drivers/platform/arm64/mpam/mpam_resctrl.c index 76ddbce0ea9c..30f2caec11d7 100644 --- a/drivers/platform/arm64/mpam/mpam_resctrl.c +++ b/drivers/platform/arm64/mpam/mpam_resctrl.c @@ -1097,6 +1097,14 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d, dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom); cprops = &res->class->props; + /* + * When CDP is enabled, but the resource doesn't support it, + * the control is cloned across both partids. + * Pick one at random to read: + */ + if (mpam_resctrl_hide_cdp(r->rid)) + type = CDP_DATA; + partid = resctrl_get_config_index(closid, type); cfg = &dom->comp->cfg[partid];
When reading resource control values through a resctrl schemata file, the index into the configuration array in the MPAM driver is currently translated incorrectly. This means that when resctrl is mounted with the "cdp" option, the wrong array entry may be returned or an out-of-bounds array access may occur when reading back of control values for the MB resource. Fix it by translating the index for affected resources as if they were "DATA" resources. ("CODE" would also work, but because resctrl_arch_update_one() clones schemata writes across "CODE" and "DATA" for affected resources, it does not matter which one is read.) Signed-off-by: Dave Martin <Dave.Martin@arm.com> --- This issue was introduced by the non-upstream commit "arm_mpam: resctrl: Improve CDP emulation" (commit b097a6193546dbbd27cd19d7e16e1e750ebb030f in git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/snapshot/v6.12-rc1 ) --- drivers/platform/arm64/mpam/mpam_resctrl.c | 8 ++++++++ 1 file changed, 8 insertions(+)