aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2010-06-24 15:21:27 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2010-06-24 17:35:15 -0400
commit0c4519e825c9e2b6a8310deff8582f8c35bfbba9 (patch)
treeed56729d5281b7fec606efd3d617f84d24d18a6c /arch
parent5cfaf214856eb934759ae500a0b812dd06a00bd9 (diff)
x86: Set resume bit before returning from breakpoint exception
Instruction breakpoints trigger before the instruction executes, and returning back from the breakpoint handler brings us again to the instruction that breakpointed. This naturally bring to a breakpoint recursion. To solve this, x86 has the Resume Bit trick. When the cpu flags have the RF flag set, the next instruction won't trigger any instruction breakpoint, and once this instruction is executed, RF is cleared back. This let's us jump back to the instruction that triggered the breakpoint without recursion. Use this when an instruction breakpoint triggers. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Prasad <prasad@linux.vnet.ibm.com> Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/hw_breakpoint.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index a8f1b803d2fd..eaa6ae2a010b 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -466,6 +466,13 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
466 466
467 perf_bp_event(bp, args->regs); 467 perf_bp_event(bp, args->regs);
468 468
469 /*
470 * Set up resume flag to avoid breakpoint recursion when
471 * returning back to origin.
472 */
473 if (bp->hw.info.type == X86_BREAKPOINT_EXECUTE)
474 args->regs->flags |= X86_EFLAGS_RF;
475
469 rcu_read_unlock(); 476 rcu_read_unlock();
470 } 477 }
471 /* 478 /*