* drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
@ 2026-09-03 1:01 kernel test robot
2026-09-03 11:02 ` Ilpo Järvinen
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2026-09-03 1:01 UTC (permalink / raw)
To: Ben Horgan
Cc: oe-kbuild-all, linux-kernel, James Morse, Zeng Heng,
Shaopeng Tan, Jonathan Cameron, Gavin Shan
Hi Ben,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 89a312991dc6e638a36adc43ccb91dbc25504c04
commit: c544f00a473239835d22e7109b403314d8b85974 arm64: mpam: Drop the CONFIG_EXPERT restriction
date: 5 months ago
config: arm64-randconfig-r051-20260902 (https://download.01.org/0day-ci/archive/20260903/202609030809.ObirDhR3-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 2c2cffa015e9549aafba9e514384b08204c7cc4b)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: c544f00a4732 ("arm64: mpam: Drop the CONFIG_EXPERT restriction")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609030809.ObirDhR3-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
vim +1860 drivers/resctrl/mpam_devices.c
f04046f2577a5c James Morse 2025-11-19 1797
f04046f2577a5c James Morse 2025-11-19 1798 static struct mpam_msc *do_mpam_msc_drv_probe(struct platform_device *pdev)
f04046f2577a5c James Morse 2025-11-19 1799 {
f04046f2577a5c James Morse 2025-11-19 1800 int err;
f04046f2577a5c James Morse 2025-11-19 1801 u32 tmp;
f04046f2577a5c James Morse 2025-11-19 1802 struct mpam_msc *msc;
f04046f2577a5c James Morse 2025-11-19 1803 struct resource *msc_res;
f04046f2577a5c James Morse 2025-11-19 1804 struct device *dev = &pdev->dev;
f04046f2577a5c James Morse 2025-11-19 1805
f04046f2577a5c James Morse 2025-11-19 1806 lockdep_assert_held(&mpam_list_lock);
f04046f2577a5c James Morse 2025-11-19 1807
f04046f2577a5c James Morse 2025-11-19 1808 msc = devm_kzalloc(&pdev->dev, sizeof(*msc), GFP_KERNEL);
f04046f2577a5c James Morse 2025-11-19 1809 if (!msc)
f04046f2577a5c James Morse 2025-11-19 1810 return ERR_PTR(-ENOMEM);
01fb4b8224726a James Morse 2025-11-19 1811 init_garbage(&msc->garbage);
01fb4b8224726a James Morse 2025-11-19 1812 msc->garbage.pdev = pdev;
f04046f2577a5c James Morse 2025-11-19 1813
f04046f2577a5c James Morse 2025-11-19 1814 err = devm_mutex_init(dev, &msc->probe_lock);
f04046f2577a5c James Morse 2025-11-19 1815 if (err)
f04046f2577a5c James Morse 2025-11-19 1816 return ERR_PTR(err);
f04046f2577a5c James Morse 2025-11-19 1817
f04046f2577a5c James Morse 2025-11-19 1818 err = devm_mutex_init(dev, &msc->part_sel_lock);
f04046f2577a5c James Morse 2025-11-19 1819 if (err)
f04046f2577a5c James Morse 2025-11-19 1820 return ERR_PTR(err);
f04046f2577a5c James Morse 2025-11-19 1821
49aa621c4dcaf8 James Morse 2025-11-19 1822 err = devm_mutex_init(dev, &msc->error_irq_lock);
49aa621c4dcaf8 James Morse 2025-11-19 1823 if (err)
49aa621c4dcaf8 James Morse 2025-11-19 1824 return ERR_PTR(err);
09b89d2a72f37b James Morse 2025-11-19 1825
09b89d2a72f37b James Morse 2025-11-19 1826 err = devm_mutex_init(dev, &msc->cfg_lock);
09b89d2a72f37b James Morse 2025-11-19 1827 if (err)
09b89d2a72f37b James Morse 2025-11-19 1828 return ERR_PTR(err);
09b89d2a72f37b James Morse 2025-11-19 1829
d02beb06ca2a62 James Morse 2025-11-19 1830 mpam_mon_sel_lock_init(msc);
f04046f2577a5c James Morse 2025-11-19 1831 msc->id = pdev->id;
f04046f2577a5c James Morse 2025-11-19 1832 msc->pdev = pdev;
f04046f2577a5c James Morse 2025-11-19 1833 INIT_LIST_HEAD_RCU(&msc->all_msc_list);
f04046f2577a5c James Morse 2025-11-19 1834 INIT_LIST_HEAD_RCU(&msc->ris);
f04046f2577a5c James Morse 2025-11-19 1835
f04046f2577a5c James Morse 2025-11-19 1836 update_msc_accessibility(msc);
f04046f2577a5c James Morse 2025-11-19 1837 if (cpumask_empty(&msc->accessibility)) {
f04046f2577a5c James Morse 2025-11-19 1838 dev_err_once(dev, "MSC is not accessible from any CPU!");
f04046f2577a5c James Morse 2025-11-19 1839 return ERR_PTR(-EINVAL);
f04046f2577a5c James Morse 2025-11-19 1840 }
f04046f2577a5c James Morse 2025-11-19 1841
49aa621c4dcaf8 James Morse 2025-11-19 1842 err = mpam_msc_setup_error_irq(msc);
49aa621c4dcaf8 James Morse 2025-11-19 1843 if (err)
49aa621c4dcaf8 James Morse 2025-11-19 1844 return ERR_PTR(err);
49aa621c4dcaf8 James Morse 2025-11-19 1845
f04046f2577a5c James Morse 2025-11-19 1846 if (device_property_read_u32(&pdev->dev, "pcc-channel", &tmp))
f04046f2577a5c James Morse 2025-11-19 1847 msc->iface = MPAM_IFACE_MMIO;
f04046f2577a5c James Morse 2025-11-19 1848 else
f04046f2577a5c James Morse 2025-11-19 1849 msc->iface = MPAM_IFACE_PCC;
f04046f2577a5c James Morse 2025-11-19 1850
f04046f2577a5c James Morse 2025-11-19 1851 if (msc->iface == MPAM_IFACE_MMIO) {
f04046f2577a5c James Morse 2025-11-19 1852 void __iomem *io;
f04046f2577a5c James Morse 2025-11-19 1853
f04046f2577a5c James Morse 2025-11-19 1854 io = devm_platform_get_and_ioremap_resource(pdev, 0,
f04046f2577a5c James Morse 2025-11-19 1855 &msc_res);
f04046f2577a5c James Morse 2025-11-19 1856 if (IS_ERR(io)) {
f04046f2577a5c James Morse 2025-11-19 1857 dev_err_once(dev, "Failed to map MSC base address\n");
f04046f2577a5c James Morse 2025-11-19 1858 return ERR_CAST(io);
f04046f2577a5c James Morse 2025-11-19 1859 }
f04046f2577a5c James Morse 2025-11-19 @1860 msc->mapped_hwpage_sz = msc_res->end - msc_res->start;
f04046f2577a5c James Morse 2025-11-19 1861 msc->mapped_hwpage = io;
f04046f2577a5c James Morse 2025-11-19 1862 } else {
f04046f2577a5c James Morse 2025-11-19 1863 return ERR_PTR(-EINVAL);
f04046f2577a5c James Morse 2025-11-19 1864 }
f04046f2577a5c James Morse 2025-11-19 1865
f04046f2577a5c James Morse 2025-11-19 1866 list_add_rcu(&msc->all_msc_list, &mpam_all_msc);
f04046f2577a5c James Morse 2025-11-19 1867 platform_set_drvdata(pdev, msc);
f04046f2577a5c James Morse 2025-11-19 1868
f04046f2577a5c James Morse 2025-11-19 1869 return msc;
f04046f2577a5c James Morse 2025-11-19 1870 }
f04046f2577a5c James Morse 2025-11-19 1871
:::::: The code at line 1860 was first introduced by commit
:::::: f04046f2577a5c76167333ca99d3903ee5331ba0 arm_mpam: Add probe/remove for mpam msc driver and kbuild boiler plate
:::::: TO: James Morse <james.morse@arm.com>
:::::: CC: Catalin Marinas <catalin.marinas@arm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
2026-09-03 1:01 drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res kernel test robot
@ 2026-09-03 11:02 ` Ilpo Järvinen
2026-09-03 13:16 ` Ben Horgan
0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2026-09-03 11:02 UTC (permalink / raw)
To: kernel test robot, James Morse
Cc: Ben Horgan, oe-kbuild-all, LKML, Zeng Heng, Shaopeng Tan,
Jonathan Cameron, Gavin Shan
On Thu, 3 Sep 2026, kernel test robot wrote:
> Hi Ben,
>
> First bad commit (maybe != root cause):
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 89a312991dc6e638a36adc43ccb91dbc25504c04
> commit: c544f00a473239835d22e7109b403314d8b85974 arm64: mpam: Drop the CONFIG_EXPERT restriction
> date: 5 months ago
> config: arm64-randconfig-r051-20260902 (https://download.01.org/0day-ci/archive/20260903/202609030809.ObirDhR3-lkp@intel.com/config)
> compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 2c2cffa015e9549aafba9e514384b08204c7cc4b)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Fixes: c544f00a4732 ("arm64: mpam: Drop the CONFIG_EXPERT restriction")
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202609030809.ObirDhR3-lkp@intel.com/
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
>
> vim +1860 drivers/resctrl/mpam_devices.c
>
> f04046f2577a5c James Morse 2025-11-19 @1860 msc->mapped_hwpage_sz = msc_res->end - msc_res->start;
> :::::: The code at line 1860 was first introduced by commit
> :::::: f04046f2577a5c76167333ca99d3903ee5331ba0 arm_mpam: Add probe/remove for mpam msc driver and kbuild boiler plate
>
> :::::: TO: James Morse <james.morse@arm.com>
> :::::: CC: Catalin Marinas <catalin.marinas@arm.com>
Hi all,
This report has some validity but the code doesn't look buggy as is, just
off-by-one errors correcting each other. The variable is called "..._sz"
(~ size), but the resource size calculation is off-by-one because trying
to do it by hand instead of using the resource_size() helper.
The mapped_hwpage_sz value is only used for register write offset
sanity checks, which use > countering the off-by-one error.
IMO, it would be better to use resource_size() and change those sanity
checks to use >= instead of > but this doesn't look a major problem by
any means.
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
2026-09-03 11:02 ` Ilpo Järvinen
@ 2026-09-03 13:16 ` Ben Horgan
0 siblings, 0 replies; 3+ messages in thread
From: Ben Horgan @ 2026-09-03 13:16 UTC (permalink / raw)
To: Ilpo Järvinen, kernel test robot, James Morse
Cc: oe-kbuild-all, LKML, Zeng Heng, Shaopeng Tan, Jonathan Cameron,
Gavin Shan
Hi Ilpo,
On 03/09/2026 12:02, Ilpo Järvinen wrote:
> On Thu, 3 Sep 2026, kernel test robot wrote:
>
>> Hi Ben,
>>
>> First bad commit (maybe != root cause):
>>
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head: 89a312991dc6e638a36adc43ccb91dbc25504c04
>> commit: c544f00a473239835d22e7109b403314d8b85974 arm64: mpam: Drop the CONFIG_EXPERT restriction
>> date: 5 months ago
>> config: arm64-randconfig-r051-20260902 (https://download.01.org/0day-ci/archive/20260903/202609030809.ObirDhR3-lkp@intel.com/config)
>> compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 2c2cffa015e9549aafba9e514384b08204c7cc4b)
>>
>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>> the same patch/commit), kindly add following tags
>> | Fixes: c544f00a4732 ("arm64: mpam: Drop the CONFIG_EXPERT restriction")
>> | Reported-by: kernel test robot <lkp@intel.com>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/202609030809.ObirDhR3-lkp@intel.com/
>>
>> cocci warnings: (new ones prefixed by >>)
>>>> drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
>>
>> vim +1860 drivers/resctrl/mpam_devices.c
>>
>> f04046f2577a5c James Morse 2025-11-19 @1860 msc->mapped_hwpage_sz = msc_res->end - msc_res->start;
>
>> :::::: The code at line 1860 was first introduced by commit
>> :::::: f04046f2577a5c76167333ca99d3903ee5331ba0 arm_mpam: Add probe/remove for mpam msc driver and kbuild boiler plate
>>
>> :::::: TO: James Morse <james.morse@arm.com>
>> :::::: CC: Catalin Marinas <catalin.marinas@arm.com>
>
> Hi all,
>
> This report has some validity but the code doesn't look buggy as is, just
> off-by-one errors correcting each other. The variable is called "..._sz"
> (~ size), but the resource size calculation is off-by-one because trying Arm A-profile Architecture Hi
> to do it by hand instead of using the resource_size() helper.
>
> The mapped_hwpage_sz value is only used for register write offset
> sanity checks, which use > countering the off-by-one error.
Ah, yes, thanks for pointing this out. mapped_hwpage_sz is a misleading name as it really indicates
the last byte mapped and so it is functionally correct when used with >.
>
> IMO, it would be better to use resource_size() and change those sanity
> checks to use >= instead of > but this doesn't look a major problem by
> any means.
Agreed. Looking back I fixed the functional bug in v6 (changed >= to >) of the original mpam driver
posting but left it in a confusing state.
Thanks,
Ben
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-03 13:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-03 1:01 drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res kernel test robot
2026-09-03 11:02 ` Ilpo Järvinen
2026-09-03 13:16 ` Ben Horgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®