Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fb69640 authored by Pratyush Anand's avatar Pratyush Anand Committed by Catalin Marinas
Browse files

arm64: Handle TRAP_TRACE for user mode as well



uprobe registers a handler at step_hook. So, single_step_handler now
checks for user mode as well if there is a valid hook.

Signed-off-by: default avatarPratyush Anand <panand@redhat.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent b66c9870
Loading
Loading
Loading
Loading
+12 −10
Original line number Original line Diff line number Diff line
@@ -226,6 +226,8 @@ static void send_user_sigtrap(int si_code)
static int single_step_handler(unsigned long addr, unsigned int esr,
static int single_step_handler(unsigned long addr, unsigned int esr,
			       struct pt_regs *regs)
			       struct pt_regs *regs)
{
{
	bool handler_found = false;

	/*
	/*
	 * If we are stepping a pending breakpoint, call the hw_breakpoint
	 * If we are stepping a pending breakpoint, call the hw_breakpoint
	 * handler first.
	 * handler first.
@@ -233,7 +235,14 @@ static int single_step_handler(unsigned long addr, unsigned int esr,
	if (!reinstall_suspended_bps(regs))
	if (!reinstall_suspended_bps(regs))
		return 0;
		return 0;


	if (user_mode(regs)) {
#ifdef	CONFIG_KPROBES
	if (kprobe_single_step_handler(regs, esr) == DBG_HOOK_HANDLED)
		handler_found = true;
#endif
	if (!handler_found && call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
		handler_found = true;

	if (!handler_found && user_mode(regs)) {
		send_user_sigtrap(TRAP_TRACE);
		send_user_sigtrap(TRAP_TRACE);


		/*
		/*
@@ -243,15 +252,8 @@ static int single_step_handler(unsigned long addr, unsigned int esr,
		 * to the active-not-pending state).
		 * to the active-not-pending state).
		 */
		 */
		user_rewind_single_step(current);
		user_rewind_single_step(current);
	} else {
	} else if (!handler_found) {
#ifdef	CONFIG_KPROBES
		pr_warn("Unexpected kernel single-step exception at EL1\n");
		if (kprobe_single_step_handler(regs, esr) == DBG_HOOK_HANDLED)
			return 0;
#endif
		if (call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
			return 0;

		pr_warning("Unexpected kernel single-step exception at EL1\n");
		/*
		/*
		 * Re-enable stepping since we know that we will be
		 * Re-enable stepping since we know that we will be
		 * returning to regs.
		 * returning to regs.