linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
@ 2020-08-28  8:53 Luc Van Oostenryck
  2020-08-28 11:15 ` kernel test robot
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Luc Van Oostenryck @ 2020-08-28  8:53 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: linux-kernel, Luc Van Oostenryck

__chk_user_ptr() & __chk_io_ptr() are dummy extern functions which
only exist to enforce the typechecking of __user or __iomem pointers
in macros when using sparse.

This typechecking is done by inserting a call to these functions.
But the presence of these calls can inhibit some simplifications
and so influence the result of sparse's analysis of context/locking.

Fix this by changing these calls into static inline calls with
an empty body.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 include/linux/compiler_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


Hi Miguel,

Could you also take this patch in your queue?
It has already be sent twice but ignored by the other channels.

Many thanks,
-- Luc

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index aaa6f051e78e..01bc5e5ae06c 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -11,8 +11,8 @@
 # define __iomem	__attribute__((noderef, address_space(__iomem)))
 # define __percpu	__attribute__((noderef, address_space(__percpu)))
 # define __rcu		__attribute__((noderef, address_space(__rcu)))
-extern void __chk_user_ptr(const volatile void __user *);
-extern void __chk_io_ptr(const volatile void __iomem *);
+static inline void __chk_user_ptr(const volatile void __user *ptr) { }
+static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
 /* context/locking */
 # define __must_hold(x)	__attribute__((context(x,1,1)))
 # define __acquires(x)	__attribute__((context(x,0,1)))

base-commit: 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
-- 
2.28.0


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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
@ 2020-08-28 11:15 ` kernel test robot
  2020-08-28 11:37 ` kernel test robot
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-08-28 11:15 UTC (permalink / raw)
  To: Luc Van Oostenryck, Miguel Ojeda
  Cc: kbuild-all, linux-kernel, Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 4264 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
base:    9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: i386-randconfig-s001-20200828 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-191-g10164920-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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/w1/slaves/w1_ds28e04.c:342:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got char *buf @@
>> drivers/w1/slaves/w1_ds28e04.c:342:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/w1/slaves/w1_ds28e04.c:342:13: sparse:     got char *buf
>> drivers/w1/slaves/w1_ds28e04.c:356:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got char const *buf @@
   drivers/w1/slaves/w1_ds28e04.c:356:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/w1/slaves/w1_ds28e04.c:356:13: sparse:     got char const *buf

# https://github.com/0day-ci/linux/commit/7d01c91ac34a64f0177bc6d058cc50e805f59102
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
git checkout 7d01c91ac34a64f0177bc6d058cc50e805f59102
vim +342 drivers/w1/slaves/w1_ds28e04.c

fa33a65a9cf7e2 Greg Kroah-Hartman 2013-08-21  338  
fa33a65a9cf7e2 Greg Kroah-Hartman 2013-08-21  339  static ssize_t crccheck_show(struct device *dev, struct device_attribute *attr,
fa33a65a9cf7e2 Greg Kroah-Hartman 2013-08-21  340  			     char *buf)
fbf7f7b4e2ae40 Markus Franke      2012-05-26  341  {
fbf7f7b4e2ae40 Markus Franke      2012-05-26 @342  	if (put_user(w1_enable_crccheck + 0x30, buf))
fbf7f7b4e2ae40 Markus Franke      2012-05-26  343  		return -EFAULT;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  344  
fbf7f7b4e2ae40 Markus Franke      2012-05-26  345  	return sizeof(w1_enable_crccheck);
fbf7f7b4e2ae40 Markus Franke      2012-05-26  346  }
fbf7f7b4e2ae40 Markus Franke      2012-05-26  347  
fa33a65a9cf7e2 Greg Kroah-Hartman 2013-08-21  348  static ssize_t crccheck_store(struct device *dev, struct device_attribute *attr,
fbf7f7b4e2ae40 Markus Franke      2012-05-26  349  			      const char *buf, size_t count)
fbf7f7b4e2ae40 Markus Franke      2012-05-26  350  {
fbf7f7b4e2ae40 Markus Franke      2012-05-26  351  	char val;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  352  
fbf7f7b4e2ae40 Markus Franke      2012-05-26  353  	if (count != 1 || !buf)
fbf7f7b4e2ae40 Markus Franke      2012-05-26  354  		return -EINVAL;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  355  
fbf7f7b4e2ae40 Markus Franke      2012-05-26 @356  	if (get_user(val, buf))
fbf7f7b4e2ae40 Markus Franke      2012-05-26  357  		return -EFAULT;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  358  
fbf7f7b4e2ae40 Markus Franke      2012-05-26  359  	/* convert to decimal */
fbf7f7b4e2ae40 Markus Franke      2012-05-26  360  	val = val - 0x30;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  361  	if (val != 0 && val != 1)
fbf7f7b4e2ae40 Markus Franke      2012-05-26  362  		return -EINVAL;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  363  
fbf7f7b4e2ae40 Markus Franke      2012-05-26  364  	/* set the new value */
fbf7f7b4e2ae40 Markus Franke      2012-05-26  365  	w1_enable_crccheck = val;
fbf7f7b4e2ae40 Markus Franke      2012-05-26  366  
fbf7f7b4e2ae40 Markus Franke      2012-05-26  367  	return sizeof(w1_enable_crccheck);
fbf7f7b4e2ae40 Markus Franke      2012-05-26  368  }
fbf7f7b4e2ae40 Markus Franke      2012-05-26  369  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33137 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
  2020-08-28 11:15 ` kernel test robot
@ 2020-08-28 11:37 ` kernel test robot
  2020-08-28 12:20 ` kernel test robot
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-08-28 11:37 UTC (permalink / raw)
  To: Luc Van Oostenryck, Miguel Ojeda
  Cc: kbuild-all, linux-kernel, Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 6388 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
base:    9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: arc-randconfig-s031-20200828 (attached as .config)
compiler: arceb-elf-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-191-g10164920-dirty
        # 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=arc 

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 >>)

>> arch/arc/kernel/process.c:70:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int *uaddr @@
>> arch/arc/kernel/process.c:70:15: sparse:     expected void const volatile [noderef] __user *ptr
   arch/arc/kernel/process.c:70:15: sparse:     got int *uaddr
   arch/arc/kernel/process.c:77:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int *uaddr @@
   arch/arc/kernel/process.c:77:15: sparse:     expected void const volatile [noderef] __user *ptr
   arch/arc/kernel/process.c:77:15: sparse:     got int *uaddr

# https://github.com/0day-ci/linux/commit/7d01c91ac34a64f0177bc6d058cc50e805f59102
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
git checkout 7d01c91ac34a64f0177bc6d058cc50e805f59102
vim +70 arch/arc/kernel/process.c

bf90e1eab682dcb Vineet Gupta      2013-01-18   45  
91e040a79df73d3 Vineet Gupta      2016-10-20   46  SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
91e040a79df73d3 Vineet Gupta      2016-10-20   47  {
e6e335bf3a400bc Vineet Gupta      2016-11-07   48  	struct pt_regs *regs = current_pt_regs();
e8708786d4fe21c Peter Zijlstra    2018-06-19   49  	u32 uval;
e8708786d4fe21c Peter Zijlstra    2018-06-19   50  	int ret;
91e040a79df73d3 Vineet Gupta      2016-10-20   51  
91e040a79df73d3 Vineet Gupta      2016-10-20   52  	/*
91e040a79df73d3 Vineet Gupta      2016-10-20   53  	 * This is only for old cores lacking LLOCK/SCOND, which by defintion
91e040a79df73d3 Vineet Gupta      2016-10-20   54  	 * can't possibly be SMP. Thus doesn't need to be SMP safe.
91e040a79df73d3 Vineet Gupta      2016-10-20   55  	 * And this also helps reduce the overhead for serializing in
91e040a79df73d3 Vineet Gupta      2016-10-20   56  	 * the UP case
91e040a79df73d3 Vineet Gupta      2016-10-20   57  	 */
91e040a79df73d3 Vineet Gupta      2016-10-20   58  	WARN_ON_ONCE(IS_ENABLED(CONFIG_SMP));
91e040a79df73d3 Vineet Gupta      2016-10-20   59  
e6e335bf3a400bc Vineet Gupta      2016-11-07   60  	/* Z indicates to userspace if operation succeded */
e6e335bf3a400bc Vineet Gupta      2016-11-07   61  	regs->status32 &= ~STATUS_Z_MASK;
e6e335bf3a400bc Vineet Gupta      2016-11-07   62  
96d4f267e40f950 Linus Torvalds    2019-01-03   63  	ret = access_ok(uaddr, sizeof(*uaddr));
e8708786d4fe21c Peter Zijlstra    2018-06-19   64  	if (!ret)
e8708786d4fe21c Peter Zijlstra    2018-06-19   65  		 goto fail;
91e040a79df73d3 Vineet Gupta      2016-10-20   66  
e8708786d4fe21c Peter Zijlstra    2018-06-19   67  again:
91e040a79df73d3 Vineet Gupta      2016-10-20   68  	preempt_disable();
91e040a79df73d3 Vineet Gupta      2016-10-20   69  
e8708786d4fe21c Peter Zijlstra    2018-06-19  @70  	ret = __get_user(uval, uaddr);
e8708786d4fe21c Peter Zijlstra    2018-06-19   71  	if (ret)
e8708786d4fe21c Peter Zijlstra    2018-06-19   72  		 goto fault;
e8708786d4fe21c Peter Zijlstra    2018-06-19   73  
e8708786d4fe21c Peter Zijlstra    2018-06-19   74  	if (uval != expected)
e8708786d4fe21c Peter Zijlstra    2018-06-19   75  		 goto out;
e8708786d4fe21c Peter Zijlstra    2018-06-19   76  
e8708786d4fe21c Peter Zijlstra    2018-06-19   77  	ret = __put_user(new, uaddr);
e8708786d4fe21c Peter Zijlstra    2018-06-19   78  	if (ret)
e8708786d4fe21c Peter Zijlstra    2018-06-19   79  		 goto fault;
91e040a79df73d3 Vineet Gupta      2016-10-20   80  
e6e335bf3a400bc Vineet Gupta      2016-11-07   81  	regs->status32 |= STATUS_Z_MASK;
91e040a79df73d3 Vineet Gupta      2016-10-20   82  
e8708786d4fe21c Peter Zijlstra    2018-06-19   83  out:
91e040a79df73d3 Vineet Gupta      2016-10-20   84  	preempt_enable();
e6e335bf3a400bc Vineet Gupta      2016-11-07   85  	return uval;
e8708786d4fe21c Peter Zijlstra    2018-06-19   86  
e8708786d4fe21c Peter Zijlstra    2018-06-19   87  fault:
e8708786d4fe21c Peter Zijlstra    2018-06-19   88  	preempt_enable();
e8708786d4fe21c Peter Zijlstra    2018-06-19   89  
e8708786d4fe21c Peter Zijlstra    2018-06-19   90  	if (unlikely(ret != -EFAULT))
e8708786d4fe21c Peter Zijlstra    2018-06-19   91  		 goto fail;
e8708786d4fe21c Peter Zijlstra    2018-06-19   92  
d8ed45c5dcd455f Michel Lespinasse 2020-06-08   93  	mmap_read_lock(current->mm);
64019a2e467a288 Peter Xu          2020-08-11   94  	ret = fixup_user_fault(current->mm, (unsigned long) uaddr,
e8708786d4fe21c Peter Zijlstra    2018-06-19   95  			       FAULT_FLAG_WRITE, NULL);
d8ed45c5dcd455f Michel Lespinasse 2020-06-08   96  	mmap_read_unlock(current->mm);
e8708786d4fe21c Peter Zijlstra    2018-06-19   97  
e8708786d4fe21c Peter Zijlstra    2018-06-19   98  	if (likely(!ret))
e8708786d4fe21c Peter Zijlstra    2018-06-19   99  		 goto again;
e8708786d4fe21c Peter Zijlstra    2018-06-19  100  
e8708786d4fe21c Peter Zijlstra    2018-06-19  101  fail:
3cf5d076fb4d489 Eric W. Biederman 2019-05-23  102  	force_sig(SIGSEGV);
e8708786d4fe21c Peter Zijlstra    2018-06-19  103  	return ret;
91e040a79df73d3 Vineet Gupta      2016-10-20  104  }
91e040a79df73d3 Vineet Gupta      2016-10-20  105  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30133 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
  2020-08-28 11:15 ` kernel test robot
  2020-08-28 11:37 ` kernel test robot
@ 2020-08-28 12:20 ` kernel test robot
  2020-08-28 14:21 ` kernel test robot
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-08-28 12:20 UTC (permalink / raw)
  To: Luc Van Oostenryck, Miguel Ojeda
  Cc: kbuild-all, linux-kernel, Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 38331 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
base:    9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: x86_64-randconfig-s021-20200828 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-191-g10164920-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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/firmware/efi/test/efi_test.c:157:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long *[addressable] data_size @@
>> drivers/firmware/efi/test/efi_test.c:157:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:157:13: sparse:     got unsigned long *[addressable] data_size
   drivers/firmware/efi/test/efi_test.c:160:61: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got struct guid_t [usertype] *[addressable] vendor_guid @@
   drivers/firmware/efi/test/efi_test.c:160:61: sparse:     expected void const [noderef] __user *from
   drivers/firmware/efi/test/efi_test.c:160:61: sparse:     got struct guid_t [usertype] *[addressable] vendor_guid
   drivers/firmware/efi/test/efi_test.c:167:60: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected unsigned short [noderef] [usertype] __user *src @@     got unsigned short [usertype] *[addressable] variable_name @@
   drivers/firmware/efi/test/efi_test.c:167:60: sparse:     expected unsigned short [noderef] [usertype] __user *src
   drivers/firmware/efi/test/efi_test.c:167:60: sparse:     got unsigned short [usertype] *[addressable] variable_name
>> drivers/firmware/efi/test/efi_test.c:187:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:187:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:187:13: sparse:     got unsigned long [usertype] *[addressable] status
   drivers/firmware/efi/test/efi_test.c:194:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long *[addressable] data_size @@
   drivers/firmware/efi/test/efi_test.c:194:35: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:194:35: sparse:     got unsigned long *[addressable] data_size
   drivers/firmware/efi/test/efi_test.c:209:45: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got void *[addressable] data @@
   drivers/firmware/efi/test/efi_test.c:209:45: sparse:     expected void [noderef] __user *to
   drivers/firmware/efi/test/efi_test.c:209:45: sparse:     got void *[addressable] data
>> drivers/firmware/efi/test/efi_test.c:215:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] *[addressable] attributes @@
   drivers/firmware/efi/test/efi_test.c:215:19: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:215:19: sparse:     got unsigned int [usertype] *[addressable] attributes
   drivers/firmware/efi/test/efi_test.c:220:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long *[addressable] data_size @@
   drivers/firmware/efi/test/efi_test.c:220:19: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:220:19: sparse:     got unsigned long *[addressable] data_size
   drivers/firmware/efi/test/efi_test.c:243:53: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got struct guid_t [usertype] *[addressable] vendor_guid @@
   drivers/firmware/efi/test/efi_test.c:243:53: sparse:     expected void const [noderef] __user *from
   drivers/firmware/efi/test/efi_test.c:243:53: sparse:     got struct guid_t [usertype] *[addressable] vendor_guid
   drivers/firmware/efi/test/efi_test.c:248:60: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected unsigned short [noderef] [usertype] __user *src @@     got unsigned short [usertype] *[addressable] variable_name @@
   drivers/firmware/efi/test/efi_test.c:248:60: sparse:     expected unsigned short [noderef] [usertype] __user *src
   drivers/firmware/efi/test/efi_test.c:248:60: sparse:     got unsigned short [usertype] *[addressable] variable_name
   drivers/firmware/efi/test/efi_test.c:253:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const [noderef] __user * @@     got void *[addressable] data @@
   drivers/firmware/efi/test/efi_test.c:253:39: sparse:     expected void const [noderef] __user *
   drivers/firmware/efi/test/efi_test.c:253:39: sparse:     got void *[addressable] data
   drivers/firmware/efi/test/efi_test.c:263:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:263:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:263:13: sparse:     got unsigned long [usertype] *[addressable] status
   drivers/firmware/efi/test/efi_test.c:292:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:292:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:292:13: sparse:     got unsigned long [usertype] *[addressable] status
   drivers/firmware/efi/test/efi_test.c:301:27: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct efi_time_cap_t [noderef] [usertype] __user *cap_local @@     got struct efi_time_cap_t [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:301:27: sparse:     expected struct efi_time_cap_t [noderef] [usertype] __user *cap_local
   drivers/firmware/efi/test/efi_test.c:301:27: sparse:     got struct efi_time_cap_t [usertype] *
   drivers/firmware/efi/test/efi_test.c:308:41: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got struct efi_time_t [usertype] *[addressable] time @@
   drivers/firmware/efi/test/efi_test.c:308:41: sparse:     expected void [noderef] __user *to
   drivers/firmware/efi/test/efi_test.c:308:41: sparse:     got struct efi_time_t [usertype] *[addressable] time
   drivers/firmware/efi/test/efi_test.c:325:46: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got struct efi_time_t [usertype] *[addressable] time @@
   drivers/firmware/efi/test/efi_test.c:325:46: sparse:     expected void const [noderef] __user *from
   drivers/firmware/efi/test/efi_test.c:325:46: sparse:     got struct efi_time_t [usertype] *[addressable] time
   drivers/firmware/efi/test/efi_test.c:330:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:330:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:330:13: sparse:     got unsigned long [usertype] *[addressable] status
   drivers/firmware/efi/test/efi_test.c:354:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:354:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:354:13: sparse:     got unsigned long [usertype] *[addressable] status
>> drivers/firmware/efi/test/efi_test.c:360:38: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned char [usertype] *[addressable] enabled @@
   drivers/firmware/efi/test/efi_test.c:360:38: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:360:38: sparse:     got unsigned char [usertype] *[addressable] enabled
   drivers/firmware/efi/test/efi_test.c:365:47: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got struct efi_time_t [usertype] *[addressable] time @@
   drivers/firmware/efi/test/efi_test.c:365:47: sparse:     expected void [noderef] __user *to
   drivers/firmware/efi/test/efi_test.c:365:47: sparse:     got struct efi_time_t [usertype] *[addressable] time
   drivers/firmware/efi/test/efi_test.c:389:60: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got struct efi_time_t [usertype] *[addressable] time @@
   drivers/firmware/efi/test/efi_test.c:389:60: sparse:     expected void const [noderef] __user *from
   drivers/firmware/efi/test/efi_test.c:389:60: sparse:     got struct efi_time_t [usertype] *[addressable] time
   drivers/firmware/efi/test/efi_test.c:397:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:397:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:397:13: sparse:     got unsigned long [usertype] *[addressable] status
>> drivers/firmware/efi/test/efi_test.c:421:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long *[addressable] variable_name_size @@
   drivers/firmware/efi/test/efi_test.c:421:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:421:21: sparse:     got unsigned long *[addressable] variable_name_size
   drivers/firmware/efi/test/efi_test.c:429:52: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got struct guid_t [usertype] *[addressable] vendor_guid @@
   drivers/firmware/efi/test/efi_test.c:429:52: sparse:     expected void const [noderef] __user *from
   drivers/firmware/efi/test/efi_test.c:429:52: sparse:     got struct guid_t [usertype] *[addressable] vendor_guid
   drivers/firmware/efi/test/efi_test.c:439:52: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected unsigned short [noderef] [usertype] __user *src @@     got unsigned short [usertype] *[addressable] variable_name @@
   drivers/firmware/efi/test/efi_test.c:439:52: sparse:     expected unsigned short [noderef] [usertype] __user *src
   drivers/firmware/efi/test/efi_test.c:439:52: sparse:     got unsigned short [usertype] *[addressable] variable_name
   drivers/firmware/efi/test/efi_test.c:452:52: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected unsigned short [noderef] [usertype] __user *src @@     got unsigned short [usertype] *[addressable] variable_name @@
   drivers/firmware/efi/test/efi_test.c:452:52: sparse:     expected unsigned short [noderef] [usertype] __user *src
   drivers/firmware/efi/test/efi_test.c:452:52: sparse:     got unsigned short [usertype] *[addressable] variable_name
   drivers/firmware/efi/test/efi_test.c:461:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:461:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:461:13: sparse:     got unsigned long [usertype] *[addressable] status
   drivers/firmware/efi/test/efi_test.c:468:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long *[addressable] variable_name_size @@
   drivers/firmware/efi/test/efi_test.c:468:35: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:468:35: sparse:     got unsigned long *[addressable] variable_name_size
   drivers/firmware/efi/test/efi_test.c:479:62: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected unsigned short [noderef] [usertype] __user *dst @@     got unsigned short [usertype] *[addressable] variable_name @@
   drivers/firmware/efi/test/efi_test.c:479:62: sparse:     expected unsigned short [noderef] [usertype] __user *dst
   drivers/firmware/efi/test/efi_test.c:479:62: sparse:     got unsigned short [usertype] *[addressable] variable_name
   drivers/firmware/efi/test/efi_test.c:487:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long *[addressable] variable_name_size @@
   drivers/firmware/efi/test/efi_test.c:487:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:487:21: sparse:     got unsigned long *[addressable] variable_name_size
   drivers/firmware/efi/test/efi_test.c:494:53: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got struct guid_t [usertype] *[addressable] vendor_guid @@
   drivers/firmware/efi/test/efi_test.c:494:53: sparse:     expected void [noderef] __user *to
   drivers/firmware/efi/test/efi_test.c:494:53: sparse:     got struct guid_t [usertype] *[addressable] vendor_guid
   drivers/firmware/efi/test/efi_test.c:522:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:522:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:522:13: sparse:     got unsigned long [usertype] *[addressable] status
>> drivers/firmware/efi/test/efi_test.c:529:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] *[addressable] high_count @@
   drivers/firmware/efi/test/efi_test.c:529:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:529:13: sparse:     got unsigned int [usertype] *[addressable] high_count
   drivers/firmware/efi/test/efi_test.c:546:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const [noderef] __user * @@     got void * @@
   drivers/firmware/efi/test/efi_test.c:546:37: sparse:     expected void const [noderef] __user *
   drivers/firmware/efi/test/efi_test.c:546:37: sparse:     got void *
   drivers/firmware/efi/test/efi_test.c:575:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] status @@
   drivers/firmware/efi/test/efi_test.c:575:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:575:13: sparse:     got unsigned long [usertype] *[addressable] status
>> drivers/firmware/efi/test/efi_test.c:581:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] *[addressable] maximum_variable_storage_size @@
   drivers/firmware/efi/test/efi_test.c:581:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:581:13: sparse:     got unsigned long long [usertype] *[addressable] maximum_variable_storage_size
>> drivers/firmware/efi/test/efi_test.c:585:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] *[addressable] remaining_variable_storage_size @@
   drivers/firmware/efi/test/efi_test.c:585:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:585:13: sparse:     got unsigned long long [usertype] *[addressable] remaining_variable_storage_size
   drivers/firmware/efi/test/efi_test.c:589:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] *[addressable] maximum_variable_size @@
   drivers/firmware/efi/test/efi_test.c:589:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:589:13: sparse:     got unsigned long long [usertype] *[addressable] maximum_variable_size
>> drivers/firmware/efi/test/efi_test.c:625:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got struct efi_capsule_header_t [usertype] ** @@
   drivers/firmware/efi/test/efi_test.c:625:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:625:21: sparse:     got struct efi_capsule_header_t [usertype] **
   drivers/firmware/efi/test/efi_test.c:629:50: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got struct efi_capsule_header_t [usertype] *[assigned] c @@
   drivers/firmware/efi/test/efi_test.c:629:50: sparse:     expected void const [noderef] __user *from
   drivers/firmware/efi/test/efi_test.c:629:50: sparse:     got struct efi_capsule_header_t [usertype] *[assigned] c
>> drivers/firmware/efi/test/efi_test.c:643:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long [usertype] *[addressable] [assigned] status @@
   drivers/firmware/efi/test/efi_test.c:643:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:643:13: sparse:     got unsigned long [usertype] *[addressable] [assigned] status
>> drivers/firmware/efi/test/efi_test.c:653:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] *[addressable] [assigned] maximum_capsule_size @@
   drivers/firmware/efi/test/efi_test.c:653:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:653:13: sparse:     got unsigned long long [usertype] *[addressable] [assigned] maximum_capsule_size
>> drivers/firmware/efi/test/efi_test.c:658:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int *[addressable] [assigned] reset_type @@
   drivers/firmware/efi/test/efi_test.c:658:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:658:13: sparse:     got int *[addressable] [assigned] reset_type
   drivers/firmware/efi/test/efi_test.c:35:27: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned short [usertype] *s @@     got unsigned short [noderef] [usertype] __user *str @@
   drivers/firmware/efi/test/efi_test.c:35:27: sparse:     expected unsigned short [usertype] *s
   drivers/firmware/efi/test/efi_test.c:35:27: sparse:     got unsigned short [noderef] [usertype] __user *str
>> drivers/firmware/efi/test/efi_test.c:44:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned short [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:44:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:44:13: sparse:     got unsigned short [usertype] *
   drivers/firmware/efi/test/efi_test.c:50:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned short [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:50:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:50:21: sparse:     got unsigned short [usertype] *
   drivers/firmware/efi/test/efi_test.c:35:27: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned short [usertype] *[assigned] s @@     got unsigned short [noderef] [usertype] __user *str @@
   drivers/firmware/efi/test/efi_test.c:35:27: sparse:     expected unsigned short [usertype] *[assigned] s
   drivers/firmware/efi/test/efi_test.c:35:27: sparse:     got unsigned short [noderef] [usertype] __user *str
>> drivers/firmware/efi/test/efi_test.c:44:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned short [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:44:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:44:13: sparse:     got unsigned short [usertype] *
   drivers/firmware/efi/test/efi_test.c:50:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned short [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:50:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:50:21: sparse:     got unsigned short [usertype] *
   drivers/firmware/efi/test/efi_test.c:35:27: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned short [usertype] *[assigned] s @@     got unsigned short [noderef] [usertype] __user *str @@
   drivers/firmware/efi/test/efi_test.c:35:27: sparse:     expected unsigned short [usertype] *[assigned] s
   drivers/firmware/efi/test/efi_test.c:35:27: sparse:     got unsigned short [noderef] [usertype] __user *str
>> drivers/firmware/efi/test/efi_test.c:44:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned short [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:44:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:44:13: sparse:     got unsigned short [usertype] *
   drivers/firmware/efi/test/efi_test.c:50:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned short [usertype] * @@
   drivers/firmware/efi/test/efi_test.c:50:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/firmware/efi/test/efi_test.c:50:21: sparse:     got unsigned short [usertype] *

# https://github.com/0day-ci/linux/commit/7d01c91ac34a64f0177bc6d058cc50e805f59102
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
git checkout 7d01c91ac34a64f0177bc6d058cc50e805f59102
vim +157 drivers/firmware/efi/test/efi_test.c

ff6301dabc3ca20 Ivan Hu      2016-08-25   26  
ff6301dabc3ca20 Ivan Hu      2016-08-25   27  /*
ff6301dabc3ca20 Ivan Hu      2016-08-25   28   * Count the bytes in 'str', including the terminating NULL.
ff6301dabc3ca20 Ivan Hu      2016-08-25   29   *
ff6301dabc3ca20 Ivan Hu      2016-08-25   30   * Note this function returns the number of *bytes*, not the number of
ff6301dabc3ca20 Ivan Hu      2016-08-25   31   * ucs2 characters.
ff6301dabc3ca20 Ivan Hu      2016-08-25   32   */
ff6301dabc3ca20 Ivan Hu      2016-08-25   33  static inline size_t user_ucs2_strsize(efi_char16_t  __user *str)
ff6301dabc3ca20 Ivan Hu      2016-08-25   34  {
ff6301dabc3ca20 Ivan Hu      2016-08-25   35  	efi_char16_t *s = str, c;
ff6301dabc3ca20 Ivan Hu      2016-08-25   36  	size_t len;
ff6301dabc3ca20 Ivan Hu      2016-08-25   37  
ff6301dabc3ca20 Ivan Hu      2016-08-25   38  	if (!str)
ff6301dabc3ca20 Ivan Hu      2016-08-25   39  		return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25   40  
ff6301dabc3ca20 Ivan Hu      2016-08-25   41  	/* Include terminating NULL */
ff6301dabc3ca20 Ivan Hu      2016-08-25   42  	len = sizeof(efi_char16_t);
ff6301dabc3ca20 Ivan Hu      2016-08-25   43  
ff6301dabc3ca20 Ivan Hu      2016-08-25  @44  	if (get_user(c, s++)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25   45  		/* Can't read userspace memory for size */
ff6301dabc3ca20 Ivan Hu      2016-08-25   46  		return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25   47  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25   48  
ff6301dabc3ca20 Ivan Hu      2016-08-25   49  	while (c != 0) {
ff6301dabc3ca20 Ivan Hu      2016-08-25   50  		if (get_user(c, s++)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25   51  			/* Can't read userspace memory for size */
ff6301dabc3ca20 Ivan Hu      2016-08-25   52  			return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25   53  		}
ff6301dabc3ca20 Ivan Hu      2016-08-25   54  		len += sizeof(efi_char16_t);
ff6301dabc3ca20 Ivan Hu      2016-08-25   55  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25   56  	return len;
ff6301dabc3ca20 Ivan Hu      2016-08-25   57  }
ff6301dabc3ca20 Ivan Hu      2016-08-25   58  
ff6301dabc3ca20 Ivan Hu      2016-08-25   59  /*
ff6301dabc3ca20 Ivan Hu      2016-08-25   60   * Allocate a buffer and copy a ucs2 string from user space into it.
ff6301dabc3ca20 Ivan Hu      2016-08-25   61   */
ff6301dabc3ca20 Ivan Hu      2016-08-25   62  static inline int
ff6301dabc3ca20 Ivan Hu      2016-08-25   63  copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
ff6301dabc3ca20 Ivan Hu      2016-08-25   64  			size_t len)
ff6301dabc3ca20 Ivan Hu      2016-08-25   65  {
ff6301dabc3ca20 Ivan Hu      2016-08-25   66  	efi_char16_t *buf;
ff6301dabc3ca20 Ivan Hu      2016-08-25   67  
ff6301dabc3ca20 Ivan Hu      2016-08-25   68  	if (!src) {
ff6301dabc3ca20 Ivan Hu      2016-08-25   69  		*dst = NULL;
ff6301dabc3ca20 Ivan Hu      2016-08-25   70  		return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25   71  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25   72  
5f72cad65cfaac5 Geliang Tang 2017-06-02   73  	buf = memdup_user(src, len);
5f72cad65cfaac5 Geliang Tang 2017-06-02   74  	if (IS_ERR(buf)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25   75  		*dst = NULL;
5f72cad65cfaac5 Geliang Tang 2017-06-02   76  		return PTR_ERR(buf);
ff6301dabc3ca20 Ivan Hu      2016-08-25   77  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25   78  	*dst = buf;
ff6301dabc3ca20 Ivan Hu      2016-08-25   79  
ff6301dabc3ca20 Ivan Hu      2016-08-25   80  	return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25   81  }
ff6301dabc3ca20 Ivan Hu      2016-08-25   82  
ff6301dabc3ca20 Ivan Hu      2016-08-25   83  /*
ff6301dabc3ca20 Ivan Hu      2016-08-25   84   * Count the bytes in 'str', including the terminating NULL.
ff6301dabc3ca20 Ivan Hu      2016-08-25   85   *
ff6301dabc3ca20 Ivan Hu      2016-08-25   86   * Just a wrap for user_ucs2_strsize
ff6301dabc3ca20 Ivan Hu      2016-08-25   87   */
ff6301dabc3ca20 Ivan Hu      2016-08-25   88  static inline int
ff6301dabc3ca20 Ivan Hu      2016-08-25   89  get_ucs2_strsize_from_user(efi_char16_t __user *src, size_t *len)
ff6301dabc3ca20 Ivan Hu      2016-08-25   90  {
ff6301dabc3ca20 Ivan Hu      2016-08-25   91  	*len = user_ucs2_strsize(src);
ff6301dabc3ca20 Ivan Hu      2016-08-25   92  	if (*len == 0)
ff6301dabc3ca20 Ivan Hu      2016-08-25   93  		return -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25   94  
ff6301dabc3ca20 Ivan Hu      2016-08-25   95  	return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25   96  }
ff6301dabc3ca20 Ivan Hu      2016-08-25   97  
ff6301dabc3ca20 Ivan Hu      2016-08-25   98  /*
ff6301dabc3ca20 Ivan Hu      2016-08-25   99   * Calculate the required buffer allocation size and copy a ucs2 string
ff6301dabc3ca20 Ivan Hu      2016-08-25  100   * from user space into it.
ff6301dabc3ca20 Ivan Hu      2016-08-25  101   *
ff6301dabc3ca20 Ivan Hu      2016-08-25  102   * This function differs from copy_ucs2_from_user_len() because it
ff6301dabc3ca20 Ivan Hu      2016-08-25  103   * calculates the size of the buffer to allocate by taking the length of
ff6301dabc3ca20 Ivan Hu      2016-08-25  104   * the string 'src'.
ff6301dabc3ca20 Ivan Hu      2016-08-25  105   *
ff6301dabc3ca20 Ivan Hu      2016-08-25  106   * If a non-zero value is returned, the caller MUST NOT access 'dst'.
ff6301dabc3ca20 Ivan Hu      2016-08-25  107   *
ff6301dabc3ca20 Ivan Hu      2016-08-25  108   * It is the caller's responsibility to free 'dst'.
ff6301dabc3ca20 Ivan Hu      2016-08-25  109   */
ff6301dabc3ca20 Ivan Hu      2016-08-25  110  static inline int
ff6301dabc3ca20 Ivan Hu      2016-08-25  111  copy_ucs2_from_user(efi_char16_t **dst, efi_char16_t __user *src)
ff6301dabc3ca20 Ivan Hu      2016-08-25  112  {
ff6301dabc3ca20 Ivan Hu      2016-08-25  113  	size_t len;
ff6301dabc3ca20 Ivan Hu      2016-08-25  114  
ff6301dabc3ca20 Ivan Hu      2016-08-25  115  	len = user_ucs2_strsize(src);
ff6301dabc3ca20 Ivan Hu      2016-08-25  116  	if (len == 0)
ff6301dabc3ca20 Ivan Hu      2016-08-25  117  		return -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  118  	return copy_ucs2_from_user_len(dst, src, len);
ff6301dabc3ca20 Ivan Hu      2016-08-25  119  }
ff6301dabc3ca20 Ivan Hu      2016-08-25  120  
ff6301dabc3ca20 Ivan Hu      2016-08-25  121  /*
ff6301dabc3ca20 Ivan Hu      2016-08-25  122   * Copy a ucs2 string to a user buffer.
ff6301dabc3ca20 Ivan Hu      2016-08-25  123   *
ff6301dabc3ca20 Ivan Hu      2016-08-25  124   * This function is a simple wrapper around copy_to_user() that does
ff6301dabc3ca20 Ivan Hu      2016-08-25  125   * nothing if 'src' is NULL, which is useful for reducing the amount of
ff6301dabc3ca20 Ivan Hu      2016-08-25  126   * NULL checking the caller has to do.
ff6301dabc3ca20 Ivan Hu      2016-08-25  127   *
ff6301dabc3ca20 Ivan Hu      2016-08-25  128   * 'len' specifies the number of bytes to copy.
ff6301dabc3ca20 Ivan Hu      2016-08-25  129   */
ff6301dabc3ca20 Ivan Hu      2016-08-25  130  static inline int
ff6301dabc3ca20 Ivan Hu      2016-08-25  131  copy_ucs2_to_user_len(efi_char16_t __user *dst, efi_char16_t *src, size_t len)
ff6301dabc3ca20 Ivan Hu      2016-08-25  132  {
ff6301dabc3ca20 Ivan Hu      2016-08-25  133  	if (!src)
ff6301dabc3ca20 Ivan Hu      2016-08-25  134  		return 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25  135  
ff6301dabc3ca20 Ivan Hu      2016-08-25  136  	return copy_to_user(dst, src, len);
ff6301dabc3ca20 Ivan Hu      2016-08-25  137  }
ff6301dabc3ca20 Ivan Hu      2016-08-25  138  
ff6301dabc3ca20 Ivan Hu      2016-08-25  139  static long efi_runtime_get_variable(unsigned long arg)
ff6301dabc3ca20 Ivan Hu      2016-08-25  140  {
ff6301dabc3ca20 Ivan Hu      2016-08-25  141  	struct efi_getvariable __user *getvariable_user;
ff6301dabc3ca20 Ivan Hu      2016-08-25  142  	struct efi_getvariable getvariable;
46b9b7135332d1e Ivan Hu      2016-10-18  143  	unsigned long datasize = 0, prev_datasize, *dz;
ff6301dabc3ca20 Ivan Hu      2016-08-25  144  	efi_guid_t vendor_guid, *vd = NULL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  145  	efi_status_t status;
ff6301dabc3ca20 Ivan Hu      2016-08-25  146  	efi_char16_t *name = NULL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  147  	u32 attr, *at;
ff6301dabc3ca20 Ivan Hu      2016-08-25  148  	void *data = NULL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  149  	int rv = 0;
ff6301dabc3ca20 Ivan Hu      2016-08-25  150  
ff6301dabc3ca20 Ivan Hu      2016-08-25  151  	getvariable_user = (struct efi_getvariable __user *)arg;
ff6301dabc3ca20 Ivan Hu      2016-08-25  152  
ff6301dabc3ca20 Ivan Hu      2016-08-25  153  	if (copy_from_user(&getvariable, getvariable_user,
ff6301dabc3ca20 Ivan Hu      2016-08-25  154  			   sizeof(getvariable)))
ff6301dabc3ca20 Ivan Hu      2016-08-25  155  		return -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  156  	if (getvariable.data_size &&
ff6301dabc3ca20 Ivan Hu      2016-08-25 @157  	    get_user(datasize, getvariable.data_size))
ff6301dabc3ca20 Ivan Hu      2016-08-25  158  		return -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  159  	if (getvariable.vendor_guid) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  160  		if (copy_from_user(&vendor_guid, getvariable.vendor_guid,
ff6301dabc3ca20 Ivan Hu      2016-08-25  161  					sizeof(vendor_guid)))
ff6301dabc3ca20 Ivan Hu      2016-08-25  162  			return -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  163  		vd = &vendor_guid;
ff6301dabc3ca20 Ivan Hu      2016-08-25  164  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  165  
ff6301dabc3ca20 Ivan Hu      2016-08-25  166  	if (getvariable.variable_name) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  167  		rv = copy_ucs2_from_user(&name, getvariable.variable_name);
ff6301dabc3ca20 Ivan Hu      2016-08-25  168  		if (rv)
ff6301dabc3ca20 Ivan Hu      2016-08-25  169  			return rv;
ff6301dabc3ca20 Ivan Hu      2016-08-25  170  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  171  
ff6301dabc3ca20 Ivan Hu      2016-08-25  172  	at = getvariable.attributes ? &attr : NULL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  173  	dz = getvariable.data_size ? &datasize : NULL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  174  
ff6301dabc3ca20 Ivan Hu      2016-08-25  175  	if (getvariable.data_size && getvariable.data) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  176  		data = kmalloc(datasize, GFP_KERNEL);
ff6301dabc3ca20 Ivan Hu      2016-08-25  177  		if (!data) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  178  			kfree(name);
ff6301dabc3ca20 Ivan Hu      2016-08-25  179  			return -ENOMEM;
ff6301dabc3ca20 Ivan Hu      2016-08-25  180  		}
ff6301dabc3ca20 Ivan Hu      2016-08-25  181  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  182  
ff6301dabc3ca20 Ivan Hu      2016-08-25  183  	prev_datasize = datasize;
ff6301dabc3ca20 Ivan Hu      2016-08-25  184  	status = efi.get_variable(name, vd, at, dz, data);
ff6301dabc3ca20 Ivan Hu      2016-08-25  185  	kfree(name);
ff6301dabc3ca20 Ivan Hu      2016-08-25  186  
ff6301dabc3ca20 Ivan Hu      2016-08-25 @187  	if (put_user(status, getvariable.status)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  188  		rv = -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  189  		goto out;
ff6301dabc3ca20 Ivan Hu      2016-08-25  190  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  191  
ff6301dabc3ca20 Ivan Hu      2016-08-25  192  	if (status != EFI_SUCCESS) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  193  		if (status == EFI_BUFFER_TOO_SMALL) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  194  			if (dz && put_user(datasize, getvariable.data_size)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  195  				rv = -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  196  				goto out;
ff6301dabc3ca20 Ivan Hu      2016-08-25  197  			}
ff6301dabc3ca20 Ivan Hu      2016-08-25  198  		}
ff6301dabc3ca20 Ivan Hu      2016-08-25  199  		rv = -EINVAL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  200  		goto out;
ff6301dabc3ca20 Ivan Hu      2016-08-25  201  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  202  
ff6301dabc3ca20 Ivan Hu      2016-08-25  203  	if (prev_datasize < datasize) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  204  		rv = -EINVAL;
ff6301dabc3ca20 Ivan Hu      2016-08-25  205  		goto out;
ff6301dabc3ca20 Ivan Hu      2016-08-25  206  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  207  
ff6301dabc3ca20 Ivan Hu      2016-08-25  208  	if (data) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  209  		if (copy_to_user(getvariable.data, data, datasize)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  210  			rv = -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  211  			goto out;
ff6301dabc3ca20 Ivan Hu      2016-08-25  212  		}
ff6301dabc3ca20 Ivan Hu      2016-08-25  213  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  214  
ff6301dabc3ca20 Ivan Hu      2016-08-25 @215  	if (at && put_user(attr, getvariable.attributes)) {
ff6301dabc3ca20 Ivan Hu      2016-08-25  216  		rv = -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  217  		goto out;
ff6301dabc3ca20 Ivan Hu      2016-08-25  218  	}
ff6301dabc3ca20 Ivan Hu      2016-08-25  219  
ff6301dabc3ca20 Ivan Hu      2016-08-25  220  	if (dz && put_user(datasize, getvariable.data_size))
ff6301dabc3ca20 Ivan Hu      2016-08-25  221  		rv = -EFAULT;
ff6301dabc3ca20 Ivan Hu      2016-08-25  222  
ff6301dabc3ca20 Ivan Hu      2016-08-25  223  out:
ff6301dabc3ca20 Ivan Hu      2016-08-25  224  	kfree(data);
ff6301dabc3ca20 Ivan Hu      2016-08-25  225  	return rv;
ff6301dabc3ca20 Ivan Hu      2016-08-25  226  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36305 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
                   ` (2 preceding siblings ...)
  2020-08-28 12:20 ` kernel test robot
@ 2020-08-28 14:21 ` kernel test robot
  2020-08-28 15:11 ` kernel test robot
  2020-08-28 19:04 ` Miguel Ojeda
  5 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-08-28 14:21 UTC (permalink / raw)
  To: Luc Van Oostenryck, Miguel Ojeda
  Cc: kbuild-all, linux-kernel, Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 40474 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
base:    9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: x86_64-randconfig-s022-20200828 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-191-g10164920-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/radeon/radeon_ttm.c:969:21: sparse: sparse: cast removes address space '__user' of expression
--
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:828:42: sparse: sparse: cast removes address space '__iomem' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2389:21: sparse: sparse: cast removes address space '__user' of expression
--
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
--
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:138:17: sparse: sparse: incorrect type in initializer (different base types) @@     expected restricted __poll_t ( *poll )( ... ) @@     got unsigned int ( * )( ... ) @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:138:17: sparse:     expected restricted __poll_t ( *poll )( ... )
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:138:17: sparse:     got unsigned int ( * )( ... )
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse:     expected void const volatile [noderef] __user *ptr
--
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
>> arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] * @@
>> arch/x86/ia32/ia32_signal.c:350:9: sparse:     expected void const volatile [noderef] __user *ptr
   arch/x86/ia32/ia32_signal.c:350:9: sparse:     got unsigned long long [usertype] *
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression

# https://github.com/0day-ci/linux/commit/7d01c91ac34a64f0177bc6d058cc50e805f59102
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
git checkout 7d01c91ac34a64f0177bc6d058cc50e805f59102
vim +969 drivers/gpu/drm/radeon/radeon_ttm.c

771fe6b912fca5 Jerome Glisse         2009-06-05  772  
771fe6b912fca5 Jerome Glisse         2009-06-05 @773  int radeon_ttm_init(struct radeon_device *rdev)
771fe6b912fca5 Jerome Glisse         2009-06-05  774  {
771fe6b912fca5 Jerome Glisse         2009-06-05  775  	int r;
771fe6b912fca5 Jerome Glisse         2009-06-05  776  
771fe6b912fca5 Jerome Glisse         2009-06-05  777  	/* No others user of address space so set it to 0 */
771fe6b912fca5 Jerome Glisse         2009-06-05  778  	r = ttm_bo_device_init(&rdev->mman.bdev,
44d847b7439bde David Herrmann        2013-08-13  779  			       &radeon_bo_driver,
44d847b7439bde David Herrmann        2013-08-13  780  			       rdev->ddev->anon_inode->i_mapping,
8b53e1cb2728b6 Gerd Hoffmann         2019-09-05  781  			       rdev->ddev->vma_offset_manager,
33b3ad3788aba8 Christoph Hellwig     2019-08-15  782  			       dma_addressing_limited(&rdev->pdev->dev));
771fe6b912fca5 Jerome Glisse         2009-06-05  783  	if (r) {
771fe6b912fca5 Jerome Glisse         2009-06-05  784  		DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
771fe6b912fca5 Jerome Glisse         2009-06-05  785  		return r;
771fe6b912fca5 Jerome Glisse         2009-06-05  786  	}
0a0c7596c64323 Jerome Glisse         2009-12-11  787  	rdev->mman.initialized = true;
4c7886791264f0 Jerome Glisse         2009-11-20  788  	r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
312ea8da049a18 Jerome Glisse         2009-12-07  789  				rdev->mc.real_vram_size >> PAGE_SHIFT);
771fe6b912fca5 Jerome Glisse         2009-06-05  790  	if (r) {
771fe6b912fca5 Jerome Glisse         2009-06-05  791  		DRM_ERROR("Failed initializing VRAM heap.\n");
771fe6b912fca5 Jerome Glisse         2009-06-05  792  		return r;
771fe6b912fca5 Jerome Glisse         2009-06-05  793  	}
14eedc32a3c0ec Lauri Kasanen         2014-02-28  794  	/* Change the size here instead of the init above so only lpfn is affected */
14eedc32a3c0ec Lauri Kasanen         2014-02-28  795  	radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size);
14eedc32a3c0ec Lauri Kasanen         2014-02-28  796  
441921d5309cfe Daniel Vetter         2011-02-18  797  	r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true,
831b6966a60fe7 Maarten Lankhorst     2014-09-18  798  			     RADEON_GEM_DOMAIN_VRAM, 0, NULL,
4aa5b92fd48f88 Kent Russell          2017-08-08  799  			     NULL, &rdev->stolen_vga_memory);
771fe6b912fca5 Jerome Glisse         2009-06-05  800  	if (r) {
771fe6b912fca5 Jerome Glisse         2009-06-05  801  		return r;
771fe6b912fca5 Jerome Glisse         2009-06-05  802  	}
4aa5b92fd48f88 Kent Russell          2017-08-08  803  	r = radeon_bo_reserve(rdev->stolen_vga_memory, false);
4c7886791264f0 Jerome Glisse         2009-11-20  804  	if (r)
4c7886791264f0 Jerome Glisse         2009-11-20  805  		return r;
4aa5b92fd48f88 Kent Russell          2017-08-08  806  	r = radeon_bo_pin(rdev->stolen_vga_memory, RADEON_GEM_DOMAIN_VRAM, NULL);
4aa5b92fd48f88 Kent Russell          2017-08-08  807  	radeon_bo_unreserve(rdev->stolen_vga_memory);
771fe6b912fca5 Jerome Glisse         2009-06-05  808  	if (r) {
4aa5b92fd48f88 Kent Russell          2017-08-08  809  		radeon_bo_unref(&rdev->stolen_vga_memory);
771fe6b912fca5 Jerome Glisse         2009-06-05  810  		return r;
771fe6b912fca5 Jerome Glisse         2009-06-05  811  	}
771fe6b912fca5 Jerome Glisse         2009-06-05  812  	DRM_INFO("radeon: %uM of VRAM memory ready\n",
fc986034540102 Niels Ole Salscheider 2013-05-18  813  		 (unsigned) (rdev->mc.real_vram_size / (1024 * 1024)));
4c7886791264f0 Jerome Glisse         2009-11-20  814  	r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT,
312ea8da049a18 Jerome Glisse         2009-12-07  815  				rdev->mc.gtt_size >> PAGE_SHIFT);
771fe6b912fca5 Jerome Glisse         2009-06-05  816  	if (r) {
771fe6b912fca5 Jerome Glisse         2009-06-05  817  		DRM_ERROR("Failed initializing GTT heap.\n");
771fe6b912fca5 Jerome Glisse         2009-06-05  818  		return r;
771fe6b912fca5 Jerome Glisse         2009-06-05  819  	}
771fe6b912fca5 Jerome Glisse         2009-06-05  820  	DRM_INFO("radeon: %uM of GTT memory ready.\n",
3ce0a23d2d2531 Jerome Glisse         2009-09-08  821  		 (unsigned)(rdev->mc.gtt_size / (1024 * 1024)));
fa8a123855e200 Dave Airlie           2009-08-26  822  
fa8a123855e200 Dave Airlie           2009-08-26  823  	r = radeon_ttm_debugfs_init(rdev);
fa8a123855e200 Dave Airlie           2009-08-26  824  	if (r) {
fa8a123855e200 Dave Airlie           2009-08-26  825  		DRM_ERROR("Failed to init debugfs\n");
fa8a123855e200 Dave Airlie           2009-08-26  826  		return r;
fa8a123855e200 Dave Airlie           2009-08-26  827  	}
771fe6b912fca5 Jerome Glisse         2009-06-05  828  	return 0;
771fe6b912fca5 Jerome Glisse         2009-06-05  829  }
771fe6b912fca5 Jerome Glisse         2009-06-05  830  
771fe6b912fca5 Jerome Glisse         2009-06-05  831  void radeon_ttm_fini(struct radeon_device *rdev)
771fe6b912fca5 Jerome Glisse         2009-06-05  832  {
4c7886791264f0 Jerome Glisse         2009-11-20  833  	int r;
4c7886791264f0 Jerome Glisse         2009-11-20  834  
0a0c7596c64323 Jerome Glisse         2009-12-11  835  	if (!rdev->mman.initialized)
0a0c7596c64323 Jerome Glisse         2009-12-11  836  		return;
2014b5694182b5 Christian König       2013-12-18  837  	radeon_ttm_debugfs_fini(rdev);
4aa5b92fd48f88 Kent Russell          2017-08-08  838  	if (rdev->stolen_vga_memory) {
4aa5b92fd48f88 Kent Russell          2017-08-08  839  		r = radeon_bo_reserve(rdev->stolen_vga_memory, false);
4c7886791264f0 Jerome Glisse         2009-11-20  840  		if (r == 0) {
4aa5b92fd48f88 Kent Russell          2017-08-08  841  			radeon_bo_unpin(rdev->stolen_vga_memory);
4aa5b92fd48f88 Kent Russell          2017-08-08  842  			radeon_bo_unreserve(rdev->stolen_vga_memory);
4c7886791264f0 Jerome Glisse         2009-11-20  843  		}
4aa5b92fd48f88 Kent Russell          2017-08-08  844  		radeon_bo_unref(&rdev->stolen_vga_memory);
771fe6b912fca5 Jerome Glisse         2009-06-05  845  	}
771fe6b912fca5 Jerome Glisse         2009-06-05  846  	ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_VRAM);
771fe6b912fca5 Jerome Glisse         2009-06-05  847  	ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_TT);
771fe6b912fca5 Jerome Glisse         2009-06-05  848  	ttm_bo_device_release(&rdev->mman.bdev);
771fe6b912fca5 Jerome Glisse         2009-06-05  849  	radeon_gart_fini(rdev);
0a0c7596c64323 Jerome Glisse         2009-12-11  850  	rdev->mman.initialized = false;
771fe6b912fca5 Jerome Glisse         2009-06-05  851  	DRM_INFO("radeon: ttm finalized\n");
771fe6b912fca5 Jerome Glisse         2009-06-05  852  }
771fe6b912fca5 Jerome Glisse         2009-06-05  853  
5359533801e3dd Dave Airlie           2011-03-14  854  /* this should only be called at bootup or when userspace
5359533801e3dd Dave Airlie           2011-03-14  855   * isn't running */
5359533801e3dd Dave Airlie           2011-03-14  856  void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
5359533801e3dd Dave Airlie           2011-03-14  857  {
5359533801e3dd Dave Airlie           2011-03-14  858  	struct ttm_mem_type_manager *man;
5359533801e3dd Dave Airlie           2011-03-14  859  
5359533801e3dd Dave Airlie           2011-03-14  860  	if (!rdev->mman.initialized)
5359533801e3dd Dave Airlie           2011-03-14  861  		return;
5359533801e3dd Dave Airlie           2011-03-14  862  
5359533801e3dd Dave Airlie           2011-03-14  863  	man = &rdev->mman.bdev.man[TTM_PL_VRAM];
5359533801e3dd Dave Airlie           2011-03-14  864  	/* this just adjusts TTM size idea, which sets lpfn to the correct value */
5359533801e3dd Dave Airlie           2011-03-14  865  	man->size = size >> PAGE_SHIFT;
5359533801e3dd Dave Airlie           2011-03-14  866  }
5359533801e3dd Dave Airlie           2011-03-14  867  
2bfb0b678e48de Souptick Joarder      2018-04-16  868  static vm_fault_t radeon_ttm_fault(struct vm_fault *vmf)
771fe6b912fca5 Jerome Glisse         2009-06-05  869  {
771fe6b912fca5 Jerome Glisse         2009-06-05  870  	struct ttm_buffer_object *bo;
5876dd249e8e47 Matthew Garrett       2010-04-26  871  	struct radeon_device *rdev;
2bfb0b678e48de Souptick Joarder      2018-04-16  872  	vm_fault_t ret;
771fe6b912fca5 Jerome Glisse         2009-06-05  873  
11bac80004499e Dave Jiang            2017-02-24  874  	bo = (struct ttm_buffer_object *)vmf->vma->vm_private_data;
165d3448a1a0e8 Christian König       2019-09-27  875  	if (bo == NULL)
771fe6b912fca5 Jerome Glisse         2009-06-05  876  		return VM_FAULT_NOPAGE;
165d3448a1a0e8 Christian König       2019-09-27  877  
5876dd249e8e47 Matthew Garrett       2010-04-26  878  	rdev = radeon_get_rdev(bo->bdev);
db7fce3983ad9b Christian König       2012-05-11  879  	down_read(&rdev->pm.mclk_lock);
165d3448a1a0e8 Christian König       2019-09-27  880  	ret = ttm_bo_vm_fault(vmf);
db7fce3983ad9b Christian König       2012-05-11  881  	up_read(&rdev->pm.mclk_lock);
2bfb0b678e48de Souptick Joarder      2018-04-16  882  	return ret;
771fe6b912fca5 Jerome Glisse         2009-06-05  883  }
771fe6b912fca5 Jerome Glisse         2009-06-05  884  
165d3448a1a0e8 Christian König       2019-09-27  885  static struct vm_operations_struct radeon_ttm_vm_ops = {
165d3448a1a0e8 Christian König       2019-09-27  886  	.fault = radeon_ttm_fault,
165d3448a1a0e8 Christian König       2019-09-27  887  	.open = ttm_bo_vm_open,
165d3448a1a0e8 Christian König       2019-09-27  888  	.close = ttm_bo_vm_close,
165d3448a1a0e8 Christian König       2019-09-27  889  	.access = ttm_bo_vm_access
165d3448a1a0e8 Christian König       2019-09-27  890  };
165d3448a1a0e8 Christian König       2019-09-27  891  
771fe6b912fca5 Jerome Glisse         2009-06-05  892  int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
771fe6b912fca5 Jerome Glisse         2009-06-05  893  {
771fe6b912fca5 Jerome Glisse         2009-06-05  894  	int r;
bed2dd84212eb0 Thomas Zimmermann     2019-02-07  895  	struct drm_file *file_priv = filp->private_data;
bed2dd84212eb0 Thomas Zimmermann     2019-02-07  896  	struct radeon_device *rdev = file_priv->minor->dev->dev_private;
771fe6b912fca5 Jerome Glisse         2009-06-05  897  
165d3448a1a0e8 Christian König       2019-09-27  898  	if (rdev == NULL)
771fe6b912fca5 Jerome Glisse         2009-06-05  899  		return -EINVAL;
165d3448a1a0e8 Christian König       2019-09-27  900  
771fe6b912fca5 Jerome Glisse         2009-06-05  901  	r = ttm_bo_mmap(filp, vma, &rdev->mman.bdev);
165d3448a1a0e8 Christian König       2019-09-27  902  	if (unlikely(r != 0))
771fe6b912fca5 Jerome Glisse         2009-06-05  903  		return r;
165d3448a1a0e8 Christian König       2019-09-27  904  
771fe6b912fca5 Jerome Glisse         2009-06-05  905  	vma->vm_ops = &radeon_ttm_vm_ops;
771fe6b912fca5 Jerome Glisse         2009-06-05  906  	return 0;
771fe6b912fca5 Jerome Glisse         2009-06-05  907  }
771fe6b912fca5 Jerome Glisse         2009-06-05  908  
fa8a123855e200 Dave Airlie           2009-08-26  909  #if defined(CONFIG_DEBUG_FS)
893d6e6e122386 Christian König       2013-12-12  910  
fa8a123855e200 Dave Airlie           2009-08-26  911  static int radeon_mm_dump_table(struct seq_file *m, void *data)
fa8a123855e200 Dave Airlie           2009-08-26  912  {
fa8a123855e200 Dave Airlie           2009-08-26  913  	struct drm_info_node *node = (struct drm_info_node *)m->private;
893d6e6e122386 Christian König       2013-12-12  914  	unsigned ttm_pl = *(int*)node->info_ent->data;
fa8a123855e200 Dave Airlie           2009-08-26  915  	struct drm_device *dev = node->minor->dev;
fa8a123855e200 Dave Airlie           2009-08-26  916  	struct radeon_device *rdev = dev->dev_private;
bbbb29efa20d55 Christian König       2017-08-07  917  	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[ttm_pl];
b5c3714fe87897 Daniel Vetter         2016-12-29  918  	struct drm_printer p = drm_seq_file_printer(m);
fa8a123855e200 Dave Airlie           2009-08-26  919  
bbbb29efa20d55 Christian König       2017-08-07  920  	man->func->debug(man, &p);
b5c3714fe87897 Daniel Vetter         2016-12-29  921  	return 0;
fa8a123855e200 Dave Airlie           2009-08-26  922  }
893d6e6e122386 Christian König       2013-12-12  923  
bbbb29efa20d55 Christian König       2017-08-07  924  
893d6e6e122386 Christian König       2013-12-12  925  static int ttm_pl_vram = TTM_PL_VRAM;
893d6e6e122386 Christian König       2013-12-12  926  static int ttm_pl_tt = TTM_PL_TT;
893d6e6e122386 Christian König       2013-12-12  927  
893d6e6e122386 Christian König       2013-12-12  928  static struct drm_info_list radeon_ttm_debugfs_list[] = {
893d6e6e122386 Christian König       2013-12-12  929  	{"radeon_vram_mm", radeon_mm_dump_table, 0, &ttm_pl_vram},
893d6e6e122386 Christian König       2013-12-12  930  	{"radeon_gtt_mm", radeon_mm_dump_table, 0, &ttm_pl_tt},
893d6e6e122386 Christian König       2013-12-12  931  	{"ttm_page_pool", ttm_page_alloc_debugfs, 0, NULL},
893d6e6e122386 Christian König       2013-12-12  932  #ifdef CONFIG_SWIOTLB
893d6e6e122386 Christian König       2013-12-12  933  	{"ttm_dma_page_pool", ttm_dma_page_alloc_debugfs, 0, NULL}
893d6e6e122386 Christian König       2013-12-12  934  #endif
893d6e6e122386 Christian König       2013-12-12  935  };
893d6e6e122386 Christian König       2013-12-12  936  
2014b5694182b5 Christian König       2013-12-18  937  static int radeon_ttm_vram_open(struct inode *inode, struct file *filep)
2014b5694182b5 Christian König       2013-12-18  938  {
2014b5694182b5 Christian König       2013-12-18  939  	struct radeon_device *rdev = inode->i_private;
2014b5694182b5 Christian König       2013-12-18  940  	i_size_write(inode, rdev->mc.mc_vram_size);
2014b5694182b5 Christian König       2013-12-18  941  	filep->private_data = inode->i_private;
2014b5694182b5 Christian König       2013-12-18  942  	return 0;
2014b5694182b5 Christian König       2013-12-18  943  }
2014b5694182b5 Christian König       2013-12-18  944  
2014b5694182b5 Christian König       2013-12-18  945  static ssize_t radeon_ttm_vram_read(struct file *f, char __user *buf,
2014b5694182b5 Christian König       2013-12-18  946  				    size_t size, loff_t *pos)
2014b5694182b5 Christian König       2013-12-18  947  {
2014b5694182b5 Christian König       2013-12-18  948  	struct radeon_device *rdev = f->private_data;
2014b5694182b5 Christian König       2013-12-18  949  	ssize_t result = 0;
2014b5694182b5 Christian König       2013-12-18  950  	int r;
2014b5694182b5 Christian König       2013-12-18  951  
2014b5694182b5 Christian König       2013-12-18  952  	if (size & 0x3 || *pos & 0x3)
2014b5694182b5 Christian König       2013-12-18  953  		return -EINVAL;
2014b5694182b5 Christian König       2013-12-18  954  
2014b5694182b5 Christian König       2013-12-18  955  	while (size) {
2014b5694182b5 Christian König       2013-12-18  956  		unsigned long flags;
2014b5694182b5 Christian König       2013-12-18  957  		uint32_t value;
2014b5694182b5 Christian König       2013-12-18  958  
2014b5694182b5 Christian König       2013-12-18  959  		if (*pos >= rdev->mc.mc_vram_size)
2014b5694182b5 Christian König       2013-12-18  960  			return result;
2014b5694182b5 Christian König       2013-12-18  961  
2014b5694182b5 Christian König       2013-12-18  962  		spin_lock_irqsave(&rdev->mmio_idx_lock, flags);
2014b5694182b5 Christian König       2013-12-18  963  		WREG32(RADEON_MM_INDEX, ((uint32_t)*pos) | 0x80000000);
2014b5694182b5 Christian König       2013-12-18  964  		if (rdev->family >= CHIP_CEDAR)
2014b5694182b5 Christian König       2013-12-18  965  			WREG32(EVERGREEN_MM_INDEX_HI, *pos >> 31);
2014b5694182b5 Christian König       2013-12-18  966  		value = RREG32(RADEON_MM_DATA);
2014b5694182b5 Christian König       2013-12-18  967  		spin_unlock_irqrestore(&rdev->mmio_idx_lock, flags);
2014b5694182b5 Christian König       2013-12-18  968  
2014b5694182b5 Christian König       2013-12-18 @969  		r = put_user(value, (uint32_t *)buf);
2014b5694182b5 Christian König       2013-12-18  970  		if (r)
2014b5694182b5 Christian König       2013-12-18  971  			return r;
2014b5694182b5 Christian König       2013-12-18  972  
2014b5694182b5 Christian König       2013-12-18  973  		result += 4;
2014b5694182b5 Christian König       2013-12-18  974  		buf += 4;
2014b5694182b5 Christian König       2013-12-18  975  		*pos += 4;
2014b5694182b5 Christian König       2013-12-18  976  		size -= 4;
2014b5694182b5 Christian König       2013-12-18  977  	}
2014b5694182b5 Christian König       2013-12-18  978  
2014b5694182b5 Christian König       2013-12-18  979  	return result;
2014b5694182b5 Christian König       2013-12-18  980  }
2014b5694182b5 Christian König       2013-12-18  981  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35138 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
                   ` (3 preceding siblings ...)
  2020-08-28 14:21 ` kernel test robot
@ 2020-08-28 15:11 ` kernel test robot
  2020-08-28 19:04 ` Miguel Ojeda
  5 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-08-28 15:11 UTC (permalink / raw)
  To: Luc Van Oostenryck, Miguel Ojeda
  Cc: kbuild-all, linux-kernel, Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 10044 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
base:    9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: i386-randconfig-s002-20200828 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-191-g10164920-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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 >>)

   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
>> arch/x86/kernel/signal.c:338:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] * @@
>> arch/x86/kernel/signal.c:338:9: sparse:     expected void const volatile [noderef] __user *ptr
   arch/x86/kernel/signal.c:338:9: sparse:     got unsigned long long [usertype] *
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:338:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] * @@
   arch/x86/kernel/signal.c:398:9: sparse:     expected void const volatile [noderef] __user *ptr
   arch/x86/kernel/signal.c:398:9: sparse:     got unsigned long long [usertype] *
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:398:9: sparse: sparse: cast removes address space '__user' of expression

# https://github.com/0day-ci/linux/commit/7d01c91ac34a64f0177bc6d058cc50e805f59102
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200828-165431
git checkout 7d01c91ac34a64f0177bc6d058cc50e805f59102
vim +338 arch/x86/kernel/signal.c

75779f05264b996 arch/x86/kernel/signal.c    Hiroshi Shimamoto 2009-02-27  303  
7e907f48980d666 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  304  static int
235b80226b986da arch/x86/kernel/signal.c    Al Viro           2012-11-09  305  __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
7e907f48980d666 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  306  	      struct pt_regs *regs)
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  307  {
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  308  	struct sigframe __user *frame;
7e907f48980d666 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  309  	void __user *restorer;
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  310  	void __user *fp = NULL;
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  311  
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  312  	frame = get_sigframe(&ksig->ka, regs, sizeof(*frame), &fp);
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  313  
5c1f178094631e8 arch/x86/kernel/signal.c    Al Viro           2020-02-15  314  	if (!user_access_begin(frame, sizeof(*frame)))
3d0aedd9538e6be arch/x86/kernel/signal_32.c Hiroshi Shimamoto 2008-09-12  315  		return -EFAULT;
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  316  
5c1f178094631e8 arch/x86/kernel/signal.c    Al Viro           2020-02-15  317  	unsafe_put_user(sig, &frame->sig, Efault);
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  318  	unsafe_put_sigcontext(&frame->sc, fp, regs, set, Efault);
5c1f178094631e8 arch/x86/kernel/signal.c    Al Viro           2020-02-15  319  	unsafe_put_user(set->sig[1], &frame->extramask[0], Efault);
1a3e4ca41c5a389 arch/x86/kernel/signal_32.c Roland McGrath    2008-04-09  320  	if (current->mm->context.vdso)
6f121e548f83674 arch/x86/kernel/signal.c    Andy Lutomirski   2014-05-05  321  		restorer = current->mm->context.vdso +
0a6d1fa0d2b48fb arch/x86/kernel/signal.c    Andy Lutomirski   2015-10-05  322  			vdso_image_32.sym___kernel_sigreturn;
9fbbd4dd17d0712 arch/i386/kernel/signal.c   Andi Kleen        2007-02-13  323  	else
ade1af77129dea6 arch/x86/kernel/signal_32.c Jan Engelhardt    2008-01-30  324  		restorer = &frame->retcode;
235b80226b986da arch/x86/kernel/signal.c    Al Viro           2012-11-09  325  	if (ksig->ka.sa.sa_flags & SA_RESTORER)
235b80226b986da arch/x86/kernel/signal.c    Al Viro           2012-11-09  326  		restorer = ksig->ka.sa.sa_restorer;
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  327  
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  328  	/* Set up to return from userspace.  */
5c1f178094631e8 arch/x86/kernel/signal.c    Al Viro           2020-02-15  329  	unsafe_put_user(restorer, &frame->pretcode, Efault);
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  330  
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  331  	/*
7e907f48980d666 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  332  	 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  333  	 *
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  334  	 * WE DO NOT USE IT ANY MORE! It's only left here for historical
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  335  	 * reasons and because gdb uses it as a signature to notice
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  336  	 * signal handler stack frames.
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  337  	 */
5c1f178094631e8 arch/x86/kernel/signal.c    Al Viro           2020-02-15 @338  	unsafe_put_user(*((u64 *)&retcode), (u64 *)frame->retcode, Efault);
5c1f178094631e8 arch/x86/kernel/signal.c    Al Viro           2020-02-15  339  	user_access_end();
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  340  
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  341  	/* Set up registers for signal handler */
65ea5b034990358 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  342  	regs->sp = (unsigned long)frame;
235b80226b986da arch/x86/kernel/signal.c    Al Viro           2012-11-09  343  	regs->ip = (unsigned long)ksig->ka.sa.sa_handler;
65ea5b034990358 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  344  	regs->ax = (unsigned long)sig;
92bc2056855b325 arch/x86/kernel/signal_32.c Harvey Harrison   2008-02-08  345  	regs->dx = 0;
92bc2056855b325 arch/x86/kernel/signal_32.c Harvey Harrison   2008-02-08  346  	regs->cx = 0;
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  347  
65ea5b034990358 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  348  	regs->ds = __USER_DS;
65ea5b034990358 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  349  	regs->es = __USER_DS;
65ea5b034990358 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  350  	regs->ss = __USER_DS;
65ea5b034990358 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  351  	regs->cs = __USER_CS;
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  352  
283828f3c19ceb3 arch/i386/kernel/signal.c   David Howells     2006-01-18  353  	return 0;
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  354  
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  355  Efault:
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  356  	user_access_end();
b00d8f8f0b2b392 arch/x86/kernel/signal.c    Al Viro           2020-02-15  357  	return -EFAULT;
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  358  }
^1da177e4c3f415 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  359  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 42879 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
                   ` (4 preceding siblings ...)
  2020-08-28 15:11 ` kernel test robot
@ 2020-08-28 19:04 ` Miguel Ojeda
  2020-08-28 20:15   ` Luc Van Oostenryck
  5 siblings, 1 reply; 14+ messages in thread
From: Miguel Ojeda @ 2020-08-28 19:04 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-kernel

Hi Luc,

On Fri, Aug 28, 2020 at 10:53 AM Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
>
> Hi Miguel,
>
> Could you also take this patch in your queue?
> It has already be sent twice but ignored by the other channels.

Yeah, no problem. However, what about all those emails from the test
bot? Is the bot using an old version of sparse or something like that?

Cheers,
Miguel

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28 19:04 ` Miguel Ojeda
@ 2020-08-28 20:15   ` Luc Van Oostenryck
  2020-08-29  7:33     ` Miguel Ojeda
  0 siblings, 1 reply; 14+ messages in thread
From: Luc Van Oostenryck @ 2020-08-28 20:15 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: linux-kernel

On Fri, Aug 28, 2020 at 09:04:28PM +0200, Miguel Ojeda wrote:
> Hi Luc,
> 
> On Fri, Aug 28, 2020 at 10:53 AM Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> >
> > Hi Miguel,
> >
> > Could you also take this patch in your queue?
> > It has already be sent twice but ignored by the other channels.
> 
> Yeah, no problem. However, what about all those emails from the test
> bot? Is the bot using an old version of sparse or something like that?

Thanks.
The bot uses the very latest sparse version (which is very nice)
but is giving here false warnings. The change in the patch has as
consequence to change related warnings:
	: ...
	:   expected void const volatile [noderef] __user *
	:   got ...
into:
	: ...
	:   expected void const volatile [noderef] __user *ptr
	:   got ...

But to the bot, any change to the content of the warning itself
or its associated info is presented as a new warning.
I've talked to the bot's guys about this problem and they've
replied that they're seriously considering to change this behaviour.

Best regards,
-- Luc

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-08-28 20:15   ` Luc Van Oostenryck
@ 2020-08-29  7:33     ` Miguel Ojeda
  0 siblings, 0 replies; 14+ messages in thread
From: Miguel Ojeda @ 2020-08-29  7:33 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-kernel

Hi Luc,

On Fri, Aug 28, 2020 at 10:15 PM Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
>
> But to the bot, any change to the content of the warning itself
> or its associated info is presented as a new warning.
> I've talked to the bot's guys about this problem and they've
> replied that they're seriously considering to change this behaviour.

I see! Well, I guess having a "false positive" is OK in that case. It
makes us look twice.

Thanks, queued!

Cheers,
Miguel

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-06-28  7:20 Luc Van Oostenryck
  2020-06-29 17:12 ` kernel test robot
  2020-06-29 18:08 ` kernel test robot
@ 2020-07-01 18:35 ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-07-01 18:35 UTC (permalink / raw)
  To: Luc Van Oostenryck, Andrew Morton
  Cc: kbuild-all, Linux Memory Management List, linux-kernel,
	Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 11783 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20200626]
[cannot apply to linux/master linus/master v5.8-rc2 v5.8-rc1 v5.7 v5.8-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200628-152401
base:    36e3135df4d426612fc77db26a312c2531108603
config: x86_64-randconfig-s021-20200701 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-3-gfa153962-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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 >>)

   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
>> arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] * @@
>> arch/x86/ia32/ia32_signal.c:350:9: sparse:     expected void const volatile [noderef] __user *ptr
   arch/x86/ia32/ia32_signal.c:350:9: sparse:     got unsigned long long [usertype] *
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/ia32/ia32_signal.c:350:9: sparse: sparse: cast removes address space '__user' of expression
--
>> drivers/w1/slaves/w1_ds28e04.c:342:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got char *buf @@
>> drivers/w1/slaves/w1_ds28e04.c:342:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/w1/slaves/w1_ds28e04.c:342:13: sparse:     got char *buf
>> drivers/w1/slaves/w1_ds28e04.c:356:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got char const *buf @@
   drivers/w1/slaves/w1_ds28e04.c:356:13: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/w1/slaves/w1_ds28e04.c:356:13: sparse:     got char const *buf
--
>> drivers/watchdog/sbc_fitpc2_wdt.c:99:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got char const * @@
>> drivers/watchdog/sbc_fitpc2_wdt.c:99:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/watchdog/sbc_fitpc2_wdt.c:99:21: sparse:     got char const *
   drivers/watchdog/sbc_fitpc2_wdt.c:128:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got struct watchdog_info * @@
   drivers/watchdog/sbc_fitpc2_wdt.c:128:37: sparse:     expected void [noderef] __user *to
   drivers/watchdog/sbc_fitpc2_wdt.c:128:37: sparse:     got struct watchdog_info *
>> drivers/watchdog/sbc_fitpc2_wdt.c:133:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int * @@
   drivers/watchdog/sbc_fitpc2_wdt.c:133:23: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/watchdog/sbc_fitpc2_wdt.c:133:23: sparse:     got int *
   drivers/watchdog/sbc_fitpc2_wdt.c:137:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int * @@
   drivers/watchdog/sbc_fitpc2_wdt.c:137:23: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/watchdog/sbc_fitpc2_wdt.c:137:23: sparse:     got int *
   drivers/watchdog/sbc_fitpc2_wdt.c:146:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int * @@
   drivers/watchdog/sbc_fitpc2_wdt.c:146:23: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/watchdog/sbc_fitpc2_wdt.c:146:23: sparse:     got int *
   drivers/watchdog/sbc_fitpc2_wdt.c:160:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got int * @@
   drivers/watchdog/sbc_fitpc2_wdt.c:160:23: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/watchdog/sbc_fitpc2_wdt.c:160:23: sparse:     got int *
   drivers/watchdog/sbc_fitpc2_wdt.c:187:27: sparse: sparse: incorrect type in initializer (incompatible argument 2 (different address spaces)) @@     expected long ( *write )( ... ) @@     got long ( * )( ... ) @@
   drivers/watchdog/sbc_fitpc2_wdt.c:187:27: sparse:     expected long ( *write )( ... )
   drivers/watchdog/sbc_fitpc2_wdt.c:187:27: sparse:     got long ( * )( ... )

vim +350 arch/x86/ia32/ia32_signal.c

^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  299  
235b80226b986d arch/x86/ia32/ia32_signal.c    Al Viro           2012-11-09  300  int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  301  			compat_sigset_t *set, struct pt_regs *regs)
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  302  {
3b0d29ee1c73b6 arch/x86/ia32/ia32_signal.c    Hiroshi Shimamoto 2008-12-17  303  	struct rt_sigframe_ia32 __user *frame;
af65d64845a90c arch/x86/ia32/ia32_signal.c    Roland McGrath    2008-01-30  304  	void __user *restorer;
44a1d996325982 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  305  	void __user *fp = NULL;
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  306  
57d563c8292569 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  307  	/* unsafe_put_user optimizes that into a single 8 byte store */
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  308  	static const struct {
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  309  		u8 movl;
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  310  		u32 val;
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  311  		u16 int80;
9cc3c49ed1b1db arch/x86/ia32/ia32_signal.c    Hiroshi Shimamoto 2008-11-11  312  		u8  pad;
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  313  	} __attribute__((packed)) code = {
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  314  		0xb8,
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  315  		__NR_ia32_rt_sigreturn,
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  316  		0x80cd,
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  317  		0,
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  318  	};
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  319  
44a1d996325982 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  320  	frame = get_sigframe(ksig, regs, sizeof(*frame), &fp);
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  321  
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  322  	if (!user_access_begin(frame, sizeof(*frame)))
3d0aedd9538e6b arch/x86/ia32/ia32_signal.c    Hiroshi Shimamoto 2008-09-12  323  		return -EFAULT;
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  324  
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  325  	unsafe_put_user(sig, &frame->sig, Efault);
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  326  	unsafe_put_user(ptr_to_compat(&frame->info), &frame->pinfo, Efault);
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  327  	unsafe_put_user(ptr_to_compat(&frame->uc), &frame->puc, Efault);
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  328  
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  329  	/* Create the ucontext.  */
ff661350157266 arch/x86/ia32/ia32_signal.c    Marco Elver       2019-07-11  330  	if (static_cpu_has(X86_FEATURE_XSAVE))
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  331  		unsafe_put_user(UC_FP_XSTATE, &frame->uc.uc_flags, Efault);
c37b5efea43f9e arch/x86/ia32/ia32_signal.c    Suresh Siddha     2008-07-29  332  	else
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  333  		unsafe_put_user(0, &frame->uc.uc_flags, Efault);
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  334  	unsafe_put_user(0, &frame->uc.uc_link, Efault);
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  335  	unsafe_compat_save_altstack(&frame->uc.uc_stack, regs->sp, Efault);
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  336  
235b80226b986d arch/x86/ia32/ia32_signal.c    Al Viro           2012-11-09  337  	if (ksig->ka.sa.sa_flags & SA_RESTORER)
235b80226b986d arch/x86/ia32/ia32_signal.c    Al Viro           2012-11-09  338  		restorer = ksig->ka.sa.sa_restorer;
af65d64845a90c arch/x86/ia32/ia32_signal.c    Roland McGrath    2008-01-30  339  	else
6f121e548f8367 arch/x86/ia32/ia32_signal.c    Andy Lutomirski   2014-05-05  340  		restorer = current->mm->context.vdso +
0a6d1fa0d2b48f arch/x86/ia32/ia32_signal.c    Andy Lutomirski   2015-10-05  341  			vdso_image_32.sym___kernel_rt_sigreturn;
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  342  	unsafe_put_user(ptr_to_compat(restorer), &frame->pretcode, Efault);
^1da177e4c3f41 arch/x86_64/ia32/ia32_signal.c Linus Torvalds    2005-04-16  343  
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  344  	/*
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  345  	 * Not actually used anymore, but left because some gdb
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  346  	 * versions need it.
99b9cdf758af70 arch/x86/ia32/ia32_signal.c    Thomas Gleixner   2008-01-30  347  	 */
39f16c1c0f14e9 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  348  	unsafe_put_user(*((u64 *)&code), (u64 __user *)frame->retcode, Efault);
44a1d996325982 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15  349  	unsafe_put_sigcontext32(&frame->uc.uc_mcontext, fp, regs, set, Efault);
57d563c8292569 arch/x86/ia32/ia32_signal.c    Al Viro           2020-02-15 @350  	unsafe_put_user(*(__u64 *)set, (__u64 *)&frame->uc.uc_sigmask, Efault);

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33774 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-06-29 18:08 ` kernel test robot
@ 2020-06-29 18:37   ` Luc Van Oostenryck
  0 siblings, 0 replies; 14+ messages in thread
From: Luc Van Oostenryck @ 2020-06-29 18:37 UTC (permalink / raw)
  To: kernel test robot; +Cc: kbuild-all, linux-kernel

On Tue, Jun 30, 2020 at 02:08:36AM +0800, kernel test robot wrote:
> Hi Luc,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on next-20200626]
> [cannot apply to linux/master linus/master v5.8-rc2 v5.8-rc1 v5.7 v5.8-rc3]
> [If your patch is applied to the wrong git tree, kindly drop us a note.

This patch should be applied on top of akpm's tree or on top of next.
I'm not sure hwo I should have specified this, 'git send-mail --base=...'
is less useful for these trees.

-- Luc

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-06-28  7:20 Luc Van Oostenryck
  2020-06-29 17:12 ` kernel test robot
@ 2020-06-29 18:08 ` kernel test robot
  2020-06-29 18:37   ` Luc Van Oostenryck
  2020-07-01 18:35 ` kernel test robot
  2 siblings, 1 reply; 14+ messages in thread
From: kernel test robot @ 2020-06-29 18:08 UTC (permalink / raw)
  To: Luc Van Oostenryck, Andrew Morton
  Cc: kbuild-all, Linux Memory Management List, linux-kernel,
	Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 23393 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20200626]
[cannot apply to linux/master linus/master v5.8-rc2 v5.8-rc1 v5.7 v5.8-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200628-152401
base:    36e3135df4d426612fc77db26a312c2531108603
config: i386-randconfig-s002-20200629 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-3-gfa153962-dirty
        # save the attached .config to linux build tree
        make W=1 C= CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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/gpu/drm/amd/amdgpu/amdgpu_ttm.c:818:42: sparse: sparse: cast removes address space '__iomem' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2388:21: sparse: sparse: cast removes address space '__user' of expression
--
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:384:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:399:21: sparse: sparse: cast removes address space '__user' of expression
--
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:138:17: sparse: sparse: incorrect type in initializer (different base types) @@     expected restricted __poll_t ( *poll )( ... ) @@     got unsigned int ( * )( ... ) @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:138:17: sparse:     expected restricted __poll_t ( *poll )( ... )
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:138:17: sparse:     got unsigned int ( * )( ... )
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
>> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
>> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:261:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:263:29: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:354:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:412:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:473:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:531:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse:     expected void const volatile [noderef] __user *ptr
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse:     got unsigned int [usertype] *
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:592:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: cast removes address space '__user' of expression
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned int [usertype] * @@
   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:650:21: sparse:     expected void const volatile [noderef] __user *ptr

vim +2388 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

d38ceaf99ed015 Alex Deucher    2015-04-20  2362  
50da51744f005f Tom St Denis    2018-05-09  2363  /**
50da51744f005f Tom St Denis    2018-05-09  2364   * amdgpu_ttm_vram_write - Linear write access to VRAM
50da51744f005f Tom St Denis    2018-05-09  2365   *
50da51744f005f Tom St Denis    2018-05-09  2366   * Accesses VRAM via MMIO for debugging purposes.
50da51744f005f Tom St Denis    2018-05-09  2367   */
08cab989f77582 Tom St Denis    2017-08-29  2368  static ssize_t amdgpu_ttm_vram_write(struct file *f, const char __user *buf,
08cab989f77582 Tom St Denis    2017-08-29  2369  				    size_t size, loff_t *pos)
08cab989f77582 Tom St Denis    2017-08-29  2370  {
08cab989f77582 Tom St Denis    2017-08-29  2371  	struct amdgpu_device *adev = file_inode(f)->i_private;
08cab989f77582 Tom St Denis    2017-08-29  2372  	ssize_t result = 0;
08cab989f77582 Tom St Denis    2017-08-29  2373  	int r;
08cab989f77582 Tom St Denis    2017-08-29  2374  
08cab989f77582 Tom St Denis    2017-08-29  2375  	if (size & 0x3 || *pos & 0x3)
08cab989f77582 Tom St Denis    2017-08-29  2376  		return -EINVAL;
08cab989f77582 Tom St Denis    2017-08-29  2377  
770d13b19fdf36 Christian König 2018-01-12  2378  	if (*pos >= adev->gmc.mc_vram_size)
08cab989f77582 Tom St Denis    2017-08-29  2379  		return -ENXIO;
08cab989f77582 Tom St Denis    2017-08-29  2380  
08cab989f77582 Tom St Denis    2017-08-29  2381  	while (size) {
08cab989f77582 Tom St Denis    2017-08-29  2382  		unsigned long flags;
08cab989f77582 Tom St Denis    2017-08-29  2383  		uint32_t value;
08cab989f77582 Tom St Denis    2017-08-29  2384  
770d13b19fdf36 Christian König 2018-01-12  2385  		if (*pos >= adev->gmc.mc_vram_size)
08cab989f77582 Tom St Denis    2017-08-29  2386  			return result;
08cab989f77582 Tom St Denis    2017-08-29  2387  
08cab989f77582 Tom St Denis    2017-08-29 @2388  		r = get_user(value, (uint32_t *)buf);
08cab989f77582 Tom St Denis    2017-08-29  2389  		if (r)
08cab989f77582 Tom St Denis    2017-08-29  2390  			return r;
08cab989f77582 Tom St Denis    2017-08-29  2391  
08cab989f77582 Tom St Denis    2017-08-29  2392  		spin_lock_irqsave(&adev->mmio_idx_lock, flags);
c30572814df55b Tom St Denis    2017-09-13  2393  		WREG32_NO_KIQ(mmMM_INDEX, ((uint32_t)*pos) | 0x80000000);
c30572814df55b Tom St Denis    2017-09-13  2394  		WREG32_NO_KIQ(mmMM_INDEX_HI, *pos >> 31);
c30572814df55b Tom St Denis    2017-09-13  2395  		WREG32_NO_KIQ(mmMM_DATA, value);
08cab989f77582 Tom St Denis    2017-08-29  2396  		spin_unlock_irqrestore(&adev->mmio_idx_lock, flags);
08cab989f77582 Tom St Denis    2017-08-29  2397  
08cab989f77582 Tom St Denis    2017-08-29  2398  		result += 4;
08cab989f77582 Tom St Denis    2017-08-29  2399  		buf += 4;
08cab989f77582 Tom St Denis    2017-08-29  2400  		*pos += 4;
08cab989f77582 Tom St Denis    2017-08-29  2401  		size -= 4;
08cab989f77582 Tom St Denis    2017-08-29  2402  	}
08cab989f77582 Tom St Denis    2017-08-29  2403  
08cab989f77582 Tom St Denis    2017-08-29  2404  	return result;
08cab989f77582 Tom St Denis    2017-08-29  2405  }
08cab989f77582 Tom St Denis    2017-08-29  2406  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33750 bytes --]

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

* Re: [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
  2020-06-28  7:20 Luc Van Oostenryck
@ 2020-06-29 17:12 ` kernel test robot
  2020-06-29 18:08 ` kernel test robot
  2020-07-01 18:35 ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-06-29 17:12 UTC (permalink / raw)
  To: Luc Van Oostenryck, Andrew Morton
  Cc: kbuild-all, Linux Memory Management List, linux-kernel,
	Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 9896 bytes --]

Hi Luc,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20200626]
[cannot apply to linux/master linus/master v5.8-rc2 v5.8-rc1 v5.7 v5.8-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Luc-Van-Oostenryck/sparse-use-static-inline-for-__chk_-user-io-_ptr/20200628-152401
base:    36e3135df4d426612fc77db26a312c2531108603
config: i386-randconfig-s001-20200629 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-3-gfa153962-dirty
        # save the attached .config to linux build tree
        make W=1 C= CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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 >>)

   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
>> arch/x86/kernel/signal.c:337:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] * @@
>> arch/x86/kernel/signal.c:337:9: sparse:     expected void const volatile [noderef] __user *ptr
   arch/x86/kernel/signal.c:337:9: sparse:     got unsigned long long [usertype] *
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:337:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __user *ptr @@     got unsigned long long [usertype] * @@
   arch/x86/kernel/signal.c:397:9: sparse:     expected void const volatile [noderef] __user *ptr
   arch/x86/kernel/signal.c:397:9: sparse:     got unsigned long long [usertype] *
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression
   arch/x86/kernel/signal.c:397:9: sparse: sparse: cast removes address space '__user' of expression

vim +337 arch/x86/kernel/signal.c

75779f05264b99 arch/x86/kernel/signal.c    Hiroshi Shimamoto 2009-02-27  302  
7e907f48980d66 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  303  static int
235b80226b986d arch/x86/kernel/signal.c    Al Viro           2012-11-09  304  __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
7e907f48980d66 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  305  	      struct pt_regs *regs)
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  306  {
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  307  	struct sigframe __user *frame;
7e907f48980d66 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  308  	void __user *restorer;
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  309  	void __user *fp = NULL;
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  310  
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  311  	frame = get_sigframe(&ksig->ka, regs, sizeof(*frame), &fp);
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  312  
5c1f178094631e arch/x86/kernel/signal.c    Al Viro           2020-02-15  313  	if (!user_access_begin(frame, sizeof(*frame)))
3d0aedd9538e6b arch/x86/kernel/signal_32.c Hiroshi Shimamoto 2008-09-12  314  		return -EFAULT;
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  315  
5c1f178094631e arch/x86/kernel/signal.c    Al Viro           2020-02-15  316  	unsafe_put_user(sig, &frame->sig, Efault);
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  317  	unsafe_put_sigcontext(&frame->sc, fp, regs, set, Efault);
5c1f178094631e arch/x86/kernel/signal.c    Al Viro           2020-02-15  318  	unsafe_put_user(set->sig[1], &frame->extramask[0], Efault);
1a3e4ca41c5a38 arch/x86/kernel/signal_32.c Roland McGrath    2008-04-09  319  	if (current->mm->context.vdso)
6f121e548f8367 arch/x86/kernel/signal.c    Andy Lutomirski   2014-05-05  320  		restorer = current->mm->context.vdso +
0a6d1fa0d2b48f arch/x86/kernel/signal.c    Andy Lutomirski   2015-10-05  321  			vdso_image_32.sym___kernel_sigreturn;
9fbbd4dd17d071 arch/i386/kernel/signal.c   Andi Kleen        2007-02-13  322  	else
ade1af77129dea arch/x86/kernel/signal_32.c Jan Engelhardt    2008-01-30  323  		restorer = &frame->retcode;
235b80226b986d arch/x86/kernel/signal.c    Al Viro           2012-11-09  324  	if (ksig->ka.sa.sa_flags & SA_RESTORER)
235b80226b986d arch/x86/kernel/signal.c    Al Viro           2012-11-09  325  		restorer = ksig->ka.sa.sa_restorer;
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  326  
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  327  	/* Set up to return from userspace.  */
5c1f178094631e arch/x86/kernel/signal.c    Al Viro           2020-02-15  328  	unsafe_put_user(restorer, &frame->pretcode, Efault);
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  329  
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  330  	/*
7e907f48980d66 arch/x86/kernel/signal_32.c Ingo Molnar       2008-03-06  331  	 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  332  	 *
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  333  	 * WE DO NOT USE IT ANY MORE! It's only left here for historical
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  334  	 * reasons and because gdb uses it as a signature to notice
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  335  	 * signal handler stack frames.
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  336  	 */
5c1f178094631e arch/x86/kernel/signal.c    Al Viro           2020-02-15 @337  	unsafe_put_user(*((u64 *)&retcode), (u64 *)frame->retcode, Efault);
5c1f178094631e arch/x86/kernel/signal.c    Al Viro           2020-02-15  338  	user_access_end();
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  339  
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  340  	/* Set up registers for signal handler */
65ea5b03499035 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  341  	regs->sp = (unsigned long)frame;
235b80226b986d arch/x86/kernel/signal.c    Al Viro           2012-11-09  342  	regs->ip = (unsigned long)ksig->ka.sa.sa_handler;
65ea5b03499035 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  343  	regs->ax = (unsigned long)sig;
92bc2056855b32 arch/x86/kernel/signal_32.c Harvey Harrison   2008-02-08  344  	regs->dx = 0;
92bc2056855b32 arch/x86/kernel/signal_32.c Harvey Harrison   2008-02-08  345  	regs->cx = 0;
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  346  
65ea5b03499035 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  347  	regs->ds = __USER_DS;
65ea5b03499035 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  348  	regs->es = __USER_DS;
65ea5b03499035 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  349  	regs->ss = __USER_DS;
65ea5b03499035 arch/x86/kernel/signal_32.c H. Peter Anvin    2008-01-30  350  	regs->cs = __USER_CS;
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  351  
283828f3c19ceb arch/i386/kernel/signal.c   David Howells     2006-01-18  352  	return 0;
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  353  
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  354  Efault:
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  355  	user_access_end();
b00d8f8f0b2b39 arch/x86/kernel/signal.c    Al Viro           2020-02-15  356  	return -EFAULT;
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  357  }
^1da177e4c3f41 arch/i386/kernel/signal.c   Linus Torvalds    2005-04-16  358  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28288 bytes --]

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

* [PATCH] sparse: use static inline for __chk_{user,io}_ptr()
@ 2020-06-28  7:20 Luc Van Oostenryck
  2020-06-29 17:12 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Luc Van Oostenryck @ 2020-06-28  7:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Luc Van Oostenryck

__chk_user_ptr() & __chk_io_ptr() are dummy extern functions which
only exist to enforce the typechecking of __user or __iomem pointers
in macros when using sparse.

This typechecking is done by inserting a call to these functions.
But the presence of these calls can inhibit some simplifications
and so influence the result of sparse's analysis of context/locking.

Fix this by changing these calls into static inline calls with
an empty body.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 include/linux/compiler_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index b67930216e45..a9b6699f3934 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -11,8 +11,8 @@
 # define __iomem	__attribute__((noderef, address_space(__iomem)))
 # define __percpu	__attribute__((noderef, address_space(__percpu)))
 # define __rcu		__attribute__((noderef, address_space(__rcu)))
-extern void __chk_user_ptr(const volatile void __user *);
-extern void __chk_io_ptr(const volatile void __iomem *);
+static inline void __chk_user_ptr(const volatile void __user *ptr) { }
+static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
 /* context/locking */
 # define __must_hold(x)	__attribute__((context(x,1,1)))
 # define __acquires(x)	__attribute__((context(x,0,1)))
-- 
2.27.0


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

end of thread, other threads:[~2020-08-29  7:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28  8:53 [PATCH] sparse: use static inline for __chk_{user,io}_ptr() Luc Van Oostenryck
2020-08-28 11:15 ` kernel test robot
2020-08-28 11:37 ` kernel test robot
2020-08-28 12:20 ` kernel test robot
2020-08-28 14:21 ` kernel test robot
2020-08-28 15:11 ` kernel test robot
2020-08-28 19:04 ` Miguel Ojeda
2020-08-28 20:15   ` Luc Van Oostenryck
2020-08-29  7:33     ` Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2020-06-28  7:20 Luc Van Oostenryck
2020-06-29 17:12 ` kernel test robot
2020-06-29 18:08 ` kernel test robot
2020-06-29 18:37   ` Luc Van Oostenryck
2020-07-01 18:35 ` 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;
as well as URLs for NNTP newsgroup(s).