MIPS: ptrace: Avoid smp_processor_id() in preemptible code

ptrace_{get,set}_watch_regs access current_cpu_data to get the watch
register count/masks, which calls smp_processor_id(). However they are
run in preemptible context and therefore trigger warnings like so:

[ 6340.092000] BUG: using smp_processor_id() in preemptible [00000000] code: gdb/367
[ 6340.092000] caller is ptrace_get_watch_regs+0x44/0x220

Since the watch register count/masks should be the same across all
CPUs, use boot_cpu_data instead. Note that this may need to change in
future should a heterogenous system be supported where the count/masks
are not the same across all CPUs (the current code is also incorrect
for this scenario - current_cpu_data here would not necessarily be
correct for the CPU that the target task will execute on).

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/6879/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by Alex Smith and committed by Ralf Baechle 57c7ea51 f02ffb19

Changed files
+7 -7
arch
mips
kernel
+7 -7
arch/mips/kernel/ptrace.c
··· 163 163 enum pt_watch_style style; 164 164 int i; 165 165 166 - if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0) 166 + if (!cpu_has_watch || boot_cpu_data.watch_reg_use_cnt == 0) 167 167 return -EIO; 168 168 if (!access_ok(VERIFY_WRITE, addr, sizeof(struct pt_watch_regs))) 169 169 return -EIO; ··· 177 177 #endif 178 178 179 179 __put_user(style, &addr->style); 180 - __put_user(current_cpu_data.watch_reg_use_cnt, 180 + __put_user(boot_cpu_data.watch_reg_use_cnt, 181 181 &addr->WATCH_STYLE.num_valid); 182 - for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) { 182 + for (i = 0; i < boot_cpu_data.watch_reg_use_cnt; i++) { 183 183 __put_user(child->thread.watch.mips3264.watchlo[i], 184 184 &addr->WATCH_STYLE.watchlo[i]); 185 185 __put_user(child->thread.watch.mips3264.watchhi[i] & 0xfff, 186 186 &addr->WATCH_STYLE.watchhi[i]); 187 - __put_user(current_cpu_data.watch_reg_masks[i], 187 + __put_user(boot_cpu_data.watch_reg_masks[i], 188 188 &addr->WATCH_STYLE.watch_masks[i]); 189 189 } 190 190 for (; i < 8; i++) { ··· 204 204 unsigned long lt[NUM_WATCH_REGS]; 205 205 u16 ht[NUM_WATCH_REGS]; 206 206 207 - if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0) 207 + if (!cpu_has_watch || boot_cpu_data.watch_reg_use_cnt == 0) 208 208 return -EIO; 209 209 if (!access_ok(VERIFY_READ, addr, sizeof(struct pt_watch_regs))) 210 210 return -EIO; 211 211 /* Check the values. */ 212 - for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) { 212 + for (i = 0; i < boot_cpu_data.watch_reg_use_cnt; i++) { 213 213 __get_user(lt[i], &addr->WATCH_STYLE.watchlo[i]); 214 214 #ifdef CONFIG_32BIT 215 215 if (lt[i] & __UA_LIMIT) ··· 228 228 return -EINVAL; 229 229 } 230 230 /* Install them. */ 231 - for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) { 231 + for (i = 0; i < boot_cpu_data.watch_reg_use_cnt; i++) { 232 232 if (lt[i] & 7) 233 233 watch_active = 1; 234 234 child->thread.watch.mips3264.watchlo[i] = lt[i];