From: Ben Horgan <ben.horgan@arm.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"kernel test robot" <lkp@intel.com>,
"James Morse" <james.morse@arm.com>
Cc: oe-kbuild-all@lists.linux.dev,
LKML <linux-kernel@vger.kernel.org>,
Zeng Heng <zengheng4@huawei.com>,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Gavin Shan <gshan@redhat.com>
Subject: Re: drivers/resctrl/mpam_devices.c:1860:35-38: WARNING: Suspicious code. resource_size is maybe missing with msc_res
Date: Thu, 3 Sep 2026 14:16:19 +0100 [thread overview]
Message-ID: <03055fbc-281f-4ed9-9282-4853d560e17f@arm.com> (raw)
In-Reply-To: <555e6b9d-cff8-ef10-42e9-5e469550292b@linux.intel.com>
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
>
prev parent reply other threads:[~2026-09-03 13:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 1:01 kernel test robot
2026-09-03 11:02 ` Ilpo Järvinen
2026-09-03 13:16 ` Ben Horgan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=03055fbc-281f-4ed9-9282-4853d560e17f@arm.com \
--to=ben.horgan@arm.com \
--cc=gshan@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=james.morse@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=zengheng4@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®