| .. | .. |
|---|
| 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> |
|---|
| .. | .. |
|---|
| 244 | 233 | |
|---|
| 245 | 234 | static int kgdb_brk_fn(struct pt_regs *regs, unsigned int esr) |
|---|
| 246 | 235 | { |
|---|
| 247 | | - if (user_mode(regs)) |
|---|
| 248 | | - return DBG_HOOK_ERROR; |
|---|
| 249 | | - |
|---|
| 250 | 236 | kgdb_handle_exception(1, SIGTRAP, 0, regs); |
|---|
| 251 | 237 | return DBG_HOOK_HANDLED; |
|---|
| 252 | 238 | } |
|---|
| .. | .. |
|---|
| 254 | 240 | |
|---|
| 255 | 241 | static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) |
|---|
| 256 | 242 | { |
|---|
| 257 | | - if (user_mode(regs)) |
|---|
| 258 | | - return DBG_HOOK_ERROR; |
|---|
| 259 | | - |
|---|
| 260 | 243 | compiled_break = 1; |
|---|
| 261 | 244 | kgdb_handle_exception(1, SIGTRAP, 0, regs); |
|---|
| 262 | 245 | |
|---|
| .. | .. |
|---|
| 266 | 249 | |
|---|
| 267 | 250 | static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) |
|---|
| 268 | 251 | { |
|---|
| 269 | | - if (user_mode(regs) || !kgdb_single_step) |
|---|
| 252 | + if (!kgdb_single_step) |
|---|
| 270 | 253 | return DBG_HOOK_ERROR; |
|---|
| 271 | 254 | |
|---|
| 272 | 255 | kgdb_handle_exception(0, SIGTRAP, 0, regs); |
|---|
| .. | .. |
|---|
| 275 | 258 | NOKPROBE_SYMBOL(kgdb_step_brk_fn); |
|---|
| 276 | 259 | |
|---|
| 277 | 260 | 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 |
|---|
| 261 | + .fn = kgdb_brk_fn, |
|---|
| 262 | + .imm = KGDB_DYN_DBG_BRK_IMM, |
|---|
| 281 | 263 | }; |
|---|
| 282 | 264 | |
|---|
| 283 | 265 | 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 |
|---|
| 266 | + .fn = kgdb_compiled_brk_fn, |
|---|
| 267 | + .imm = KGDB_COMPILED_DBG_BRK_IMM, |
|---|
| 287 | 268 | }; |
|---|
| 288 | 269 | |
|---|
| 289 | 270 | static struct step_hook kgdb_step_hook = { |
|---|
| 290 | 271 | .fn = kgdb_step_brk_fn |
|---|
| 291 | 272 | }; |
|---|
| 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 | 273 | |
|---|
| 305 | 274 | static int __kgdb_notify(struct die_args *args, unsigned long cmd) |
|---|
| 306 | 275 | { |
|---|
| .. | .. |
|---|
| 344 | 313 | if (ret != 0) |
|---|
| 345 | 314 | return ret; |
|---|
| 346 | 315 | |
|---|
| 347 | | - register_break_hook(&kgdb_brkpt_hook); |
|---|
| 348 | | - register_break_hook(&kgdb_compiled_brkpt_hook); |
|---|
| 349 | | - register_step_hook(&kgdb_step_hook); |
|---|
| 316 | + register_kernel_break_hook(&kgdb_brkpt_hook); |
|---|
| 317 | + register_kernel_break_hook(&kgdb_compiled_brkpt_hook); |
|---|
| 318 | + register_kernel_step_hook(&kgdb_step_hook); |
|---|
| 350 | 319 | return 0; |
|---|
| 351 | 320 | } |
|---|
| 352 | 321 | |
|---|
| .. | .. |
|---|
| 357 | 326 | */ |
|---|
| 358 | 327 | void kgdb_arch_exit(void) |
|---|
| 359 | 328 | { |
|---|
| 360 | | - unregister_break_hook(&kgdb_brkpt_hook); |
|---|
| 361 | | - unregister_break_hook(&kgdb_compiled_brkpt_hook); |
|---|
| 362 | | - unregister_step_hook(&kgdb_step_hook); |
|---|
| 329 | + unregister_kernel_break_hook(&kgdb_brkpt_hook); |
|---|
| 330 | + unregister_kernel_break_hook(&kgdb_compiled_brkpt_hook); |
|---|
| 331 | + unregister_kernel_step_hook(&kgdb_step_hook); |
|---|
| 363 | 332 | unregister_die_notifier(&kgdb_notifier); |
|---|
| 364 | 333 | } |
|---|
| 365 | 334 | |
|---|
| 366 | | -struct kgdb_arch arch_kgdb_ops; |
|---|
| 335 | +const struct kgdb_arch arch_kgdb_ops; |
|---|
| 367 | 336 | |
|---|
| 368 | 337 | int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) |
|---|
| 369 | 338 | { |
|---|