.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * AArch64 KGDB support |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright (C) 2013 Cavium Inc. |
---|
7 | 8 | * Author: Vijaya Kumar K <vijaya.kumar@caviumnetworks.com> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License version 2 as |
---|
11 | | - * published by the Free Software Foundation. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | | - * |
---|
18 | | - * You should have received a copy of the GNU General Public License |
---|
19 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | 9 | */ |
---|
21 | 10 | |
---|
22 | 11 | #include <linux/bug.h> |
---|
.. | .. |
---|
234 | 223 | */ |
---|
235 | 224 | if (!kernel_active_single_step()) |
---|
236 | 225 | kernel_enable_single_step(linux_regs); |
---|
| 226 | + else |
---|
| 227 | + kernel_rewind_single_step(linux_regs); |
---|
237 | 228 | err = 0; |
---|
238 | 229 | break; |
---|
239 | 230 | default: |
---|
.. | .. |
---|
244 | 235 | |
---|
245 | 236 | static int kgdb_brk_fn(struct pt_regs *regs, unsigned int esr) |
---|
246 | 237 | { |
---|
247 | | - if (user_mode(regs)) |
---|
248 | | - return DBG_HOOK_ERROR; |
---|
249 | | - |
---|
250 | 238 | kgdb_handle_exception(1, SIGTRAP, 0, regs); |
---|
251 | 239 | return DBG_HOOK_HANDLED; |
---|
252 | 240 | } |
---|
.. | .. |
---|
254 | 242 | |
---|
255 | 243 | static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) |
---|
256 | 244 | { |
---|
257 | | - if (user_mode(regs)) |
---|
258 | | - return DBG_HOOK_ERROR; |
---|
259 | | - |
---|
260 | 245 | compiled_break = 1; |
---|
261 | 246 | kgdb_handle_exception(1, SIGTRAP, 0, regs); |
---|
262 | 247 | |
---|
.. | .. |
---|
266 | 251 | |
---|
267 | 252 | static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) |
---|
268 | 253 | { |
---|
269 | | - if (user_mode(regs) || !kgdb_single_step) |
---|
| 254 | + if (!kgdb_single_step) |
---|
270 | 255 | return DBG_HOOK_ERROR; |
---|
271 | 256 | |
---|
272 | 257 | kgdb_handle_exception(0, SIGTRAP, 0, regs); |
---|
.. | .. |
---|
275 | 260 | NOKPROBE_SYMBOL(kgdb_step_brk_fn); |
---|
276 | 261 | |
---|
277 | 262 | static struct break_hook kgdb_brkpt_hook = { |
---|
278 | | - .esr_mask = 0xffffffff, |
---|
279 | | - .esr_val = (u32)ESR_ELx_VAL_BRK64(KGDB_DYN_DBG_BRK_IMM), |
---|
280 | | - .fn = kgdb_brk_fn |
---|
| 263 | + .fn = kgdb_brk_fn, |
---|
| 264 | + .imm = KGDB_DYN_DBG_BRK_IMM, |
---|
281 | 265 | }; |
---|
282 | 266 | |
---|
283 | 267 | static struct break_hook kgdb_compiled_brkpt_hook = { |
---|
284 | | - .esr_mask = 0xffffffff, |
---|
285 | | - .esr_val = (u32)ESR_ELx_VAL_BRK64(KGDB_COMPILED_DBG_BRK_IMM), |
---|
286 | | - .fn = kgdb_compiled_brk_fn |
---|
| 268 | + .fn = kgdb_compiled_brk_fn, |
---|
| 269 | + .imm = KGDB_COMPILED_DBG_BRK_IMM, |
---|
287 | 270 | }; |
---|
288 | 271 | |
---|
289 | 272 | static struct step_hook kgdb_step_hook = { |
---|
290 | 273 | .fn = kgdb_step_brk_fn |
---|
291 | 274 | }; |
---|
292 | | - |
---|
293 | | -static void kgdb_call_nmi_hook(void *ignored) |
---|
294 | | -{ |
---|
295 | | - kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); |
---|
296 | | -} |
---|
297 | | - |
---|
298 | | -void kgdb_roundup_cpus(unsigned long flags) |
---|
299 | | -{ |
---|
300 | | - local_irq_enable(); |
---|
301 | | - smp_call_function(kgdb_call_nmi_hook, NULL, 0); |
---|
302 | | - local_irq_disable(); |
---|
303 | | -} |
---|
304 | 275 | |
---|
305 | 276 | static int __kgdb_notify(struct die_args *args, unsigned long cmd) |
---|
306 | 277 | { |
---|
.. | .. |
---|
344 | 315 | if (ret != 0) |
---|
345 | 316 | return ret; |
---|
346 | 317 | |
---|
347 | | - register_break_hook(&kgdb_brkpt_hook); |
---|
348 | | - register_break_hook(&kgdb_compiled_brkpt_hook); |
---|
349 | | - register_step_hook(&kgdb_step_hook); |
---|
| 318 | + register_kernel_break_hook(&kgdb_brkpt_hook); |
---|
| 319 | + register_kernel_break_hook(&kgdb_compiled_brkpt_hook); |
---|
| 320 | + register_kernel_step_hook(&kgdb_step_hook); |
---|
350 | 321 | return 0; |
---|
351 | 322 | } |
---|
352 | 323 | |
---|
.. | .. |
---|
357 | 328 | */ |
---|
358 | 329 | void kgdb_arch_exit(void) |
---|
359 | 330 | { |
---|
360 | | - unregister_break_hook(&kgdb_brkpt_hook); |
---|
361 | | - unregister_break_hook(&kgdb_compiled_brkpt_hook); |
---|
362 | | - unregister_step_hook(&kgdb_step_hook); |
---|
| 331 | + unregister_kernel_break_hook(&kgdb_brkpt_hook); |
---|
| 332 | + unregister_kernel_break_hook(&kgdb_compiled_brkpt_hook); |
---|
| 333 | + unregister_kernel_step_hook(&kgdb_step_hook); |
---|
363 | 334 | unregister_die_notifier(&kgdb_notifier); |
---|
364 | 335 | } |
---|
365 | 336 | |
---|
366 | | -struct kgdb_arch arch_kgdb_ops; |
---|
| 337 | +const struct kgdb_arch arch_kgdb_ops; |
---|
367 | 338 | |
---|
368 | 339 | int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) |
---|
369 | 340 | { |
---|