arch/arc/kernel/signal.c:77:31: sparse: sparse: incorrect type in argument 1 (different address spaces)

kernel test robot
2022-02-25T23:30:37Z

head: 53ab78cd6d5aba25575a7cfb95729336ba9497d8
commit: 96f1b00138cb8f04c742c82d0a7c460b2202e887 ARCv2: save ABI registers across signal handling
date: 9 months ago
config: arc-randconfig-s032-20220226 (https://download.01.org/0day-ci/archive/20220226/202202260759.DXHGI8gG-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.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.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=96f1b00138cb8f04c742c82d0a7c460b2202e887
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 96f1b00138cb8f04c742c82d0a7c460b2202e887
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arc SHELL=/bin/bash arch/arc/kernel/ drivers/remoteproc/ fs/ kernel/

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

sparse warnings: (new ones prefixed by >>)
>> arch/arc/kernel/signal.c:77:31: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got struct user_regs_arcv2 * @@
arch/arc/kernel/signal.c:77:31: sparse: expected void [noderef] __user *to
arch/arc/kernel/signal.c:77:31: sparse: got struct user_regs_arcv2 *
>> arch/arc/kernel/signal.c:88:41: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *from @@ got struct user_regs_arcv2 * @@
arch/arc/kernel/signal.c:88:41: sparse: expected void const [noderef] __user *from
arch/arc/kernel/signal.c:88:41: sparse: got struct user_regs_arcv2 *
>> arch/arc/kernel/signal.c:134:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sigcontext *mctx @@ got struct sigcontext [noderef] __user * @@
arch/arc/kernel/signal.c:134:42: sparse: expected struct sigcontext *mctx
arch/arc/kernel/signal.c:134:42: sparse: got struct sigcontext [noderef] __user *
arch/arc/kernel/signal.c:153:45: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sigcontext *mctx @@ got struct sigcontext [noderef] __user * @@
arch/arc/kernel/signal.c:153:45: sparse: expected struct sigcontext *mctx
arch/arc/kernel/signal.c:153:45: sparse: got struct sigcontext [noderef] __user *

vim +77 arch/arc/kernel/signal.c

63
64 static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
65 {
66 int err = 0;
67 #ifndef CONFIG_ISA_ARCOMPACT
68 struct user_regs_arcv2 v2abi;
69
70 v2abi.r30 = regs->r30;
71 #ifdef CONFIG_ARC_HAS_ACCL_REGS
72 v2abi.r58 = regs->r58;
73 v2abi.r59 = regs->r59;
74 #else
75 v2abi.r58 = v2abi.r59 = 0;
76 #endif
> 77 err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi));
78 #endif
79 return err;
80 }
81
82 static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
83 {
84 int err = 0;
85 #ifndef CONFIG_ISA_ARCOMPACT
86 struct user_regs_arcv2 v2abi;
87
> 88 err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi));
89
90 regs->r30 = v2abi.r30;
91 #ifdef CONFIG_ARC_HAS_ACCL_REGS
92 regs->r58 = v2abi.r58;
93 regs->r59 = v2abi.r59;
94 #endif
95 #endif
96 return err;
97 }
98
99 static int
100 stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
101 sigset_t *set)
102 {
103 int err;
104 struct user_regs_struct uregs;
105
106 uregs.scratch.bta = regs->bta;
107 uregs.scratch.lp_start = regs->lp_start;
108 uregs.scratch.lp_end = regs->lp_end;
109 uregs.scratch.lp_count = regs->lp_count;
110 uregs.scratch.status32 = regs->status32;
111 uregs.scratch.ret = regs->ret;
112 uregs.scratch.blink = regs->blink;
113 uregs.scratch.fp = regs->fp;
114 uregs.scratch.gp = regs->r26;
115 uregs.scratch.r12 = regs->r12;
116 uregs.scratch.r11 = regs->r11;
117 uregs.scratch.r10 = regs->r10;
118 uregs.scratch.r9 = regs->r9;
119 uregs.scratch.r8 = regs->r8;
120 uregs.scratch.r7 = regs->r7;
121 uregs.scratch.r6 = regs->r6;
122 uregs.scratch.r5 = regs->r5;
123 uregs.scratch.r4 = regs->r4;
124 uregs.scratch.r3 = regs->r3;
125 uregs.scratch.r2 = regs->r2;
126 uregs.scratch.r1 = regs->r1;
127 uregs.scratch.r0 = regs->r0;
128 uregs.scratch.sp = regs->sp;
129
130 err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
131 sizeof(sf->uc.uc_mcontext.regs.scratch));
132
133 if (is_isa_arcv2())
> 134 err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs);
135
136 err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
137
138 return err ? -EFAULT : 0;
139 }
140

---
0-DAY CI Kernel Test Service, Intel Corporation