__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 <[email protected]>
---
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
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 <[email protected]>
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/[email protected]
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 <[email protected]>
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/[email protected]
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 <[email protected]>
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/[email protected]
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 <[email protected]>
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/[email protected]
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 <[email protected]>
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/[email protected]
Hi Luc,
On Fri, Aug 28, 2020 at 10:53 AM Luc Van Oostenryck
<[email protected]> 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
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
> <[email protected]> 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
Hi Luc,
On Fri, Aug 28, 2020 at 10:15 PM Luc Van Oostenryck
<[email protected]> 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