blob: 797317311b36f8c8797460c4ddd51afb4924b276 [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From 766f65096433dde206cdfa19c2cd644be6beaf32 Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:02 +0800
4Subject: [PATCH] [basic-part][999-2001-kgdb-add-interrupt-control.patch]
5
6---
7 arch/arm64/kernel/kgdb.c | 14 ++++++++++++++
8 1 file changed, 14 insertions(+)
9
developerfd40db22021-04-29 10:08:25 +080010diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
developer5d148cb2023-06-02 13:08:11 +080011index 1a157ca33..258fe4b38 100644
developerfd40db22021-04-29 10:08:25 +080012--- a/arch/arm64/kernel/kgdb.c
13+++ b/arch/arm64/kernel/kgdb.c
14@@ -18,6 +18,10 @@
15 #include <asm/debug-monitors.h>
16 #include <asm/insn.h>
17 #include <asm/traps.h>
18+#include <asm/ptrace.h>
19+
20+
21+static DEFINE_PER_CPU(unsigned int, kgdb_pstate);
22
23 struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
24 { "x0", 8, offsetof(struct pt_regs, regs[0])},
25@@ -206,6 +210,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
26 err = 0;
27 break;
28 case 's':
29+ __this_cpu_write(kgdb_pstate, linux_regs->pstate);
30+ linux_regs->pstate |= PSR_I_BIT;
31 /*
32 * Update step address value with address passed
33 * with step packet.
34@@ -249,9 +255,17 @@ NOKPROBE_SYMBOL(kgdb_compiled_brk_fn);
35
36 static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
37 {
38+ unsigned int pstate;
39+
40 if (!kgdb_single_step)
41 return DBG_HOOK_ERROR;
42+ kernel_disable_single_step();
43
44+ pstate = __this_cpu_read(kgdb_pstate);
45+ if (pstate & PSR_I_BIT)
46+ regs->pstate |= PSR_I_BIT;
47+ else
48+ regs->pstate &= ~PSR_I_BIT;
49 kgdb_handle_exception(0, SIGTRAP, 0, regs);
50 return DBG_HOOK_HANDLED;
51 }
developer5d148cb2023-06-02 13:08:11 +080052--
532.34.1
54