From: kernel test robot <lkp@intel.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Subject: arch/arm/kernel/swp_emulate.c:198:14: sparse: sparse: incorrect type in argument 1 (different base types)
Date: Tue, 10 Nov 2020 02:47:25 +0800 [thread overview]
Message-ID: <202011100217.F2MVOCls-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 7559 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f8394f232b1eab649ce2df5c5f15b0e528c92091
commit: e5fc436f06eef54ef512ea55a9db8eb9f2e76959 sparse: use static inline for __chk_{user,io}_ptr()
date: 2 months ago
config: arm-randconfig-s031-20201105 (attached as .config)
compiler: arm-linux-gnueabi-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.3-76-gf680124b-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5fc436f06eef54ef512ea55a9db8eb9f2e76959
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout e5fc436f06eef54ef512ea55a9db8eb9f2e76959
# 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=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"sparse warnings: (new ones prefixed by >>)"
>> arch/arm/kernel/swp_emulate.c:198:14: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int @@
>> arch/arm/kernel/swp_emulate.c:198:14: sparse: expected void const volatile [noderef] __user *ptr
arch/arm/kernel/swp_emulate.c:198:14: sparse: got unsigned int
vim +198 arch/arm/kernel/swp_emulate.c
64d2dc384e41e2b Leif Lindholm 2010-09-16 153
64d2dc384e41e2b Leif Lindholm 2010-09-16 154 /*
64d2dc384e41e2b Leif Lindholm 2010-09-16 155 * swp_handler logs the id of calling process, dissects the instruction, sanity
64d2dc384e41e2b Leif Lindholm 2010-09-16 156 * checks the memory location, calls emulate_swpX for the actual operation and
64d2dc384e41e2b Leif Lindholm 2010-09-16 157 * deals with fixup/error handling before returning
64d2dc384e41e2b Leif Lindholm 2010-09-16 158 */
64d2dc384e41e2b Leif Lindholm 2010-09-16 159 static int swp_handler(struct pt_regs *regs, unsigned int instr)
64d2dc384e41e2b Leif Lindholm 2010-09-16 160 {
64d2dc384e41e2b Leif Lindholm 2010-09-16 161 unsigned int address, destreg, data, type;
64d2dc384e41e2b Leif Lindholm 2010-09-16 162 unsigned int res = 0;
64d2dc384e41e2b Leif Lindholm 2010-09-16 163
a8b0ca17b80e92f Peter Zijlstra 2011-06-27 164 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, regs->ARM_pc);
64d2dc384e41e2b Leif Lindholm 2010-09-16 165
c245dcd326fb9f8 Leif Lindholm 2011-12-12 166 res = arm_check_condition(instr, regs->ARM_cpsr);
c245dcd326fb9f8 Leif Lindholm 2011-12-12 167 switch (res) {
c245dcd326fb9f8 Leif Lindholm 2011-12-12 168 case ARM_OPCODE_CONDTEST_PASS:
c245dcd326fb9f8 Leif Lindholm 2011-12-12 169 break;
c245dcd326fb9f8 Leif Lindholm 2011-12-12 170 case ARM_OPCODE_CONDTEST_FAIL:
c245dcd326fb9f8 Leif Lindholm 2011-12-12 171 /* Condition failed - return to next instruction */
c245dcd326fb9f8 Leif Lindholm 2011-12-12 172 regs->ARM_pc += 4;
c245dcd326fb9f8 Leif Lindholm 2011-12-12 173 return 0;
c245dcd326fb9f8 Leif Lindholm 2011-12-12 174 case ARM_OPCODE_CONDTEST_UNCOND:
c245dcd326fb9f8 Leif Lindholm 2011-12-12 175 /* If unconditional encoding - not a SWP, undef */
c245dcd326fb9f8 Leif Lindholm 2011-12-12 176 return -EFAULT;
c245dcd326fb9f8 Leif Lindholm 2011-12-12 177 default:
c245dcd326fb9f8 Leif Lindholm 2011-12-12 178 return -EINVAL;
c245dcd326fb9f8 Leif Lindholm 2011-12-12 179 }
c245dcd326fb9f8 Leif Lindholm 2011-12-12 180
64d2dc384e41e2b Leif Lindholm 2010-09-16 181 if (current->pid != previous_pid) {
64d2dc384e41e2b Leif Lindholm 2010-09-16 182 pr_debug("\"%s\" (%ld) uses deprecated SWP{B} instruction\n",
64d2dc384e41e2b Leif Lindholm 2010-09-16 183 current->comm, (unsigned long)current->pid);
64d2dc384e41e2b Leif Lindholm 2010-09-16 184 previous_pid = current->pid;
64d2dc384e41e2b Leif Lindholm 2010-09-16 185 }
64d2dc384e41e2b Leif Lindholm 2010-09-16 186
64d2dc384e41e2b Leif Lindholm 2010-09-16 187 address = regs->uregs[EXTRACT_REG_NUM(instr, RN_OFFSET)];
64d2dc384e41e2b Leif Lindholm 2010-09-16 188 data = regs->uregs[EXTRACT_REG_NUM(instr, RT2_OFFSET)];
64d2dc384e41e2b Leif Lindholm 2010-09-16 189 destreg = EXTRACT_REG_NUM(instr, RT_OFFSET);
64d2dc384e41e2b Leif Lindholm 2010-09-16 190
64d2dc384e41e2b Leif Lindholm 2010-09-16 191 type = instr & TYPE_SWPB;
64d2dc384e41e2b Leif Lindholm 2010-09-16 192
64d2dc384e41e2b Leif Lindholm 2010-09-16 193 pr_debug("addr in r%d->0x%08x, dest is r%d, source in r%d->0x%08x)\n",
64d2dc384e41e2b Leif Lindholm 2010-09-16 194 EXTRACT_REG_NUM(instr, RN_OFFSET), address,
64d2dc384e41e2b Leif Lindholm 2010-09-16 195 destreg, EXTRACT_REG_NUM(instr, RT2_OFFSET), data);
64d2dc384e41e2b Leif Lindholm 2010-09-16 196
64d2dc384e41e2b Leif Lindholm 2010-09-16 197 /* Check access in reasonable access range for both SWP and SWPB */
96d4f267e40f950 Linus Torvalds 2019-01-03 @198 if (!access_ok((address & ~3), 4)) {
64d2dc384e41e2b Leif Lindholm 2010-09-16 199 pr_debug("SWP{B} emulation: access to %p not allowed!\n",
64d2dc384e41e2b Leif Lindholm 2010-09-16 200 (void *)address);
64d2dc384e41e2b Leif Lindholm 2010-09-16 201 res = -EFAULT;
64d2dc384e41e2b Leif Lindholm 2010-09-16 202 } else {
64d2dc384e41e2b Leif Lindholm 2010-09-16 203 res = emulate_swpX(address, &data, type);
64d2dc384e41e2b Leif Lindholm 2010-09-16 204 }
64d2dc384e41e2b Leif Lindholm 2010-09-16 205
64d2dc384e41e2b Leif Lindholm 2010-09-16 206 if (res == 0) {
64d2dc384e41e2b Leif Lindholm 2010-09-16 207 /*
64d2dc384e41e2b Leif Lindholm 2010-09-16 208 * On successful emulation, revert the adjustment to the PC
64d2dc384e41e2b Leif Lindholm 2010-09-16 209 * made in kernel/traps.c in order to resume execution at the
64d2dc384e41e2b Leif Lindholm 2010-09-16 210 * instruction following the SWP{B}.
64d2dc384e41e2b Leif Lindholm 2010-09-16 211 */
64d2dc384e41e2b Leif Lindholm 2010-09-16 212 regs->ARM_pc += 4;
64d2dc384e41e2b Leif Lindholm 2010-09-16 213 regs->uregs[destreg] = data;
64d2dc384e41e2b Leif Lindholm 2010-09-16 214 } else if (res == -EFAULT) {
64d2dc384e41e2b Leif Lindholm 2010-09-16 215 /*
64d2dc384e41e2b Leif Lindholm 2010-09-16 216 * Memory errors do not mean emulation failed.
64d2dc384e41e2b Leif Lindholm 2010-09-16 217 * Set up signal info to return SEGV, then return OK
64d2dc384e41e2b Leif Lindholm 2010-09-16 218 */
64d2dc384e41e2b Leif Lindholm 2010-09-16 219 set_segfault(regs, address);
64d2dc384e41e2b Leif Lindholm 2010-09-16 220 }
64d2dc384e41e2b Leif Lindholm 2010-09-16 221
64d2dc384e41e2b Leif Lindholm 2010-09-16 222 return 0;
64d2dc384e41e2b Leif Lindholm 2010-09-16 223 }
64d2dc384e41e2b Leif Lindholm 2010-09-16 224
:::::: The code at line 198 was first introduced by commit
:::::: 96d4f267e40f9509e8a66e2b39e8b95655617693 Remove 'type' argument from access_ok() function
:::::: TO: Linus Torvalds <torvalds@linux-foundation.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32738 bytes --]
next reply other threads:[~2020-11-09 18:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 18:47 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-05-01 12:46 arch/arm/kernel/swp_emulate.c:198:14: sparse: sparse: incorrect type in argument 1 (different base types) kernel test robot
2020-11-10 4:13 kernel test robot
2020-11-09 9:54 kernel test robot
2020-11-09 8:16 kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202011100217.F2MVOCls-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=miguel.ojeda.sandonis@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox