blob: e0ee95490dce84d4e7ca1403838bc3d8691a8b11 [file] [log] [blame]
developerfd40db22021-04-29 10:08:25 +08001diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
2index 1a157ca..258fe4b 100644
3--- a/arch/arm64/kernel/kgdb.c
4+++ b/arch/arm64/kernel/kgdb.c
5@@ -18,6 +18,10 @@
6 #include <asm/debug-monitors.h>
7 #include <asm/insn.h>
8 #include <asm/traps.h>
9+#include <asm/ptrace.h>
10+
11+
12+static DEFINE_PER_CPU(unsigned int, kgdb_pstate);
13
14 struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
15 { "x0", 8, offsetof(struct pt_regs, regs[0])},
16@@ -206,6 +210,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
17 err = 0;
18 break;
19 case 's':
20+ __this_cpu_write(kgdb_pstate, linux_regs->pstate);
21+ linux_regs->pstate |= PSR_I_BIT;
22 /*
23 * Update step address value with address passed
24 * with step packet.
25@@ -249,9 +255,17 @@ NOKPROBE_SYMBOL(kgdb_compiled_brk_fn);
26
27 static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
28 {
29+ unsigned int pstate;
30+
31 if (!kgdb_single_step)
32 return DBG_HOOK_ERROR;
33+ kernel_disable_single_step();
34
35+ pstate = __this_cpu_read(kgdb_pstate);
36+ if (pstate & PSR_I_BIT)
37+ regs->pstate |= PSR_I_BIT;
38+ else
39+ regs->pstate &= ~PSR_I_BIT;
40 kgdb_handle_exception(0, SIGTRAP, 0, regs);
41 return DBG_HOOK_HANDLED;
42 }