From: Wang ShaoBo bobo.shaobowang@huawei.com
hulk inclusion category: feature bugzilla: 34278 CVE: NA
-------------------------------------------------
For MPAM, Processing elements (PEs) issue memory-system requests, PEs must implement the MPAMn_ELx registers and their behaviors to generate the PARTID and PMG fields of memory-system requests.
So far schemata supports cdp writing and reading, to grab MPAM info from cpu for downstream MSCs, SYS_MPAMx_ELx registers should be filled in both partid_d and partid_i (mapped from closids) of LxDATA and LxCODE and pmg_d and pmg_i (mapped from rmid).
Signed-off-by: Wang ShaoBo bobo.shaobowang@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Cheng Jian cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- arch/arm64/kernel/mpam/mpam_resctrl.c | 69 ++++++++++++++++++++------- 1 file changed, 52 insertions(+), 17 deletions(-)
diff --git a/arch/arm64/kernel/mpam/mpam_resctrl.c b/arch/arm64/kernel/mpam/mpam_resctrl.c index 2508bf666742..b3924fca81f2 100644 --- a/arch/arm64/kernel/mpam/mpam_resctrl.c +++ b/arch/arm64/kernel/mpam/mpam_resctrl.c @@ -1371,7 +1371,8 @@ int __init mpam_resctrl_init(void) void __mpam_sched_in(void) { struct intel_pqr_state *state = this_cpu_ptr(&pqr_state); - u64 partid = state->default_closid; + u64 closid = state->default_closid; + u64 partid_d, partid_i; u64 pmg = state->default_rmid;
/* @@ -1380,7 +1381,7 @@ void __mpam_sched_in(void) */ if (static_branch_likely(&resctrl_alloc_enable_key)) { if (current->closid) - partid = current->closid; + closid = current->closid; }
if (static_branch_likely(&resctrl_mon_enable_key)) { @@ -1388,22 +1389,56 @@ void __mpam_sched_in(void) pmg = current->rmid; }
- if (partid != state->cur_closid || pmg != state->cur_rmid) { + if (closid != state->cur_closid || pmg != state->cur_rmid) { u64 reg; - state->cur_closid = partid; - state->cur_rmid = pmg; - - /* set in EL0 */ - reg = mpam_read_sysreg_s(SYS_MPAM0_EL1, "SYS_MPAM0_EL1"); - reg = PARTID_SET(reg, partid); - reg = PMG_SET(reg, pmg); - mpam_write_sysreg_s(reg, SYS_MPAM0_EL1, "SYS_MPAM0_EL1"); - - /* set in EL1 */ - reg = mpam_read_sysreg_s(SYS_MPAM1_EL1, "SYS_MPAM1_EL1"); - reg = PARTID_SET(reg, partid); - reg = PMG_SET(reg, pmg); - mpam_write_sysreg_s(reg, SYS_MPAM1_EL1, "SYS_MPAM1_EL1"); + + if (resctrl_cdp_enabled) { + hw_closid_t hw_closid; + + resctrl_cdp_map(clos, closid, CDP_DATA, hw_closid); + partid_d = hw_closid_val(hw_closid); + + resctrl_cdp_map(clos, closid, CDP_CODE, hw_closid); + partid_i = hw_closid_val(hw_closid); + + /* + * when cdp enabled, we use partid_i to label cur_closid + * of cpu state instead of partid_d, because each task/ + * rdtgrp's closid is labeled by CDP_BOTH/CDP_CODE but not + * CDP_DATA. + */ + state->cur_closid = partid_i; + state->cur_rmid = pmg; + + /* set in EL0 */ + reg = mpam_read_sysreg_s(SYS_MPAM0_EL1, "SYS_MPAM0_EL1"); + reg = PARTID_D_SET(reg, partid_d); + reg = PARTID_I_SET(reg, partid_i); + reg = PMG_SET(reg, pmg); + mpam_write_sysreg_s(reg, SYS_MPAM0_EL1, "SYS_MPAM0_EL1"); + + /* set in EL1 */ + reg = mpam_read_sysreg_s(SYS_MPAM1_EL1, "SYS_MPAM1_EL1"); + reg = PARTID_D_SET(reg, partid_d); + reg = PARTID_I_SET(reg, partid_i); + reg = PMG_SET(reg, pmg); + mpam_write_sysreg_s(reg, SYS_MPAM1_EL1, "SYS_MPAM1_EL1"); + } else { + state->cur_closid = closid; + state->cur_rmid = pmg; + + /* set in EL0 */ + reg = mpam_read_sysreg_s(SYS_MPAM0_EL1, "SYS_MPAM0_EL1"); + reg = PARTID_SET(reg, closid); + reg = PMG_SET(reg, pmg); + mpam_write_sysreg_s(reg, SYS_MPAM0_EL1, "SYS_MPAM0_EL1"); + + /* set in EL1 */ + reg = mpam_read_sysreg_s(SYS_MPAM1_EL1, "SYS_MPAM1_EL1"); + reg = PARTID_SET(reg, closid); + reg = PMG_SET(reg, pmg); + mpam_write_sysreg_s(reg, SYS_MPAM1_EL1, "SYS_MPAM1_EL1"); + } } }