From ce79436fd22f1e7d65be2941644dc64da26d2494 Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Tue, 22 Jul 2025 21:24:08 +0800 Subject: [PATCH 1/2] arm64/mpam: Fix typo in resctrl_arch_set_cdp_enabled() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICO2ME -------------------------------- After CDP mode is enabled, MPAM uses different PartIDs to track CPU instruction-port and data-port memory-access requests. If these PartIDs are configured in reverse, the root directory group’s isolation settings for data and instruction ports will not behave as expected. Fixes: b4280653f60d ("arm_mpam: resctrl: Add CDP emulation") Signed-off-by: Zeng Heng --- drivers/platform/mpam/mpam_resctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index c3f9f0c2a94c..428afe27fda2 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -111,8 +111,8 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable) partid = RESCTRL_RESERVED_CLOSID; if (enable) { - partid_d = resctrl_get_config_index(partid, CDP_CODE); - partid_i = resctrl_get_config_index(partid, CDP_DATA); + partid_d = resctrl_get_config_index(partid, CDP_DATA); + partid_i = resctrl_get_config_index(partid, CDP_CODE); regval = FIELD_PREP(MPAM_SYSREG_PARTID_D, partid_d) | FIELD_PREP(MPAM_SYSREG_PARTID_I, partid_i); -- Gitee From ec5074d9367a3dd2bad1acd7c9f02efe0bbdb4ef Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Tue, 22 Jul 2025 21:24:09 +0800 Subject: [PATCH 2/2] arm64/mpam: Fix incorrect CPU-to-partid binding under CDP mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ICO2ME -------------------------------- Under CDP mode, MPAM uses different PartIDs to track CPU instruction-port and data-port memory-access requests. In practice, to prevent tasks switching their PartIDs too frequently, the root directory group’s default mpam_partid_pmg remains 0, rather than 1, under CDP mode. Accordingly, mpam_thread_switch() must check the task’s mpam_partid_pmg against 0 instead of against mpam_resctrl_default_group; otherwise, in CDP mode the scheduler will fail to switch to the partid that corresponds to CPU. Fixes: 5cd0dad659e8 ("arm64: mpam: Context switch the MPAM registers") Signed-off-by: Zeng Heng --- arch/arm64/include/asm/mpam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/mpam.h b/arch/arm64/include/asm/mpam.h index 9abe1fe58c34..8caac70e22ed 100644 --- a/arch/arm64/include/asm/mpam.h +++ b/arch/arm64/include/asm/mpam.h @@ -153,7 +153,7 @@ static inline void mpam_thread_switch(struct task_struct *tsk) !static_branch_likely(&mpam_enabled)) return; - if (regval == READ_ONCE(mpam_resctrl_default_group)) + if (!regval) regval = READ_ONCE(per_cpu(arm64_mpam_default, cpu)); oldregval = READ_ONCE(per_cpu(arm64_mpam_current, cpu)); -- Gitee