hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/902 ------------------ For resources that hide CDP support, using the staged_config's type directly results in incorrect partid calculation, causing access to the wrong configuration (comp->cfg[partid]). Since CDP_CODE and CDP_DATA map to the same underlying configuration for these resources, force the use of CDP_DATA type to ensure correct partid indexing in resctrl_arch_get_config() and resctrl_arch_update_one(). Fixes: 58db5c68e84a ("untested: arm_mpam: resctrl: Add support for MB resource") Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_resctrl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 773ab763d1bb..94bb46c0f633 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -1244,6 +1244,13 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); cprops = &res->class->props; + /* + * For resources that don't support CDP, both CDP_CODE and + * CDP_DATA map to the same configuration. + */ + if (mpam_resctrl_hide_cdp(r->rid)) + type = CDP_DATA; + partid = resctrl_get_config_index(closid, type); cfg = &dom->comp->cfg[partid]; @@ -1335,6 +1342,9 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom); cprops = &res->class->props; + if (mpam_resctrl_hide_cdp(r->rid)) + t = CDP_DATA; + partid = resctrl_get_config_index(closid, t); if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r)) return -EINVAL; -- 2.25.1