diff options
author | Alex Smith <alex.smith@imgtec.com> | 2014-05-01 07:51:19 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-05-28 04:54:41 -0400 |
commit | 57c7ea513f0e4b033ba602550992e2ca0e6b8d2c (patch) | |
tree | 8bf4a477987a4fb671c099cea658b2a3a5ac3c63 | |
parent | f02ffb199d3af57407a79075f3e0e6c0e8980b6c (diff) |
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>
-rw-r--r-- | arch/mips/kernel/ptrace.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 71f85f427034..f639ccd5060c 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -163,7 +163,7 @@ int ptrace_get_watch_regs(struct task_struct *child, | |||
163 | enum pt_watch_style style; | 163 | enum pt_watch_style style; |
164 | int i; | 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 | return -EIO; | 167 | return -EIO; |
168 | if (!access_ok(VERIFY_WRITE, addr, sizeof(struct pt_watch_regs))) | 168 | if (!access_ok(VERIFY_WRITE, addr, sizeof(struct pt_watch_regs))) |
169 | return -EIO; | 169 | return -EIO; |
@@ -177,14 +177,14 @@ int ptrace_get_watch_regs(struct task_struct *child, | |||
177 | #endif | 177 | #endif |
178 | 178 | ||
179 | __put_user(style, &addr->style); | 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 | &addr->WATCH_STYLE.num_valid); | 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 | __put_user(child->thread.watch.mips3264.watchlo[i], | 183 | __put_user(child->thread.watch.mips3264.watchlo[i], |
184 | &addr->WATCH_STYLE.watchlo[i]); | 184 | &addr->WATCH_STYLE.watchlo[i]); |
185 | __put_user(child->thread.watch.mips3264.watchhi[i] & 0xfff, | 185 | __put_user(child->thread.watch.mips3264.watchhi[i] & 0xfff, |
186 | &addr->WATCH_STYLE.watchhi[i]); | 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 | &addr->WATCH_STYLE.watch_masks[i]); | 188 | &addr->WATCH_STYLE.watch_masks[i]); |
189 | } | 189 | } |
190 | for (; i < 8; i++) { | 190 | for (; i < 8; i++) { |
@@ -204,12 +204,12 @@ int ptrace_set_watch_regs(struct task_struct *child, | |||
204 | unsigned long lt[NUM_WATCH_REGS]; | 204 | unsigned long lt[NUM_WATCH_REGS]; |
205 | u16 ht[NUM_WATCH_REGS]; | 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 | return -EIO; | 208 | return -EIO; |
209 | if (!access_ok(VERIFY_READ, addr, sizeof(struct pt_watch_regs))) | 209 | if (!access_ok(VERIFY_READ, addr, sizeof(struct pt_watch_regs))) |
210 | return -EIO; | 210 | return -EIO; |
211 | /* Check the values. */ | 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 | __get_user(lt[i], &addr->WATCH_STYLE.watchlo[i]); | 213 | __get_user(lt[i], &addr->WATCH_STYLE.watchlo[i]); |
214 | #ifdef CONFIG_32BIT | 214 | #ifdef CONFIG_32BIT |
215 | if (lt[i] & __UA_LIMIT) | 215 | if (lt[i] & __UA_LIMIT) |
@@ -228,7 +228,7 @@ int ptrace_set_watch_regs(struct task_struct *child, | |||
228 | return -EINVAL; | 228 | return -EINVAL; |
229 | } | 229 | } |
230 | /* Install them. */ | 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 | if (lt[i] & 7) | 232 | if (lt[i] & 7) |
233 | watch_active = 1; | 233 | watch_active = 1; |
234 | child->thread.watch.mips3264.watchlo[i] = lt[i]; | 234 | child->thread.watch.mips3264.watchlo[i] = lt[i]; |