Content-Type: multipart/mixed; boundary="===============4328792931016750382==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: drivers/vfio/pci/vfio_pci_igd.c:146:21: sparse: sparse: incorrect type in assignment (different base types) Date: Mon, 29 Nov 2021 00:13:20 +0800 Message-ID: <202111290026.O3vehj03-lkp@intel.com> List-Id: --===============4328792931016750382== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: 3498e7f2bb415e447354a3debef6738d9655768c commit: 179209fa12709a3df8888c323b37315da2683c24 vfio: IOMMU_API should be = selected date: 9 months ago config: i386-randconfig-s002-20211117 (https://download.01.org/0day-ci/arch= ive/20211129/202111290026.O3vehj03-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-dirty # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.gi= t/commit/?id=3D179209fa12709a3df8888c323b37315da2683c24 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/gi= t/torvalds/linux.git git fetch --no-tags linus master git checkout 179209fa12709a3df8888c323b37315da2683c24 # save the config file to linux build tree make W=3D1 C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=3D= build_dir ARCH=3Di386 SHELL=3D/bin/bash drivers/vfio/pci/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> drivers/vfio/pci/vfio_pci_igd.c:146:21: sparse: sparse: incorrect type i= n assignment (different base types) @@ expected unsigned short [address= able] [usertype] val @@ got restricted __le16 [usertype] @@ drivers/vfio/pci/vfio_pci_igd.c:146:21: sparse: expected unsigned sh= ort [addressable] [usertype] val drivers/vfio/pci/vfio_pci_igd.c:146:21: sparse: got restricted __le1= 6 [usertype] >> drivers/vfio/pci/vfio_pci_igd.c:161:21: sparse: sparse: incorrect type i= n assignment (different base types) @@ expected unsigned int [addressab= le] [usertype] val @@ got restricted __le32 [usertype] @@ drivers/vfio/pci/vfio_pci_igd.c:161:21: sparse: expected unsigned in= t [addressable] [usertype] val drivers/vfio/pci/vfio_pci_igd.c:161:21: sparse: got restricted __le3= 2 [usertype] drivers/vfio/pci/vfio_pci_igd.c:176:21: sparse: sparse: incorrect type i= n assignment (different base types) @@ expected unsigned short [address= able] [usertype] val @@ got restricted __le16 [usertype] @@ drivers/vfio/pci/vfio_pci_igd.c:176:21: sparse: expected unsigned sh= ort [addressable] [usertype] val drivers/vfio/pci/vfio_pci_igd.c:176:21: sparse: got restricted __le1= 6 [usertype] vim +146 drivers/vfio/pci/vfio_pci_igd.c f572a960a15e8b Alex Williamson 2016-02-22 109 = f572a960a15e8b Alex Williamson 2016-02-22 110 static size_t vfio_pci_igd_= cfg_rw(struct vfio_pci_device *vdev, f572a960a15e8b Alex Williamson 2016-02-22 111 char __user *buf, siz= e_t count, loff_t *ppos, f572a960a15e8b Alex Williamson 2016-02-22 112 bool iswrite) f572a960a15e8b Alex Williamson 2016-02-22 113 { f572a960a15e8b Alex Williamson 2016-02-22 114 unsigned int i =3D VFIO_PC= I_OFFSET_TO_INDEX(*ppos) - VFIO_PCI_NUM_REGIONS; f572a960a15e8b Alex Williamson 2016-02-22 115 struct pci_dev *pdev =3D v= dev->region[i].data; f572a960a15e8b Alex Williamson 2016-02-22 116 loff_t pos =3D *ppos & VFI= O_PCI_OFFSET_MASK; f572a960a15e8b Alex Williamson 2016-02-22 117 size_t size; f572a960a15e8b Alex Williamson 2016-02-22 118 int ret; f572a960a15e8b Alex Williamson 2016-02-22 119 = f572a960a15e8b Alex Williamson 2016-02-22 120 if (pos >=3D vdev->region[= i].size || iswrite) f572a960a15e8b Alex Williamson 2016-02-22 121 return -EINVAL; f572a960a15e8b Alex Williamson 2016-02-22 122 = f572a960a15e8b Alex Williamson 2016-02-22 123 size =3D count =3D min(cou= nt, (size_t)(vdev->region[i].size - pos)); f572a960a15e8b Alex Williamson 2016-02-22 124 = f572a960a15e8b Alex Williamson 2016-02-22 125 if ((pos & 1) && size) { f572a960a15e8b Alex Williamson 2016-02-22 126 u8 val; f572a960a15e8b Alex Williamson 2016-02-22 127 = f572a960a15e8b Alex Williamson 2016-02-22 128 ret =3D pci_user_read_con= fig_byte(pdev, pos, &val); f572a960a15e8b Alex Williamson 2016-02-22 129 if (ret) 37a682ffbe2ab3 Heiner Kallweit 2021-01-24 130 return ret; f572a960a15e8b Alex Williamson 2016-02-22 131 = f572a960a15e8b Alex Williamson 2016-02-22 132 if (copy_to_user(buf + co= unt - size, &val, 1)) f572a960a15e8b Alex Williamson 2016-02-22 133 return -EFAULT; f572a960a15e8b Alex Williamson 2016-02-22 134 = f572a960a15e8b Alex Williamson 2016-02-22 135 pos++; f572a960a15e8b Alex Williamson 2016-02-22 136 size--; f572a960a15e8b Alex Williamson 2016-02-22 137 } f572a960a15e8b Alex Williamson 2016-02-22 138 = f572a960a15e8b Alex Williamson 2016-02-22 139 if ((pos & 3) && size > 2)= { f572a960a15e8b Alex Williamson 2016-02-22 140 u16 val; f572a960a15e8b Alex Williamson 2016-02-22 141 = f572a960a15e8b Alex Williamson 2016-02-22 142 ret =3D pci_user_read_con= fig_word(pdev, pos, &val); f572a960a15e8b Alex Williamson 2016-02-22 143 if (ret) 37a682ffbe2ab3 Heiner Kallweit 2021-01-24 144 return ret; f572a960a15e8b Alex Williamson 2016-02-22 145 = f572a960a15e8b Alex Williamson 2016-02-22 @146 val =3D cpu_to_le16(val); f572a960a15e8b Alex Williamson 2016-02-22 147 if (copy_to_user(buf + co= unt - size, &val, 2)) f572a960a15e8b Alex Williamson 2016-02-22 148 return -EFAULT; f572a960a15e8b Alex Williamson 2016-02-22 149 = f572a960a15e8b Alex Williamson 2016-02-22 150 pos +=3D 2; f572a960a15e8b Alex Williamson 2016-02-22 151 size -=3D 2; f572a960a15e8b Alex Williamson 2016-02-22 152 } f572a960a15e8b Alex Williamson 2016-02-22 153 = f572a960a15e8b Alex Williamson 2016-02-22 154 while (size > 3) { f572a960a15e8b Alex Williamson 2016-02-22 155 u32 val; f572a960a15e8b Alex Williamson 2016-02-22 156 = f572a960a15e8b Alex Williamson 2016-02-22 157 ret =3D pci_user_read_con= fig_dword(pdev, pos, &val); f572a960a15e8b Alex Williamson 2016-02-22 158 if (ret) 37a682ffbe2ab3 Heiner Kallweit 2021-01-24 159 return ret; f572a960a15e8b Alex Williamson 2016-02-22 160 = f572a960a15e8b Alex Williamson 2016-02-22 @161 val =3D cpu_to_le32(val); f572a960a15e8b Alex Williamson 2016-02-22 162 if (copy_to_user(buf + co= unt - size, &val, 4)) f572a960a15e8b Alex Williamson 2016-02-22 163 return -EFAULT; f572a960a15e8b Alex Williamson 2016-02-22 164 = f572a960a15e8b Alex Williamson 2016-02-22 165 pos +=3D 4; f572a960a15e8b Alex Williamson 2016-02-22 166 size -=3D 4; f572a960a15e8b Alex Williamson 2016-02-22 167 } f572a960a15e8b Alex Williamson 2016-02-22 168 = f572a960a15e8b Alex Williamson 2016-02-22 169 while (size >=3D 2) { f572a960a15e8b Alex Williamson 2016-02-22 170 u16 val; f572a960a15e8b Alex Williamson 2016-02-22 171 = f572a960a15e8b Alex Williamson 2016-02-22 172 ret =3D pci_user_read_con= fig_word(pdev, pos, &val); f572a960a15e8b Alex Williamson 2016-02-22 173 if (ret) 37a682ffbe2ab3 Heiner Kallweit 2021-01-24 174 return ret; f572a960a15e8b Alex Williamson 2016-02-22 175 = f572a960a15e8b Alex Williamson 2016-02-22 176 val =3D cpu_to_le16(val); f572a960a15e8b Alex Williamson 2016-02-22 177 if (copy_to_user(buf + co= unt - size, &val, 2)) f572a960a15e8b Alex Williamson 2016-02-22 178 return -EFAULT; f572a960a15e8b Alex Williamson 2016-02-22 179 = f572a960a15e8b Alex Williamson 2016-02-22 180 pos +=3D 2; f572a960a15e8b Alex Williamson 2016-02-22 181 size -=3D 2; f572a960a15e8b Alex Williamson 2016-02-22 182 } f572a960a15e8b Alex Williamson 2016-02-22 183 = f572a960a15e8b Alex Williamson 2016-02-22 184 while (size) { f572a960a15e8b Alex Williamson 2016-02-22 185 u8 val; f572a960a15e8b Alex Williamson 2016-02-22 186 = f572a960a15e8b Alex Williamson 2016-02-22 187 ret =3D pci_user_read_con= fig_byte(pdev, pos, &val); f572a960a15e8b Alex Williamson 2016-02-22 188 if (ret) 37a682ffbe2ab3 Heiner Kallweit 2021-01-24 189 return ret; f572a960a15e8b Alex Williamson 2016-02-22 190 = f572a960a15e8b Alex Williamson 2016-02-22 191 if (copy_to_user(buf + co= unt - size, &val, 1)) f572a960a15e8b Alex Williamson 2016-02-22 192 return -EFAULT; f572a960a15e8b Alex Williamson 2016-02-22 193 = f572a960a15e8b Alex Williamson 2016-02-22 194 pos++; f572a960a15e8b Alex Williamson 2016-02-22 195 size--; f572a960a15e8b Alex Williamson 2016-02-22 196 } f572a960a15e8b Alex Williamson 2016-02-22 197 = f572a960a15e8b Alex Williamson 2016-02-22 198 *ppos +=3D count; f572a960a15e8b Alex Williamson 2016-02-22 199 = f572a960a15e8b Alex Williamson 2016-02-22 200 return count; f572a960a15e8b Alex Williamson 2016-02-22 201 } f572a960a15e8b Alex Williamson 2016-02-22 202 = :::::: The code at line 146 was first introduced by commit :::::: f572a960a15e8bb56599f6d2358a9c18f0808e91 vfio/pci: Intel IGD host an= d LCP bridge config space access :::::: TO: Alex Williamson :::::: CC: Alex Williamson --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============4328792931016750382==--