[PATCH v4 2/6] arm_mpam: Fix MSC MMIO window size off-by-one with resource_size()
Jinjie Ruan
ruanjinjie at huawei.com
Thu Oct 29 01:13:18 PDT 2026
在 2026/10/28 19:45, Yin Li 写道:
> 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 at intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202609030809.ObirDhR3-lkp@intel.com/
> Signed-off-by: Yin Li <yin.li at oss.qualcomm.com>
> Reviewed-by: Andre Przywara <andre.przywara at arm.com>
> Reviewed-by: Ben Horgan <ben.horgan at arm.com>
> ---
> 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);
Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
> msc->mapped_hwpage = io;
> } else if (msc->iface == MPAM_IFACE_PCC) {
> u32 mpam_fb_msc_id;
>
--
Best regards,
Jinjie
More information about the linux-arm-kernel
mailing list