[lkml]   [2010]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 1/2] x86: Ignore trap bits on single step exceptions
    When a single step exception fires, the trap bits, used to
    signal hardware breakpoints, are in a random state.

    These trap bits might be set if another exception will follow,
    like a breakpoint in the next instruction, or a watchpoint in the
    previous one. Or there can be any junk there.

    So if we handle these trap bits during the single step exception,
    we are going to handle an exception twice, or we are going to
    handle junk.

    Just ignore them in this case.

    This fixes

    Reported-by: Michael Stefaniuc <>
    Signed-off-by: Frederic Weisbecker <>
    Cc: Rafael J. Wysocki <>
    Cc: Maciej Rutecki <>
    Cc: Alexandre Julliard <>
    Cc: Jason Wessel <>
    Cc: All since 2.6.33.x <>
    arch/x86/kernel/hw_breakpoint.c | 4 ++++
    1 files changed, 4 insertions(+), 0 deletions(-)

    diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
    index ff15c9d..42c5942 100644
    --- a/arch/x86/kernel/hw_breakpoint.c
    +++ b/arch/x86/kernel/hw_breakpoint.c
    @@ -433,6 +433,10 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
    dr6_p = (unsigned long *)ERR_PTR(args->err);
    dr6 = *dr6_p;

    + /* If it's a single step, TRAP bits are random */
    + if (dr6 & DR_STEP)
    + return NOTIFY_DONE;
    /* Do an early return if no trap bits are set in DR6 */
    if ((dr6 & DR_TRAP_BITS) == 0)
    return NOTIFY_DONE;

     \ /
      Last update: 2010-11-13 22:41    [W:0.020 / U:8.004 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site