BCC: [email protected] CC: [email protected] CC: [email protected] TO: Nicolin Chen <[email protected]> CC: Alex Williamson <[email protected]> CC: Jason Gunthorpe <[email protected]> CC: Eric Farman <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 1612c382ffbdf1f673caec76502b1c00e6d35363 commit: 1331460514ff7d378373223109eefae4cd55ec77 vfio/ccw: Change pa_pfn list to pa_iova list date: 12 days ago :::::: branch date: 4 hours ago :::::: commit date: 12 days ago config: s390-randconfig-m041-20220807 (https://download.01.org/0day-ci/archive/20220807/[email protected]/config) compiler: s390-linux-gcc (GCC) 12.1.0 If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> smatch warnings: drivers/s390/cio/vfio_ccw_cp.c:69 page_array_alloc() warn: double check that we're allocating correct size: 8 vs 16 drivers/s390/cio/vfio_ccw_cp.c:76 page_array_alloc() warn: potentially one past the end of array 'pa->pa_iova[pa->pa_nr]' vim +69 drivers/s390/cio/vfio_ccw_cp.c 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 40 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 41 /* 1331460514ff7d Nicolin Chen 2022-07-22 42 * page_array_alloc() - alloc memory for page array 1331460514ff7d Nicolin Chen 2022-07-22 43 * @pa: page_array on which to perform the operation 5c1cfb1c3948fe Dong Jia Shi 2018-05-23 44 * @iova: target guest physical address 5c1cfb1c3948fe Dong Jia Shi 2018-05-23 45 * @len: number of bytes that should be pinned from @iova 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 46 * 1331460514ff7d Nicolin Chen 2022-07-22 47 * Attempt to allocate memory for page array. 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 48 * 1331460514ff7d Nicolin Chen 2022-07-22 49 * Usage of page_array: 1331460514ff7d Nicolin Chen 2022-07-22 50 * We expect (pa_nr == 0) and (pa_iova == NULL), any field in 5c1cfb1c3948fe Dong Jia Shi 2018-05-23 51 * this structure will be filled in by this function. 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 52 * 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 53 * Returns: 1331460514ff7d Nicolin Chen 2022-07-22 54 * 0 if page array is allocated 1331460514ff7d Nicolin Chen 2022-07-22 55 * -EINVAL if pa->pa_nr is not initially zero, or pa->pa_iova is not NULL e4f3f18b12324e Eric Farman 2019-05-15 56 * -ENOMEM if alloc failed 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 57 */ 1331460514ff7d Nicolin Chen 2022-07-22 58 static int page_array_alloc(struct page_array *pa, u64 iova, unsigned int len) 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 59 { e4f3f18b12324e Eric Farman 2019-05-15 60 int i; 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 61 1331460514ff7d Nicolin Chen 2022-07-22 62 if (pa->pa_nr || pa->pa_iova) 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 63 return -EINVAL; 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 64 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 65 pa->pa_nr = ((iova & ~PAGE_MASK) + len + (PAGE_SIZE - 1)) >> PAGE_SHIFT; 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 66 if (!pa->pa_nr) 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 67 return -EINVAL; 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 68 1331460514ff7d Nicolin Chen 2022-07-22 @69 pa->pa_iova = kcalloc(pa->pa_nr, 1331460514ff7d Nicolin Chen 2022-07-22 70 sizeof(*pa->pa_iova) + sizeof(*pa->pa_pfn), 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 71 GFP_KERNEL); 1331460514ff7d Nicolin Chen 2022-07-22 72 if (unlikely(!pa->pa_iova)) { c1ab69268d124e Farhan Ali 2019-07-11 73 pa->pa_nr = 0; 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 74 return -ENOMEM; c1ab69268d124e Farhan Ali 2019-07-11 75 } 1331460514ff7d Nicolin Chen 2022-07-22 @76 pa->pa_pfn = (unsigned long *)&pa->pa_iova[pa->pa_nr]; 0a19e61e6d4c61 Dong Jia Shi 2017-03-17 77 1331460514ff7d Nicolin Chen 2022-07-22 78 pa->pa_iova[0] = iova; c34a12e6a3df3a Eric Farman 2019-05-15 79 pa->pa_pfn[0] = -1ULL; c34a12e6a3df3a Eric Farman 2019-05-15 80 for (i = 1; i < pa->pa_nr; i++) { 1331460514ff7d Nicolin Chen 2022-07-22 81 pa->pa_iova[i] = pa->pa_iova[i - 1] + PAGE_SIZE; c34a12e6a3df3a Eric Farman 2019-05-15 82 pa->pa_pfn[i] = -1ULL; c34a12e6a3df3a Eric Farman 2019-05-15 83 } 5c1cfb1c3948fe Dong Jia Shi 2018-05-23 84 e4f3f18b12324e Eric Farman 2019-05-15 85 return 0; e4f3f18b12324e Eric Farman 2019-05-15 86 } e4f3f18b12324e Eric Farman 2019-05-15 87 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
