blob: 797317311b36f8c8797460c4ddd51afb4924b276 [file] [log] [blame]
From 766f65096433dde206cdfa19c2cd644be6beaf32 Mon Sep 17 00:00:00 2001
From: Sam Shih <sam.shih@mediatek.com>
Date: Fri, 2 Jun 2023 13:06:02 +0800
Subject: [PATCH] [basic-part][999-2001-kgdb-add-interrupt-control.patch]
---
arch/arm64/kernel/kgdb.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
index 1a157ca33..258fe4b38 100644
--- a/arch/arm64/kernel/kgdb.c
+++ b/arch/arm64/kernel/kgdb.c
@@ -18,6 +18,10 @@
#include <asm/debug-monitors.h>
#include <asm/insn.h>
#include <asm/traps.h>
+#include <asm/ptrace.h>
+
+
+static DEFINE_PER_CPU(unsigned int, kgdb_pstate);
struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
{ "x0", 8, offsetof(struct pt_regs, regs[0])},
@@ -206,6 +210,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
err = 0;
break;
case 's':
+ __this_cpu_write(kgdb_pstate, linux_regs->pstate);
+ linux_regs->pstate |= PSR_I_BIT;
/*
* Update step address value with address passed
* with step packet.
@@ -249,9 +255,17 @@ NOKPROBE_SYMBOL(kgdb_compiled_brk_fn);
static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
{
+ unsigned int pstate;
+
if (!kgdb_single_step)
return DBG_HOOK_ERROR;
+ kernel_disable_single_step();
+ pstate = __this_cpu_read(kgdb_pstate);
+ if (pstate & PSR_I_BIT)
+ regs->pstate |= PSR_I_BIT;
+ else
+ regs->pstate &= ~PSR_I_BIT;
kgdb_handle_exception(0, SIGTRAP, 0, regs);
return DBG_HOOK_HANDLED;
}
--
2.34.1