Skip to content

Commit 7043679

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/debug: Remove handle_debug(.user) argument
The handle_debug(.user) argument is used to terminate the #DB handler early for the INT1-from-kernel case, since the kernel doesn't use INT1. Remove the argument and handle this explicitly in #DB-from-kernel. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Daniel Thompson <daniel.thompson@linaro.org> Acked-by: Andy Lutomirski <luto@kernel.org> Link: https://lore.kernel.org/r/20200902133200.907020598@infradead.org
1 parent 20a6e35 commit 7043679

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

arch/x86/kernel/traps.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -783,25 +783,18 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
783783
*
784784
* May run on IST stack.
785785
*/
786-
static void handle_debug(struct pt_regs *regs, unsigned long dr6, bool user)
786+
static void handle_debug(struct pt_regs *regs, unsigned long dr6)
787787
{
788788
struct task_struct *tsk = current;
789789
bool user_icebp;
790790
int si_code;
791791

792-
/*
793-
* If DR6 is zero, no point in trying to handle it. The kernel is
794-
* not using INT1.
795-
*/
796-
if (!user && !dr6)
797-
return;
798-
799792
/*
800793
* If dr6 has no reason to give us about the origin of this trap,
801794
* then it's very likely the result of an icebp/int01 trap.
802795
* User wants a sigtrap for that.
803796
*/
804-
user_icebp = user && !dr6;
797+
user_icebp = !dr6;
805798

806799
/* Store the virtualized DR6 value */
807800
tsk->thread.debugreg6 = dr6;
@@ -874,7 +867,13 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
874867
if (kprobe_debug_handler(regs))
875868
goto out;
876869

877-
handle_debug(regs, dr6, false);
870+
/*
871+
* The kernel doesn't use INT1
872+
*/
873+
if (!dr6)
874+
goto out;
875+
876+
handle_debug(regs, dr6);
878877

879878
out:
880879
instrumentation_end();
@@ -904,7 +903,7 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
904903
irqentry_enter_from_user_mode(regs);
905904
instrumentation_begin();
906905

907-
handle_debug(regs, dr6, true);
906+
handle_debug(regs, dr6);
908907

909908
instrumentation_end();
910909
irqentry_exit_to_user_mode(regs);

0 commit comments

Comments
 (0)