Re: [PATCH v4 2/6] arm_mpam: Fix MSC MMIO window size off-by-one with resource_size()

From: Srivathsa L Rao

Date: Fri Oct 30 2026 - 13:19:13 EST


Reviewed-by: Srivathsa L Rao <srivathsa.rao@xxxxxxxxxxxxxxxx>

On 10/28/2026 5:15 PM, Yin Li wrote:
struct resource uses an inclusive end address, so the window size is
end - start + 1. do_mpam_msc_drv_probe() computed it as end - start,
which is one byte too small.

mapped_hwpage_sz is used by the register access bounds checks, which
have the form "offset + width > mapped_hwpage_sz". With the size one
byte too small, an access to the last register in the window is
incorrectly flagged as out of bounds: for a 0x1000 window, a 4-byte
access at offset 0xFFC (bytes 0xFFC..0xFFF, legal) computes
0xFFC + 4 = 0x1000 > 0xFFF and falsely warns.

Use resource_size() so the size is correct. The ">" bounds checks are
correct as-is once the size is accurate and are left unchanged.

Fixes: f04046f2577a ("arm_mpam: Add probe/remove for mpam msc driver and kbuild boiler plate")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202609030809.ObirDhR3-lkp@xxxxxxxxx/
Signed-off-by: Yin Li <yin.li@xxxxxxxxxxxxxxxx>
Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx>
Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
---
drivers/resctrl/mpam_devices.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 347a5a6d6a1d..0f984fcbcae9 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2508,7 +2508,7 @@ static struct mpam_msc *do_mpam_msc_drv_probe(struct platform_device *pdev)
dev_err_once(dev, "Failed to map MSC base address\n");
return ERR_CAST(io);
}
- msc->mapped_hwpage_sz = msc_res->end - msc_res->start;
+ msc->mapped_hwpage_sz = resource_size(msc_res);
msc->mapped_hwpage = io;
} else if (msc->iface == MPAM_IFACE_PCC) {
u32 mpam_fb_msc_id;

Best Regards,
Srivathsa