[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202501030414.p0DE9xNK-lkp@intel.com>
Date: Fri, 3 Jan 2025 04:46:01 +0800
From: kernel test robot <lkp@...el.com>
To: Hans Zhang <18255117159@....com>, manivannan.sadhasivam@...aro.org
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev, kw@...ux.com,
kishon@...nel.org, arnd@...db.de, gregkh@...uxfoundation.org,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
rockswang7@...il.com, Hans Zhang <18255117159@....com>,
kernel test robot <lkp@...el.com>,
Niklas Cassel <cassel@...nel.org>
Subject: Re: [v6] misc: pci_endpoint_test: Fix overflow of bar_size
Hi Hans,
kernel test robot noticed the following build errors:
[auto build test ERROR on ccb98ccef0e543c2bd4ef1a72270461957f3d8d0]
url: https://github.com/intel-lab-lkp/linux/commits/Hans-Zhang/misc-pci_endpoint_test-Fix-overflow-of-bar_size/20250102-200548
base: ccb98ccef0e543c2bd4ef1a72270461957f3d8d0
patch link: https://lore.kernel.org/r/20250102120222.1403906-1-18255117159%40163.com
patch subject: [v6] misc: pci_endpoint_test: Fix overflow of bar_size
config: arm-defconfig (https://download.01.org/0day-ci/archive/20250103/202501030414.p0DE9xNK-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 096551537b2a747a3387726ca618ceeb3950e9bc)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250103/202501030414.p0DE9xNK-lkp@intel.com/reproduce)
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
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501030414.p0DE9xNK-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
>> drivers/misc/pci_endpoint_test.c:311:11: warning: comparison of distinct pointer types ('typeof ((bar_size)) *' (aka 'unsigned int *') and 'uint64_t *' (aka 'unsigned long long *')) [-Wcompare-distinct-pointer-types]
311 | remain = do_div(bar_size, buf_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:183:28: note: expanded from macro 'do_div'
183 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
| ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
>> drivers/misc/pci_endpoint_test.c:311:11: error: incompatible pointer types passing 'resource_size_t *' (aka 'unsigned int *') to parameter of type 'uint64_t *' (aka 'unsigned long long *') [-Werror,-Wincompatible-pointer-types]
311 | remain = do_div(bar_size, buf_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:199:22: note: expanded from macro 'do_div'
199 | __rem = __div64_32(&(n), __base); \
| ^~~~
arch/arm/include/asm/div64.h:24:45: note: passing argument to parameter 'n' here
24 | static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
| ^
>> drivers/misc/pci_endpoint_test.c:311:11: warning: shift count >= width of type [-Wshift-count-overflow]
311 | remain = do_div(bar_size, buf_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:195:25: note: expanded from macro 'do_div'
195 | } else if (likely(((n) >> 32) == 0)) { \
| ^ ~~
include/linux/compiler.h:76:40: note: expanded from macro 'likely'
76 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
2 warnings and 1 error generated.
vim +311 drivers/misc/pci_endpoint_test.c
279
280 static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
281 enum pci_barno barno)
282 {
283 void *write_buf __free(kfree) = NULL;
284 void *read_buf __free(kfree) = NULL;
285 struct pci_dev *pdev = test->pdev;
286 int j, buf_size, iters, remain;
287 resource_size_t bar_size;
288
289 if (!test->bar[barno])
290 return false;
291
292 bar_size = pci_resource_len(pdev, barno);
293
294 if (barno == test->test_reg_bar)
295 bar_size = 0x4;
296
297 /*
298 * Allocate a buffer of max size 1MB, and reuse that buffer while
299 * iterating over the whole BAR size (which might be much larger).
300 */
301 buf_size = min(SZ_1M, bar_size);
302
303 write_buf = kmalloc(buf_size, GFP_KERNEL);
304 if (!write_buf)
305 return false;
306
307 read_buf = kmalloc(buf_size, GFP_KERNEL);
308 if (!read_buf)
309 return false;
310
> 311 remain = do_div(bar_size, buf_size);
312 iters = bar_size;
313 for (j = 0; j < iters; j++)
314 if (pci_endpoint_test_bar_memcmp(test, barno, buf_size * j,
315 write_buf, read_buf, buf_size))
316 return false;
317
318 if (remain)
319 if (pci_endpoint_test_bar_memcmp(test, barno, buf_size * iters,
320 write_buf, read_buf, remain))
321 return false;
322
323 return true;
324 }
325
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists