tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
head:   39f9137268ee3df0047706df4e9b7357a40ffc98
commit: 7b9148dcb74a004a4df10df3af9239a46dfc2b2f [108/110] staging: vchiq: 
Combine vchiq platform code into single file
config: powerpc64-randconfig-r011-20210728 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
c49df15c278857adecd12db6bb1cdc96885f7079)
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
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=7b9148dcb74a004a4df10df3af9239a46dfc2b2f
        git remote add staging 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
        git fetch --no-tags staging staging-testing
        git checkout 7b9148dcb74a004a4df10df3af9239a46dfc2b2f
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 
ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>

All warnings (new ones prefixed by >>):

   __do_insb
   ^
   arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
   #define __do_insb(p, b, n)      readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:16:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:225:1: note: expanded from here
   __do_insw
   ^
   arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
   #define __do_insw(p, b, n)      readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:16:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:229:1: note: expanded from here
   __do_insl
   ^
   arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
   #define __do_insl(p, b, n)      readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:16:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:233:1: note: expanded from here
   __do_outsb
   ^
   arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
   #define __do_outsb(p, b, n)     writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:16:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:237:1: note: expanded from here
   __do_outsw
   ^
   arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
   #define __do_outsw(p, b, n)     writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:16:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:241:1: note: expanded from here
   __do_outsl
   ^
   arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
   #define __do_outsl(p, b, n)     writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
>> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:185:16: 
>> warning: result of comparison of constant 419244183493398898 with expression 
>> of type 'unsigned int' is always false 
>> [-Wtautological-constant-out-of-range-compare]
           if (num_pages > (SIZE_MAX - sizeof(struct pagelist) -
           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       
~~~~~~~~~~~~~~~~~^~~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
>> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:185:16: 
>> warning: result of comparison of constant 419244183493398898 with expression 
>> of type 'unsigned int' is always false 
>> [-Wtautological-constant-out-of-range-compare]
           if (num_pages > (SIZE_MAX - sizeof(struct pagelist) -
           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
>> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:185:16: 
>> warning: result of comparison of constant 419244183493398898 with expression 
>> of type 'unsigned int' is always false 
>> [-Wtautological-constant-out-of-range-compare]
           if (num_pages > (SIZE_MAX - sizeof(struct pagelist) -
           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                               ^~~~
   15 warnings generated.


vim +185 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

   152  
   153  /* There is a potential problem with partial cache lines (pages?)
   154   * at the ends of the block when reading. If the CPU accessed anything 
in
   155   * the same line (page?) then it may have pulled old data into the 
cache,
   156   * obscuring the new data underneath. We can solve this by transferring 
the
   157   * partial cache lines separately, and allowing the ARM to copy into the
   158   * cached area.
   159   */
   160  
   161  static struct vchiq_pagelist_info *
   162  create_pagelist(char *buf, char __user *ubuf,
   163                  size_t count, unsigned short type)
   164  {
   165          struct pagelist *pagelist;
   166          struct vchiq_pagelist_info *pagelistinfo;
   167          struct page **pages;
   168          u32 *addrs;
   169          unsigned int num_pages, offset, i, k;
   170          int actual_pages;
   171          size_t pagelist_size;
   172          struct scatterlist *scatterlist, *sg;
   173          int dma_buffers;
   174          dma_addr_t dma_addr;
   175  
   176          if (count >= INT_MAX - PAGE_SIZE)
   177                  return NULL;
   178  
   179          if (buf)
   180                  offset = (uintptr_t)buf & (PAGE_SIZE - 1);
   181          else
   182                  offset = (uintptr_t)ubuf & (PAGE_SIZE - 1);
   183          num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE);
   184  
 > 185          if (num_pages > (SIZE_MAX - sizeof(struct pagelist) -
   186                           sizeof(struct vchiq_pagelist_info)) /
   187                          (sizeof(u32) + sizeof(pages[0]) +
   188                           sizeof(struct scatterlist)))
   189                  return NULL;
   190  
   191          pagelist_size = sizeof(struct pagelist) +
   192                          (num_pages * sizeof(u32)) +
   193                          (num_pages * sizeof(pages[0]) +
   194                          (num_pages * sizeof(struct scatterlist))) +
   195                          sizeof(struct vchiq_pagelist_info);
   196  
   197          /* Allocate enough storage to hold the page pointers and the 
page
   198           * list
   199           */
   200          pagelist = dma_alloc_coherent(g_dev, pagelist_size, &dma_addr,
   201                                        GFP_KERNEL);
   202  
   203          vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, 
pagelist);
   204  
   205          if (!pagelist)
   206                  return NULL;
   207  
   208          addrs           = pagelist->addrs;
   209          pages           = (struct page **)(addrs + num_pages);
   210          scatterlist     = (struct scatterlist *)(pages + num_pages);
   211          pagelistinfo    = (struct vchiq_pagelist_info *)
   212                            (scatterlist + num_pages);
   213  
   214          pagelist->length = count;
   215          pagelist->type = type;
   216          pagelist->offset = offset;
   217  
   218          /* Populate the fields of the pagelistinfo structure */
   219          pagelistinfo->pagelist = pagelist;
   220          pagelistinfo->pagelist_buffer_size = pagelist_size;
   221          pagelistinfo->dma_addr = dma_addr;
   222          pagelistinfo->dma_dir =  (type == PAGELIST_WRITE) ?
   223                                    DMA_TO_DEVICE : DMA_FROM_DEVICE;
   224          pagelistinfo->num_pages = num_pages;
   225          pagelistinfo->pages_need_release = 0;
   226          pagelistinfo->pages = pages;
   227          pagelistinfo->scatterlist = scatterlist;
   228          pagelistinfo->scatterlist_mapped = 0;
   229  
   230          if (buf) {
   231                  unsigned long length = count;
   232                  unsigned int off = offset;
   233  
   234                  for (actual_pages = 0; actual_pages < num_pages;
   235                       actual_pages++) {
   236                          struct page *pg =
   237                                  vmalloc_to_page((buf +
   238                                                   (actual_pages * 
PAGE_SIZE)));
   239                          size_t bytes = PAGE_SIZE - off;
   240  
   241                          if (!pg) {
   242                                  cleanup_pagelistinfo(pagelistinfo);
   243                                  return NULL;
   244                          }
   245  
   246                          if (bytes > length)
   247                                  bytes = length;
   248                          pages[actual_pages] = pg;
   249                          length -= bytes;
   250                          off = 0;
   251                  }
   252                  /* do not try and release vmalloc pages */
   253          } else {
   254                  actual_pages = pin_user_pages_fast(
   255                                            (unsigned long)ubuf & 
PAGE_MASK,
   256                                            num_pages,
   257                                            type == PAGELIST_READ,
   258                                            pages);
   259  
   260                  if (actual_pages != num_pages) {
   261                          vchiq_log_info(vchiq_arm_log_level,
   262                                         "%s - only %d/%d pages locked",
   263                                         __func__, actual_pages, 
num_pages);
   264  
   265                          /* This is probably due to the process being 
killed */
   266                          if (actual_pages > 0)
   267                                  unpin_user_pages(pages, actual_pages);
   268                          cleanup_pagelistinfo(pagelistinfo);
   269                          return NULL;
   270                  }
   271                   /* release user pages */
   272                  pagelistinfo->pages_need_release = 1;
   273          }
   274  
   275          /*
   276           * Initialize the scatterlist so that the magic cookie
   277           *  is filled if debugging is enabled
   278           */
   279          sg_init_table(scatterlist, num_pages);
   280          /* Now set the pages for each scatterlist */
   281          for (i = 0; i < num_pages; i++) {
   282                  unsigned int len = PAGE_SIZE - offset;
   283  
   284                  if (len > count)
   285                          len = count;
   286                  sg_set_page(scatterlist + i, pages[i], len, offset);
   287                  offset = 0;
   288                  count -= len;
   289          }
   290  
   291          dma_buffers = dma_map_sg(g_dev,
   292                                   scatterlist,
   293                                   num_pages,
   294                                   pagelistinfo->dma_dir);
   295  
   296          if (dma_buffers == 0) {
   297                  cleanup_pagelistinfo(pagelistinfo);
   298                  return NULL;
   299          }
   300  
   301          pagelistinfo->scatterlist_mapped = 1;
   302  
   303          /* Combine adjacent blocks for performance */
   304          k = 0;
   305          for_each_sg(scatterlist, sg, dma_buffers, i) {
   306                  u32 len = sg_dma_len(sg);
   307                  u32 addr = sg_dma_address(sg);
   308  
   309                  /* Note: addrs is the address + page_count - 1
   310                   * The firmware expects blocks after the first to be 
page-
   311                   * aligned and a multiple of the page size
   312                   */
   313                  WARN_ON(len == 0);
   314                  WARN_ON(i && (i != (dma_buffers - 1)) && (len & 
~PAGE_MASK));
   315                  WARN_ON(i && (addr & ~PAGE_MASK));
   316                  if (k > 0 &&
   317                      ((addrs[k - 1] & PAGE_MASK) +
   318                       (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT))
   319                      == (addr & PAGE_MASK))
   320                          addrs[k - 1] += ((len + PAGE_SIZE - 1) >> 
PAGE_SHIFT);
   321                  else
   322                          addrs[k++] = (addr & PAGE_MASK) |
   323                                  (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) 
- 1);
   324          }
   325  
   326          /* Partial cache lines (fragments) require special measures */
   327          if ((type == PAGELIST_READ) &&
   328                  ((pagelist->offset & (g_cache_line_size - 1)) ||
   329                  ((pagelist->offset + pagelist->length) &
   330                  (g_cache_line_size - 1)))) {
   331                  char *fragments;
   332  
   333                  if (down_interruptible(&g_free_fragments_sema)) {
   334                          cleanup_pagelistinfo(pagelistinfo);
   335                          return NULL;
   336                  }
   337  
   338                  WARN_ON(!g_free_fragments);
   339  
   340                  down(&g_free_fragments_mutex);
   341                  fragments = g_free_fragments;
   342                  WARN_ON(!fragments);
   343                  g_free_fragments = *(char **) g_free_fragments;
   344                  up(&g_free_fragments_mutex);
   345                  pagelist->type = PAGELIST_READ_WITH_FRAGMENTS +
   346                          (fragments - g_fragments_base) / 
g_fragments_size;
   347          }
   348  
   349          return pagelistinfo;
   350  }
   351  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org

Attachment: .config.gz
Description: application/gzip

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to