hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/arch/arm64/kernel/kgdb.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AArch64 KGDB support
34 *
....@@ -5,18 +6,6 @@
56 *
67 * Copyright (C) 2013 Cavium Inc.
78 * 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/>.
209 */
2110
2211 #include <linux/bug.h>
....@@ -234,6 +223,8 @@
234223 */
235224 if (!kernel_active_single_step())
236225 kernel_enable_single_step(linux_regs);
226
+ else
227
+ kernel_rewind_single_step(linux_regs);
237228 err = 0;
238229 break;
239230 default:
....@@ -244,9 +235,6 @@
244235
245236 static int kgdb_brk_fn(struct pt_regs *regs, unsigned int esr)
246237 {
247
- if (user_mode(regs))
248
- return DBG_HOOK_ERROR;
249
-
250238 kgdb_handle_exception(1, SIGTRAP, 0, regs);
251239 return DBG_HOOK_HANDLED;
252240 }
....@@ -254,9 +242,6 @@
254242
255243 static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr)
256244 {
257
- if (user_mode(regs))
258
- return DBG_HOOK_ERROR;
259
-
260245 compiled_break = 1;
261246 kgdb_handle_exception(1, SIGTRAP, 0, regs);
262247
....@@ -266,7 +251,7 @@
266251
267252 static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
268253 {
269
- if (user_mode(regs) || !kgdb_single_step)
254
+ if (!kgdb_single_step)
270255 return DBG_HOOK_ERROR;
271256
272257 kgdb_handle_exception(0, SIGTRAP, 0, regs);
....@@ -275,32 +260,18 @@
275260 NOKPROBE_SYMBOL(kgdb_step_brk_fn);
276261
277262 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,
281265 };
282266
283267 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,
287270 };
288271
289272 static struct step_hook kgdb_step_hook = {
290273 .fn = kgdb_step_brk_fn
291274 };
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
-}
304275
305276 static int __kgdb_notify(struct die_args *args, unsigned long cmd)
306277 {
....@@ -344,9 +315,9 @@
344315 if (ret != 0)
345316 return ret;
346317
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);
350321 return 0;
351322 }
352323
....@@ -357,13 +328,13 @@
357328 */
358329 void kgdb_arch_exit(void)
359330 {
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);
363334 unregister_die_notifier(&kgdb_notifier);
364335 }
365336
366
-struct kgdb_arch arch_kgdb_ops;
337
+const struct kgdb_arch arch_kgdb_ops;
367338
368339 int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
369340 {