Linux PCI subsystem development
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Hans Zhang <18255117159@163.com>, manivannan.sadhasivam@linaro.org
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	kw@linux.com, kishon@kernel.org, arnd@arndb.de,
	gregkh@linuxfoundation.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, rockswang7@gmail.com,
	Hans Zhang <18255117159@163.com>,
	kernel test robot <lkp@intel.com>,
	Niklas Cassel <cassel@kernel.org>
Subject: Re: [v6] misc: pci_endpoint_test: Fix overflow of bar_size
Date: Fri, 3 Jan 2025 04:46:01 +0800	[thread overview]
Message-ID: <202501030414.p0DE9xNK-lkp@intel.com> (raw)
In-Reply-To: <20250102120222.1403906-1-18255117159@163.com>

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@intel.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

      parent reply	other threads:[~2025-01-02 20:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02 12:02 [v6] misc: pci_endpoint_test: Fix overflow of bar_size Hans Zhang
2025-01-02 12:21 ` Niklas Cassel
2025-01-02 18:52 ` kernel test robot
2025-01-02 20:46 ` kernel test robot [this message]

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=202501030414.p0DE9xNK-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=18255117159@163.com \
    --cc=arnd@arndb.de \
    --cc=cassel@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rockswang7@gmail.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