hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8421 ------------------------------------------ In the mpam_reset_device_bitmap, wd indicates the bit width. The original logic directly converts it into a bitmap, which is incorrect. As a result, the bit width of the bitmap is one bit more than the actual bit width. After resctrl is mounted again, the schemata read is not as expected. Fix it by subtracting 1 from wb before GENMASK is performed. Fixes: 675345bc2866 ("arm64/mpam: Reset controls when CPUs come online") Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com> --- arch/arm64/kernel/mpam/mpam_device.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/mpam/mpam_device.c b/arch/arm64/kernel/mpam/mpam_device.c index deaf990d0c74..7de8e2cd8bd9 100644 --- a/arch/arm64/kernel/mpam/mpam_device.c +++ b/arch/arm64/kernel/mpam/mpam_device.c @@ -911,7 +911,7 @@ int mpam_discovery_start(void) static void mpam_reset_device_bitmap(struct mpam_device *dev, u16 reg, u16 wd) { - u32 bm = ~0; + u32 msb, bm = ~0; int i; lockdep_assert_held(&dev->lock); @@ -920,8 +920,12 @@ static void mpam_reset_device_bitmap(struct mpam_device *dev, u16 reg, u16 wd) for (i = 0; i < wd / 32; i++, reg += sizeof(bm)) mpam_write_reg(dev, reg, bm); - /* and the last partial 32bit word */ - bm = GENMASK(wd % 32, 0); + /* + * ....and the last partial 32bit word. When wd is a multiple + * of 32, msb should be 31 to write a full 32bit word. + */ + msb = (wd - 1) % 32; + bm = GENMASK(msb, 0); if (bm) mpam_write_reg(dev, reg, bm); } -- 2.43.0