From: Robin Murphy <robin.murphy@arm.com>
To: Nicolin Chen <nicolinc@nvidia.com>, Jason Gunthorpe <jgg@nvidia.com>
Cc: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
Kevin Tian <kevin.tian@intel.com>,
linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
Will Deacon <will@kernel.org>,
Lixiao Yang <lixiao.yang@intel.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
patches@lists.linux.dev, stable@vger.kernel.org,
syzbot+c2f65e2801743ca64e08@syzkaller.appspotmail.com,
Yi Liu <yi.l.liu@intel.com>
Subject: Re: [PATCH 2/2] iommufd/selftest: Test reserved regions near ULONG_MAX
Date: Fri, 18 Jul 2025 19:23:25 +0100 [thread overview]
Message-ID: <d18d7013-e82e-456a-87da-8acffc90d8db@arm.com> (raw)
In-Reply-To: <aHoCOnOAlwpoiDNe@Asurada-Nvidia>
On 2025-07-18 9:13 am, Nicolin Chen wrote:
> On Thu, Jul 17, 2025 at 07:45:51PM -0700, Nicolin Chen wrote:
>> On Thu, Jul 17, 2025 at 04:15:09PM -0300, Jason Gunthorpe wrote:
>>
>>> +TEST_F(iommufd_ioas, reserved_overflow)
>>> +{
>>> + struct iommu_test_cmd test_cmd = {
>>> + .size = sizeof(test_cmd),
>>> + .op = IOMMU_TEST_OP_ADD_RESERVED,
>>> + .id = self->ioas_id,
>>> + .add_reserved = { .start = 6,
>>> + .length = 0xffffffffffff8001 },
>>> + };
>>> + __u64 iova;
>>> +
>>> + ASSERT_EQ(0,
>>> + ioctl(self->fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_ADD_RESERVED),
>>> + &test_cmd));
>>> + test_err_ioctl_ioas_map(ENOSPC, buffer, 0x5000, &iova);
>>
>> When:
>> PAGE_SIZE=SZ_64K = 0x10000
>> MOCK_PAGE_SIZE = PAGE_SIZE / 2 = 0x8000
>>
>> This likely fails the alignment test, returning -EINVAL instead:
>>
>> # iommufd.c:988:reserved_overflow:Expected 28 (28) == errno (22)
>> # reserved_overflow: Test failed
>> # FAIL iommufd_ioas.mock_domain_limit.reserved_overflow
>>
>> So, I think we'd have to pick a number aligned to MOCK_PAGE_SIZE?
>> e.g. changing to 0x18000 for example can pass.
>
> I realized that we can't change the number as it won't reproduce
> on PAGE_SIZE=4K. So, perhaps it should just SKIP other page sizes
> than 4K.
Shouldn't it work to parametrise both numbers accordingly, e.g. (if my
Friday-evening maths holds up) reserve "1UL - MOCK_PAGE_SIZE * 16" then
map "MOCK_PAGE_SIZE * 10"?
Robin.
next prev parent reply other threads:[~2025-07-18 18:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-17 19:15 [PATCH 0/2] Fix undetected overflow when allocating IOVA Jason Gunthorpe
2025-07-17 19:15 ` [PATCH 1/2] iommufd: Prevent ALIGN() overflow Jason Gunthorpe
2025-07-18 8:16 ` Nicolin Chen
2025-07-18 13:03 ` Yi Liu
2025-07-17 19:15 ` [PATCH 2/2] iommufd/selftest: Test reserved regions near ULONG_MAX Jason Gunthorpe
2025-07-18 2:45 ` Nicolin Chen
2025-07-18 8:13 ` Nicolin Chen
2025-07-18 16:21 ` Jason Gunthorpe
2025-07-18 18:23 ` Robin Murphy [this message]
2025-07-18 18:50 ` Nicolin Chen
2025-07-18 20:16 ` Jason Gunthorpe
2025-07-18 19:56 ` Jason Gunthorpe
2025-07-18 13:03 ` Yi Liu
2025-07-18 18:10 ` [PATCH 0/2] Fix undetected overflow when allocating IOVA Nicolin Chen
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=d18d7013-e82e-456a-87da-8acffc90d8db@arm.com \
--to=robin.murphy@arm.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=lixiao.yang@intel.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=patches@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+c2f65e2801743ca64e08@syzkaller.appspotmail.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.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