drivers/char/tpm/tpm_ibmvtpm.c:130:30: sparse: sparse: cast removes address space '__iomem' of expression

From: kernel test robot
Date: Sat Aug 08 2020 - 23:36:13 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 06a81c1c7db9bd5de0bd38cd5acc44bb22b99150
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to define address spaces
date: 7 weeks ago
config: powerpc64-randconfig-s032-20200808 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.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.2-118-ge1578773-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=powerpc64

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


sparse warnings: (new ones prefixed by >>)

>> drivers/char/tpm/tpm_ibmvtpm.c:130:30: sparse: sparse: cast removes address space '__iomem' of expression
>> drivers/char/tpm/tpm_ibmvtpm.c:131:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void * @@ got void [noderef] __iomem *rtce_buf @@
drivers/char/tpm/tpm_ibmvtpm.c:131:23: sparse: expected void *
>> drivers/char/tpm/tpm_ibmvtpm.c:131:23: sparse: got void [noderef] __iomem *rtce_buf
drivers/char/tpm/tpm_ibmvtpm.c:234:17: sparse: sparse: cast removes address space '__iomem' of expression
>> drivers/char/tpm/tpm_ibmvtpm.c:369:30: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *rtce_buf @@
drivers/char/tpm/tpm_ibmvtpm.c:369:30: sparse: expected void const *
drivers/char/tpm/tpm_ibmvtpm.c:369:30: sparse: got void [noderef] __iomem *rtce_buf
>> drivers/char/tpm/tpm_ibmvtpm.c:530:43: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *rtce_buf @@ got void * @@
>> drivers/char/tpm/tpm_ibmvtpm.c:530:43: sparse: expected void [noderef] __iomem *rtce_buf
drivers/char/tpm/tpm_ibmvtpm.c:530:43: sparse: got void *
>> drivers/char/tpm/tpm_ibmvtpm.c:537:52: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *ptr @@ got void [noderef] __iomem *rtce_buf @@
drivers/char/tpm/tpm_ibmvtpm.c:537:52: sparse: expected void *ptr
drivers/char/tpm/tpm_ibmvtpm.c:537:52: sparse: got void [noderef] __iomem *rtce_buf
drivers/char/tpm/tpm_ibmvtpm.c:543:46: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *rtce_buf @@
drivers/char/tpm/tpm_ibmvtpm.c:543:46: sparse: expected void const *
drivers/char/tpm/tpm_ibmvtpm.c:543:46: sparse: got void [noderef] __iomem *rtce_buf
--
drivers/vfio/pci/vfio_pci_nvlink2.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, drivers/vfio/pci/trace.h):
include/trace/../../drivers/vfio/pci/trace.h:17:1: sparse: sparse: incorrect type in assignment (different base types) @@ expected int ret @@ got restricted vm_fault_t [usertype] ret @@
include/trace/../../drivers/vfio/pci/trace.h:17:1: sparse: expected int ret
include/trace/../../drivers/vfio/pci/trace.h:17:1: sparse: got restricted vm_fault_t [usertype] ret
>> drivers/vfio/pci/vfio_pci_nvlink2.c:76:40: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void *to @@ got void [noderef] __iomem * @@
drivers/vfio/pci/vfio_pci_nvlink2.c:76:40: sparse: expected void *to
>> drivers/vfio/pci/vfio_pci_nvlink2.c:76:40: sparse: got void [noderef] __iomem *
>> drivers/vfio/pci/vfio_pci_nvlink2.c:81:43: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const *from @@ got void [noderef] __iomem * @@
drivers/vfio/pci/vfio_pci_nvlink2.c:81:43: sparse: expected void const *from
drivers/vfio/pci/vfio_pci_nvlink2.c:81:43: sparse: got void [noderef] __iomem *

vim +/__iomem +130 drivers/char/tpm/tpm_ibmvtpm.c

132f7629474424 Ashley Lai 2012-08-22 94
132f7629474424 Ashley Lai 2012-08-22 95 /**
132f7629474424 Ashley Lai 2012-08-22 96 * tpm_ibmvtpm_recv - Receive data after send
93c12f293f8798 Winkler, Tomas 2016-11-23 97 *
132f7629474424 Ashley Lai 2012-08-22 98 * @chip: tpm chip struct
132f7629474424 Ashley Lai 2012-08-22 99 * @buf: buffer to read
93c12f293f8798 Winkler, Tomas 2016-11-23 100 * @count: size of buffer
132f7629474424 Ashley Lai 2012-08-22 101 *
93c12f293f8798 Winkler, Tomas 2016-11-23 102 * Return:
132f7629474424 Ashley Lai 2012-08-22 103 * Number of bytes read
132f7629474424 Ashley Lai 2012-08-22 104 */
132f7629474424 Ashley Lai 2012-08-22 105 static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
132f7629474424 Ashley Lai 2012-08-22 106 {
9e0d39d8a6a0a8 Christophe Ricard 2016-03-31 107 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
132f7629474424 Ashley Lai 2012-08-22 108 u16 len;
b5666502700855 Ashley Lai 2012-09-12 109 int sig;
132f7629474424 Ashley Lai 2012-08-22 110
132f7629474424 Ashley Lai 2012-08-22 111 if (!ibmvtpm->rtce_buf) {
132f7629474424 Ashley Lai 2012-08-22 112 dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
132f7629474424 Ashley Lai 2012-08-22 113 return 0;
132f7629474424 Ashley Lai 2012-08-22 114 }
132f7629474424 Ashley Lai 2012-08-22 115
6674ff145eef1f Stefan Berger 2015-12-09 116 sig = wait_event_interruptible(ibmvtpm->wq, !ibmvtpm->tpm_processing_cmd);
b5666502700855 Ashley Lai 2012-09-12 117 if (sig)
b5666502700855 Ashley Lai 2012-09-12 118 return -EINTR;
b5666502700855 Ashley Lai 2012-09-12 119
b5666502700855 Ashley Lai 2012-09-12 120 len = ibmvtpm->res_len;
132f7629474424 Ashley Lai 2012-08-22 121
b5666502700855 Ashley Lai 2012-09-12 122 if (count < len) {
132f7629474424 Ashley Lai 2012-08-22 123 dev_err(ibmvtpm->dev,
37ab03414829e5 Jason Gunthorpe 2013-09-14 124 "Invalid size in recv: count=%zd, crq_size=%d\n",
b5666502700855 Ashley Lai 2012-09-12 125 count, len);
132f7629474424 Ashley Lai 2012-08-22 126 return -EIO;
132f7629474424 Ashley Lai 2012-08-22 127 }
132f7629474424 Ashley Lai 2012-08-22 128
132f7629474424 Ashley Lai 2012-08-22 129 spin_lock(&ibmvtpm->rtce_lock);
b5666502700855 Ashley Lai 2012-09-12 @130 memcpy((void *)buf, (void *)ibmvtpm->rtce_buf, len);
b5666502700855 Ashley Lai 2012-09-12 @131 memset(ibmvtpm->rtce_buf, 0, len);
b5666502700855 Ashley Lai 2012-09-12 132 ibmvtpm->res_len = 0;
132f7629474424 Ashley Lai 2012-08-22 133 spin_unlock(&ibmvtpm->rtce_lock);
132f7629474424 Ashley Lai 2012-08-22 134 return len;
132f7629474424 Ashley Lai 2012-08-22 135 }
132f7629474424 Ashley Lai 2012-08-22 136

:::::: The code at line 130 was first introduced by commit
:::::: b5666502700855a1eb1a15482005b22478b9460e drivers/char/tpm: remove tasklet and cleanup

:::::: TO: Ashley Lai <adlai@xxxxxxxxxxxxxxxxxx>
:::::: CC: Kent Yoder <key@xxxxxxxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip