From: Sasha Levin <sashal@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>
Cc: Shuah Khan <shuah@kernel.org>,
iommu@lists.linux.dev, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] iommufd/selftest: fix the unmap-all length on 32-bit architectures
Date: Tue, 3 Nov 2026 11:39:10 -0500 [thread overview]
Message-ID: <20261103163910.640756-1-sashal@kernel.org> (raw)
_test_ioctl_ioas_unmap() takes the length as a size_t, so on 32-bit
architectures test_ioctl_ioas_unmap(0, UINT64_MAX), which asks to unmap
everything, passes SIZE_MAX instead and doesn't test the unmap-all case:
iommufd.c:861:9: warning: conversion from 'long long unsigned int' to 'size_t' {aka 'unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Woverflow]
Take the length as uint64_t, like the length field of struct
iommu_ioas_unmap. While at it, cast the pointers that go into 64-bit
UAPI fields through uintptr_t, as casting them straight to uint64_t
warns on 32-bit.
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Found with 32-bit builds of the selftests (gcc 16 and clang 21 with
-m32, with and without -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64);
KernelCI's 32-bit arm builds show the same warnings. The changed files
build without them now, and the x86_64 builds don't change.
tools/testing/selftests/iommu/iommufd.c | 2 +-
tools/testing/selftests/iommu/iommufd_utils.h | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index ca2b35e9d443a..f96c262c6a245 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -2454,7 +2454,7 @@ TEST_F(iommufd, map_cmd)
struct vfio_iommu_type1_dma_map map_cmd = {
.iova = MOCK_APERTURE_START,
.size = PAGE_SIZE,
- .vaddr = (__u64)buffer,
+ .vaddr = (__u64)(uintptr_t)buffer,
};
map_cmd.argsz = 1;
diff --git a/tools/testing/selftests/iommu/iommufd_utils.h b/tools/testing/selftests/iommu/iommufd_utils.h
index b4928cbd4d9c8..38339dc9f943b 100644
--- a/tools/testing/selftests/iommu/iommufd_utils.h
+++ b/tools/testing/selftests/iommu/iommufd_utils.h
@@ -198,7 +198,7 @@ static int _test_cmd_hwpt_alloc(int fd, __u32 device_id, __u32 pt_id, __u32 ft_i
.pt_id = pt_id,
.data_type = data_type,
.data_len = data_len,
- .data_uptr = (uint64_t)data,
+ .data_uptr = (uint64_t)(uintptr_t)data,
.fault_id = ft_id,
};
int ret;
@@ -310,7 +310,7 @@ static int _test_cmd_hwpt_invalidate(int fd, __u32 hwpt_id, void *reqs,
.size = sizeof(cmd),
.hwpt_id = hwpt_id,
.data_type = data_type,
- .data_uptr = (uint64_t)reqs,
+ .data_uptr = (uint64_t)(uintptr_t)reqs,
.entry_len = lreq,
.entry_num = *nreqs,
};
@@ -341,7 +341,7 @@ static int _test_cmd_viommu_invalidate(int fd, __u32 viommu_id, void *reqs,
.size = sizeof(cmd),
.hwpt_id = viommu_id,
.data_type = data_type,
- .data_uptr = (uint64_t)reqs,
+ .data_uptr = (uint64_t)(uintptr_t)reqs,
.entry_len = lreq,
.entry_num = *nreqs,
};
@@ -695,7 +695,7 @@ static int _test_ioctl_ioas_map(int fd, unsigned int ioas_id, void *buffer,
})
static int _test_ioctl_ioas_unmap(int fd, unsigned int ioas_id, uint64_t iova,
- size_t length, uint64_t *out_len)
+ uint64_t length, uint64_t *out_len)
{
struct iommu_ioas_unmap cmd = {
.size = sizeof(cmd),
@@ -832,7 +832,7 @@ static int _test_cmd_get_hw_info(int fd, __u32 device_id, __u32 data_type,
.dev_id = device_id,
.data_len = data_len,
.in_data_type = data_type,
- .data_uptr = (uint64_t)data,
+ .data_uptr = (uint64_t)(uintptr_t)data,
.out_capabilities = 0,
};
int ret;
@@ -978,7 +978,7 @@ static int _test_cmd_viommu_alloc(int fd, __u32 device_id, __u32 hwpt_id,
.type = type,
.dev_id = device_id,
.hwpt_id = hwpt_id,
- .data_uptr = (uint64_t)data,
+ .data_uptr = (uint64_t)(uintptr_t)data,
.data_len = data_len,
};
int ret;
--
2.53.0
reply other threads:[~2026-11-03 16:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261103163910.640756-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
/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®