
From: Wang ShaoBo <bobo.shaobowang@huawei.com> hulk inclusion category: feature bugzilla: 34278 CVE: NA ------------------------------------------------- MPAM spec says, when an MPAMCFG register other than MPAMCFG_INTPARTID is read or written, if the value of MPAMCFG_PART_SEL.INTERNAL is not 1, MPAMF_ESR is set to indicate an intPARTID_Range error. So we should set MPAMCFG_PART_SEL.INTERNAL to 1 before reading MPAMCFG_PRI register. 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> --- arch/arm64/kernel/mpam/mpam_device.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/mpam/mpam_device.c b/arch/arm64/kernel/mpam/mpam_device.c index 1202a5795e97..70f27e0e12c9 100644 --- a/arch/arm64/kernel/mpam/mpam_device.c +++ b/arch/arm64/kernel/mpam/mpam_device.c @@ -123,7 +123,7 @@ mpam_probe_update_sysprops(u16 max_partid, u16 max_pmg) static int mpam_device_probe(struct mpam_device *dev) { - u32 hwfeatures; + u32 hwfeatures, part_sel; u16 max_intpartid = 0; u16 max_partid, max_pmg; @@ -205,8 +205,17 @@ static int mpam_device_probe(struct mpam_device *dev) /* Priority partitioning */ if (MPAMF_IDR_HAS_PRI_PART(hwfeatures)) { - u32 pri_features = mpam_read_reg(dev, MPAMF_PRI_IDR); - u32 hwdef_pri = mpam_read_reg(dev, MPAMCFG_PRI); + u32 pri_features, hwdef_pri; + /* + * if narrow support, MPAMCFG_PART_SEL.INTERNAL must be 1 when + * reading/writing MPAMCFG register other than MPAMCFG_INTPARTID. + */ + if (mpam_has_feature(mpam_feat_part_nrw, dev->features)) { + part_sel = MPAMCFG_PART_SEL_INTERNAL; + mpam_write_reg(dev, MPAMCFG_PART_SEL, part_sel); + } + pri_features = mpam_read_reg(dev, MPAMF_PRI_IDR); + hwdef_pri = mpam_read_reg(dev, MPAMCFG_PRI); pr_debug("probe: probed PRI_PART\n"); -- 2.25.1