[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202111270455.dyUYQ1BQ-lkp@intel.com>
Date: Sat, 27 Nov 2021 04:45:02 +0800
From: kernel test robot <lkp@...el.com>
To: Jason Gunthorpe <jgg@...dia.com>
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: [jgunthorpe:iommufd 3/9]
drivers/iommu/iommufd/io_pagetable.c:1155:6: warning: comparison of distinct
pointer types ('typeof (npages) *' (aka 'unsigned int *') and 'typeof
(((1UL) << 12)) *' (aka 'unsigned long *'))
tree: https://github.com/jgunthorpe/linux iommufd
head: 20622aca716f08225b705a8c84a2beeb8c71decb
commit: 3e99bfe1e6898207226254c9c3663804f72e4c75 [3/9] iommufd: Data structure to provide IOVA to PFN mapping
config: i386-randconfig-r006-20211126 (https://download.01.org/0day-ci/archive/20211127/202111270455.dyUYQ1BQ-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5162b558d8c0b542e752b037e72a69d5fd51eb1e)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/jgunthorpe/linux/commit/3e99bfe1e6898207226254c9c3663804f72e4c75
git remote add jgunthorpe https://github.com/jgunthorpe/linux
git fetch --no-tags jgunthorpe iommufd
git checkout 3e99bfe1e6898207226254c9c3663804f72e4c75
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/iommu/iommufd/ net/mac80211/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> drivers/iommu/iommufd/io_pagetable.c:1155:6: warning: comparison of distinct pointer types ('typeof (npages) *' (aka 'unsigned int *') and 'typeof (((1UL) << 12)) *' (aka 'unsigned long *')) [-Wcompare-distinct-pointer-types]
if (check_mul_overflow(npages, PAGE_SIZE, &length) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:84:15: note: expanded from macro 'check_mul_overflow'
(void) (&__a == &__b); \
~~~~ ^ ~~~~
>> drivers/iommu/iommufd/io_pagetable.c:1156:6: warning: comparison of distinct pointer types ('typeof (iova) *' (aka 'unsigned long *') and 'typeof (length - 1) *' (aka 'unsigned int *')) [-Wcompare-distinct-pointer-types]
check_add_overflow(iova, length - 1, &iova_end))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:66:15: note: expanded from macro 'check_add_overflow'
(void) (&__a == &__b); \
~~~~ ^ ~~~~
drivers/iommu/iommufd/io_pagetable.c:1211:6: warning: comparison of distinct pointer types ('typeof (npages) *' (aka 'unsigned int *') and 'typeof (((1UL) << 12)) *' (aka 'unsigned long *')) [-Wcompare-distinct-pointer-types]
if (check_mul_overflow(npages, PAGE_SIZE, &length) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:84:15: note: expanded from macro 'check_mul_overflow'
(void) (&__a == &__b); \
~~~~ ^ ~~~~
drivers/iommu/iommufd/io_pagetable.c:1212:6: warning: comparison of distinct pointer types ('typeof (iova) *' (aka 'unsigned long *') and 'typeof (length - 1) *' (aka 'unsigned int *')) [-Wcompare-distinct-pointer-types]
check_add_overflow(iova, length - 1, &iova_end))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/overflow.h:66:15: note: expanded from macro 'check_add_overflow'
(void) (&__a == &__b); \
~~~~ ^ ~~~~
4 warnings generated.
vim +1155 drivers/iommu/iommufd/io_pagetable.c
1131
1132 /**
1133 * iopt_access_pages - Return a list of pages under the iova
1134 *
1135 * Reads @npages starting at iova and returns the struct page * pointers. These
1136 * can be kmap'd by the caller for CPU access.
1137 *
1138 * The caller must perform iopt_unaccess_pages() when done to balance this.
1139 *
1140 * CHECKME: callers that need a DMA mapping via a sgl should create another
1141 * interface to build the SGL efficiently)
1142 */
1143 int iopt_access_pages(struct io_pagetable *iopt, unsigned long iova,
1144 size_t npages, struct page **out_pages, bool write)
1145 {
1146 unsigned long cur_iova;
1147 unsigned long iova_end;
1148 struct iopt_area *area;
1149 size_t length;
1150 int rc;
1151
1152 down_read(&iopt->rwsem);
1153 if (!npages || iova % PAGE_SIZE)
1154 return -EINVAL;
> 1155 if (check_mul_overflow(npages, PAGE_SIZE, &length) ||
> 1156 check_add_overflow(iova, length - 1, &iova_end))
1157 return -EOVERFLOW;
1158
1159 cur_iova = iova;
1160 for (area = iopt_area_iter_first(iopt, iova, iova_end); area;
1161 area = iopt_area_iter_next(area, iova, iova_end)) {
1162 unsigned long intr_start = max(iova, iopt_area_iova(area));
1163 unsigned long intr_end =
1164 min(iova_end, iopt_area_last_iova(area));
1165 size_t npages = (intr_end - intr_start + 1) / PAGE_SIZE;
1166
1167 /* Need contiguous areas un the access */
1168 if (cur_iova != intr_start) {
1169 rc = -EINVAL;
1170 goto out_remove;
1171 }
1172
1173 npages = (intr_end - intr_start + 1) / PAGE_SIZE;
1174 rc = iopt_pages_add_user(
1175 area->pages,
1176 (intr_start - iopt_area_iova(area)) / PAGE_SIZE, npages,
1177 out_pages + (intr_end - iopt_area_iova(area) + 1) /
1178 PAGE_SIZE,
1179 write);
1180 if (rc)
1181 goto out_remove;
1182 cur_iova += npages * PAGE_SIZE;
1183 atomic_inc(&area->num_users);
1184 }
1185
1186 up_read(&iopt->rwsem);
1187 return 0;
1188
1189 out_remove:
1190 iopt_unaccess_pages(iopt, iova, (cur_iova - iova) / PAGE_SIZE);
1191 return rc;
1192 }
1193
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Powered by blists - more mailing lists