public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
@ 2022-03-28  3:04 kernel test robot
  2022-03-29  6:56 ` Christoph Hellwig
  2022-03-31  8:43 ` Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: kernel test robot @ 2022-03-28  3:04 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: kbuild-all, linux-kernel, Christoph Hellwig

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f82da161ea75dc4db21b2499e4b1facd36dab275
commit: a97b693c3712f040c5802f32b2d685352e08cefa uaccess: fix nios2 and microblaze get_user_8()
date:   4 weeks ago
config: microblaze-randconfig-s032-20220328 (https://download.01.org/0day-ci/archive/20220328/202203281004.InhLOFxn-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a97b693c3712f040c5802f32b2d685352e08cefa
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout a97b693c3712f040c5802f32b2d685352e08cefa
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/pci/

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


sparse warnings: (new ones prefixed by >>)
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:150:17: sparse: sparse: cast to restricted __le16
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
   drivers/pci/proc.c:159:17: sparse: sparse: cast to restricted __le32
   drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:168:17: sparse: sparse: cast to restricted __le16

vim +150 drivers/pci/proc.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  112  
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  113  static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  114  				  size_t nbytes, loff_t *ppos)
^1da177e4c3f41 Linus Torvalds  2005-04-16  115  {
496ad9aa8ef448 Al Viro         2013-01-23  116  	struct inode *ino = file_inode(file);
359745d78351c6 Muchun Song     2022-01-21  117  	struct pci_dev *dev = pde_data(ino);
^1da177e4c3f41 Linus Torvalds  2005-04-16  118  	int pos = *ppos;
d9dda78bad8795 Al Viro         2013-03-31  119  	int size = dev->cfg_size;
eb627e17727ebe Matthew Garrett 2019-08-19  120  	int cnt, ret;
eb627e17727ebe Matthew Garrett 2019-08-19  121  
eb627e17727ebe Matthew Garrett 2019-08-19  122  	ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
eb627e17727ebe Matthew Garrett 2019-08-19  123  	if (ret)
eb627e17727ebe Matthew Garrett 2019-08-19  124  		return ret;
^1da177e4c3f41 Linus Torvalds  2005-04-16  125  
^1da177e4c3f41 Linus Torvalds  2005-04-16  126  	if (pos >= size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  127  		return 0;
^1da177e4c3f41 Linus Torvalds  2005-04-16  128  	if (nbytes >= size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  129  		nbytes = size;
^1da177e4c3f41 Linus Torvalds  2005-04-16  130  	if (pos + nbytes > size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  131  		nbytes = size - pos;
^1da177e4c3f41 Linus Torvalds  2005-04-16  132  	cnt = nbytes;
^1da177e4c3f41 Linus Torvalds  2005-04-16  133  
96d4f267e40f95 Linus Torvalds  2019-01-03  134  	if (!access_ok(buf, cnt))
^1da177e4c3f41 Linus Torvalds  2005-04-16  135  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds  2005-04-16  136  
b3c32c4f9565f9 Huang Ying      2012-10-25  137  	pci_config_pm_runtime_get(dev);
b3c32c4f9565f9 Huang Ying      2012-10-25  138  
^1da177e4c3f41 Linus Torvalds  2005-04-16  139  	if ((pos & 1) && cnt) {
^1da177e4c3f41 Linus Torvalds  2005-04-16  140  		unsigned char val;
^1da177e4c3f41 Linus Torvalds  2005-04-16  141  		__get_user(val, buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  142  		pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds  2005-04-16  143  		buf++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  144  		pos++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  145  		cnt--;
^1da177e4c3f41 Linus Torvalds  2005-04-16  146  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  147  
^1da177e4c3f41 Linus Torvalds  2005-04-16  148  	if ((pos & 3) && cnt > 2) {
f17a077e61b627 Harvey Harrison 2008-07-22  149  		__le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @150  		__get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  151  		pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  152  		buf += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  153  		pos += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  154  		cnt -= 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  155  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  156  
^1da177e4c3f41 Linus Torvalds  2005-04-16  157  	while (cnt >= 4) {
f17a077e61b627 Harvey Harrison 2008-07-22  158  		__le32 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @159  		__get_user(val, (__le32 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  160  		pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  161  		buf += 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  162  		pos += 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  163  		cnt -= 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  164  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  165  
^1da177e4c3f41 Linus Torvalds  2005-04-16  166  	if (cnt >= 2) {
f17a077e61b627 Harvey Harrison 2008-07-22  167  		__le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22  168  		__get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  169  		pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  170  		buf += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  171  		pos += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  172  		cnt -= 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  173  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  174  
^1da177e4c3f41 Linus Torvalds  2005-04-16  175  	if (cnt) {
^1da177e4c3f41 Linus Torvalds  2005-04-16  176  		unsigned char val;
^1da177e4c3f41 Linus Torvalds  2005-04-16  177  		__get_user(val, buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  178  		pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds  2005-04-16  179  		buf++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  180  		pos++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  181  		cnt--;
^1da177e4c3f41 Linus Torvalds  2005-04-16  182  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  183  
b3c32c4f9565f9 Huang Ying      2012-10-25  184  	pci_config_pm_runtime_put(dev);
b3c32c4f9565f9 Huang Ying      2012-10-25  185  
^1da177e4c3f41 Linus Torvalds  2005-04-16  186  	*ppos = pos;
d9dda78bad8795 Al Viro         2013-03-31  187  	i_size_write(ino, dev->cfg_size);
^1da177e4c3f41 Linus Torvalds  2005-04-16  188  	return nbytes;
^1da177e4c3f41 Linus Torvalds  2005-04-16  189  }
^1da177e4c3f41 Linus Torvalds  2005-04-16  190  

:::::: The code at line 150 was first introduced by commit
:::::: f17a077e61b627e58db5926bc474cf308318dad9 PCI: fixup sparse endianness warnings in proc.c

:::::: TO: Harvey Harrison <harvey.harrison@gmail.com>
:::::: CC: Jesse Barnes <jbarnes@virtuousgeek.org>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
  2022-03-28  3:04 drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer kernel test robot
@ 2022-03-29  6:56 ` Christoph Hellwig
  2022-03-31  8:43 ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-03-29  6:56 UTC (permalink / raw)
  To: kernel test robot
  Cc: Arnd Bergmann, kbuild-all, linux-kernel, Christoph Hellwig

Looks like new uaccess code doesn't handle sparse __bitwise annotations.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
@ 2022-03-31  7:42 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-03-31  7:42 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: kbuild-all, linux-kernel, Christoph Hellwig

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   787af64d05cd528aac9ad16752d11bb1c6061bb9
commit: a97b693c3712f040c5802f32b2d685352e08cefa uaccess: fix nios2 and microblaze get_user_8()
date:   5 weeks ago
config: microblaze-randconfig-s032-20220331 (https://download.01.org/0day-ci/archive/20220331/202203311536.W1IL3Too-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a97b693c3712f040c5802f32b2d685352e08cefa
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout a97b693c3712f040c5802f32b2d685352e08cefa
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/pci/

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


sparse warnings: (new ones prefixed by >>)
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:150:17: sparse: sparse: cast to restricted __le16
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
   drivers/pci/proc.c:159:17: sparse: sparse: cast to restricted __le32
   drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:168:17: sparse: sparse: cast to restricted __le16

vim +150 drivers/pci/proc.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  112  
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  113  static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  114  				  size_t nbytes, loff_t *ppos)
^1da177e4c3f41 Linus Torvalds  2005-04-16  115  {
496ad9aa8ef448 Al Viro         2013-01-23  116  	struct inode *ino = file_inode(file);
359745d78351c6 Muchun Song     2022-01-21  117  	struct pci_dev *dev = pde_data(ino);
^1da177e4c3f41 Linus Torvalds  2005-04-16  118  	int pos = *ppos;
d9dda78bad8795 Al Viro         2013-03-31  119  	int size = dev->cfg_size;
eb627e17727ebe Matthew Garrett 2019-08-19  120  	int cnt, ret;
eb627e17727ebe Matthew Garrett 2019-08-19  121  
eb627e17727ebe Matthew Garrett 2019-08-19  122  	ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
eb627e17727ebe Matthew Garrett 2019-08-19  123  	if (ret)
eb627e17727ebe Matthew Garrett 2019-08-19  124  		return ret;
^1da177e4c3f41 Linus Torvalds  2005-04-16  125  
^1da177e4c3f41 Linus Torvalds  2005-04-16  126  	if (pos >= size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  127  		return 0;
^1da177e4c3f41 Linus Torvalds  2005-04-16  128  	if (nbytes >= size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  129  		nbytes = size;
^1da177e4c3f41 Linus Torvalds  2005-04-16  130  	if (pos + nbytes > size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  131  		nbytes = size - pos;
^1da177e4c3f41 Linus Torvalds  2005-04-16  132  	cnt = nbytes;
^1da177e4c3f41 Linus Torvalds  2005-04-16  133  
96d4f267e40f95 Linus Torvalds  2019-01-03  134  	if (!access_ok(buf, cnt))
^1da177e4c3f41 Linus Torvalds  2005-04-16  135  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds  2005-04-16  136  
b3c32c4f9565f9 Huang Ying      2012-10-25  137  	pci_config_pm_runtime_get(dev);
b3c32c4f9565f9 Huang Ying      2012-10-25  138  
^1da177e4c3f41 Linus Torvalds  2005-04-16  139  	if ((pos & 1) && cnt) {
^1da177e4c3f41 Linus Torvalds  2005-04-16  140  		unsigned char val;
^1da177e4c3f41 Linus Torvalds  2005-04-16  141  		__get_user(val, buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  142  		pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds  2005-04-16  143  		buf++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  144  		pos++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  145  		cnt--;
^1da177e4c3f41 Linus Torvalds  2005-04-16  146  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  147  
^1da177e4c3f41 Linus Torvalds  2005-04-16  148  	if ((pos & 3) && cnt > 2) {
f17a077e61b627 Harvey Harrison 2008-07-22  149  		__le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @150  		__get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  151  		pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  152  		buf += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  153  		pos += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  154  		cnt -= 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  155  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  156  
^1da177e4c3f41 Linus Torvalds  2005-04-16  157  	while (cnt >= 4) {
f17a077e61b627 Harvey Harrison 2008-07-22  158  		__le32 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @159  		__get_user(val, (__le32 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  160  		pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  161  		buf += 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  162  		pos += 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  163  		cnt -= 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  164  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  165  
^1da177e4c3f41 Linus Torvalds  2005-04-16  166  	if (cnt >= 2) {
f17a077e61b627 Harvey Harrison 2008-07-22  167  		__le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22  168  		__get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  169  		pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  170  		buf += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  171  		pos += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  172  		cnt -= 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  173  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  174  
^1da177e4c3f41 Linus Torvalds  2005-04-16  175  	if (cnt) {
^1da177e4c3f41 Linus Torvalds  2005-04-16  176  		unsigned char val;
^1da177e4c3f41 Linus Torvalds  2005-04-16  177  		__get_user(val, buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  178  		pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds  2005-04-16  179  		buf++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  180  		pos++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  181  		cnt--;
^1da177e4c3f41 Linus Torvalds  2005-04-16  182  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  183  
b3c32c4f9565f9 Huang Ying      2012-10-25  184  	pci_config_pm_runtime_put(dev);
b3c32c4f9565f9 Huang Ying      2012-10-25  185  
^1da177e4c3f41 Linus Torvalds  2005-04-16  186  	*ppos = pos;
d9dda78bad8795 Al Viro         2013-03-31  187  	i_size_write(ino, dev->cfg_size);
^1da177e4c3f41 Linus Torvalds  2005-04-16  188  	return nbytes;
^1da177e4c3f41 Linus Torvalds  2005-04-16  189  }
^1da177e4c3f41 Linus Torvalds  2005-04-16  190  

:::::: The code at line 150 was first introduced by commit
:::::: f17a077e61b627e58db5926bc474cf308318dad9 PCI: fixup sparse endianness warnings in proc.c

:::::: TO: Harvey Harrison <harvey.harrison@gmail.com>
:::::: CC: Jesse Barnes <jbarnes@virtuousgeek.org>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
  2022-03-28  3:04 drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer kernel test robot
  2022-03-29  6:56 ` Christoph Hellwig
@ 2022-03-31  8:43 ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2022-03-31  8:43 UTC (permalink / raw)
  To: kernel test robot
  Cc: Arnd Bergmann, kbuild-all, Linux Kernel Mailing List,
	Christoph Hellwig, linux-riscv, Openrisc, Stafford Horne,
	Palmer Dabbelt

On Mon, Mar 28, 2022 at 5:04 AM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   f82da161ea75dc4db21b2499e4b1facd36dab275
> commit: a97b693c3712f040c5802f32b2d685352e08cefa uaccess: fix nios2 and microblaze get_user_8()
> date:   4 weeks ago
> config: microblaze-randconfig-s032-20220328 (https://download.01.org/0day-ci/archive/20220328/202203281004.InhLOFxn-lkp@intel.com/config)
> compiler: microblaze-linux-gcc (GCC) 11.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # apt-get install sparse
>         # sparse version: v0.6.4-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a97b693c3712f040c5802f32b2d685352e08cefa
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout a97b693c3712f040c5802f32b2d685352e08cefa
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/pci/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
> >> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
>    drivers/pci/proc.c:150:17: sparse: sparse: cast to restricted __le16
> >> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
> >> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
>    drivers/pci/proc.c:159:17: sparse: sparse: cast to restricted __le32
>    drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
>    drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
>    drivers/pci/proc.c:168:17: sparse: sparse: cast to restricted __le16

On Tue, Mar 29, 2022 at 8:56 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Looks like new uaccess code doesn't handle sparse __bitwise annotations.

Right. I copied the line that caused this from 32-bit riscv, which has the same
issue, same on openrisc after d877322bc1ad ("openrisc: Fix issue with
get_user for
64-bit values").

It sounds like we should fix all three of these the same way, any
suggestion which
architecture to copy from?

       Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

* drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
@ 2022-06-04  7:54 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-06-04  7:54 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: kbuild-all, linux-kernel, Christoph Hellwig

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   032dcf09e2bf7c822be25b4abef7a6c913870d98
commit: a97b693c3712f040c5802f32b2d685352e08cefa uaccess: fix nios2 and microblaze get_user_8()
date:   3 months ago
config: microblaze-randconfig-s032-20220603 (https://download.01.org/0day-ci/archive/20220604/202206041544.Y1lQqqa6-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-18-g56afb504-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a97b693c3712f040c5802f32b2d685352e08cefa
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout a97b693c3712f040c5802f32b2d685352e08cefa
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/pci/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
>> drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:150:17: sparse: sparse: cast to restricted __le16
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
>> drivers/pci/proc.c:159:17: sparse: sparse: restricted __le32 degrades to integer
   drivers/pci/proc.c:159:17: sparse: sparse: cast to restricted __le32
   drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:168:17: sparse: sparse: restricted __le16 degrades to integer
   drivers/pci/proc.c:168:17: sparse: sparse: cast to restricted __le16

vim +150 drivers/pci/proc.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  112  
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  113  static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  114  				  size_t nbytes, loff_t *ppos)
^1da177e4c3f41 Linus Torvalds  2005-04-16  115  {
496ad9aa8ef448 Al Viro         2013-01-23  116  	struct inode *ino = file_inode(file);
359745d78351c6 Muchun Song     2022-01-21  117  	struct pci_dev *dev = pde_data(ino);
^1da177e4c3f41 Linus Torvalds  2005-04-16  118  	int pos = *ppos;
d9dda78bad8795 Al Viro         2013-03-31  119  	int size = dev->cfg_size;
eb627e17727ebe Matthew Garrett 2019-08-19  120  	int cnt, ret;
eb627e17727ebe Matthew Garrett 2019-08-19  121  
eb627e17727ebe Matthew Garrett 2019-08-19  122  	ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
eb627e17727ebe Matthew Garrett 2019-08-19  123  	if (ret)
eb627e17727ebe Matthew Garrett 2019-08-19  124  		return ret;
^1da177e4c3f41 Linus Torvalds  2005-04-16  125  
^1da177e4c3f41 Linus Torvalds  2005-04-16  126  	if (pos >= size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  127  		return 0;
^1da177e4c3f41 Linus Torvalds  2005-04-16  128  	if (nbytes >= size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  129  		nbytes = size;
^1da177e4c3f41 Linus Torvalds  2005-04-16  130  	if (pos + nbytes > size)
^1da177e4c3f41 Linus Torvalds  2005-04-16  131  		nbytes = size - pos;
^1da177e4c3f41 Linus Torvalds  2005-04-16  132  	cnt = nbytes;
^1da177e4c3f41 Linus Torvalds  2005-04-16  133  
96d4f267e40f95 Linus Torvalds  2019-01-03  134  	if (!access_ok(buf, cnt))
^1da177e4c3f41 Linus Torvalds  2005-04-16  135  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds  2005-04-16  136  
b3c32c4f9565f9 Huang Ying      2012-10-25  137  	pci_config_pm_runtime_get(dev);
b3c32c4f9565f9 Huang Ying      2012-10-25  138  
^1da177e4c3f41 Linus Torvalds  2005-04-16  139  	if ((pos & 1) && cnt) {
^1da177e4c3f41 Linus Torvalds  2005-04-16  140  		unsigned char val;
^1da177e4c3f41 Linus Torvalds  2005-04-16  141  		__get_user(val, buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  142  		pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds  2005-04-16  143  		buf++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  144  		pos++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  145  		cnt--;
^1da177e4c3f41 Linus Torvalds  2005-04-16  146  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  147  
^1da177e4c3f41 Linus Torvalds  2005-04-16  148  	if ((pos & 3) && cnt > 2) {
f17a077e61b627 Harvey Harrison 2008-07-22  149  		__le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @150  		__get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  151  		pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  152  		buf += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  153  		pos += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  154  		cnt -= 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  155  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  156  
^1da177e4c3f41 Linus Torvalds  2005-04-16  157  	while (cnt >= 4) {
f17a077e61b627 Harvey Harrison 2008-07-22  158  		__le32 val;
f17a077e61b627 Harvey Harrison 2008-07-22 @159  		__get_user(val, (__le32 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  160  		pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  161  		buf += 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  162  		pos += 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  163  		cnt -= 4;
^1da177e4c3f41 Linus Torvalds  2005-04-16  164  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  165  
^1da177e4c3f41 Linus Torvalds  2005-04-16  166  	if (cnt >= 2) {
f17a077e61b627 Harvey Harrison 2008-07-22  167  		__le16 val;
f17a077e61b627 Harvey Harrison 2008-07-22  168  		__get_user(val, (__le16 __user *) buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  169  		pci_user_write_config_word(dev, pos, le16_to_cpu(val));
^1da177e4c3f41 Linus Torvalds  2005-04-16  170  		buf += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  171  		pos += 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  172  		cnt -= 2;
^1da177e4c3f41 Linus Torvalds  2005-04-16  173  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  174  
^1da177e4c3f41 Linus Torvalds  2005-04-16  175  	if (cnt) {
^1da177e4c3f41 Linus Torvalds  2005-04-16  176  		unsigned char val;
^1da177e4c3f41 Linus Torvalds  2005-04-16  177  		__get_user(val, buf);
e04b0ea2e0f9c1 Brian King      2005-09-27  178  		pci_user_write_config_byte(dev, pos, val);
^1da177e4c3f41 Linus Torvalds  2005-04-16  179  		buf++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  180  		pos++;
^1da177e4c3f41 Linus Torvalds  2005-04-16  181  		cnt--;
^1da177e4c3f41 Linus Torvalds  2005-04-16  182  	}
^1da177e4c3f41 Linus Torvalds  2005-04-16  183  
b3c32c4f9565f9 Huang Ying      2012-10-25  184  	pci_config_pm_runtime_put(dev);
b3c32c4f9565f9 Huang Ying      2012-10-25  185  
^1da177e4c3f41 Linus Torvalds  2005-04-16  186  	*ppos = pos;
d9dda78bad8795 Al Viro         2013-03-31  187  	i_size_write(ino, dev->cfg_size);
^1da177e4c3f41 Linus Torvalds  2005-04-16  188  	return nbytes;
^1da177e4c3f41 Linus Torvalds  2005-04-16  189  }
^1da177e4c3f41 Linus Torvalds  2005-04-16  190  

:::::: The code at line 150 was first introduced by commit
:::::: f17a077e61b627e58db5926bc474cf308318dad9 PCI: fixup sparse endianness warnings in proc.c

:::::: TO: Harvey Harrison <harvey.harrison@gmail.com>
:::::: CC: Jesse Barnes <jbarnes@virtuousgeek.org>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-04  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-28  3:04 drivers/pci/proc.c:150:17: sparse: sparse: restricted __le16 degrades to integer kernel test robot
2022-03-29  6:56 ` Christoph Hellwig
2022-03-31  8:43 ` Arnd Bergmann
  -- strict thread matches above, loose matches on Subject: below --
2022-03-31  7:42 kernel test robot
2022-06-04  7:54 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox