lkml.org 
[lkml]   [2013]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/6] x86, ptrace: Ifdef HW_BREAKPOINTS code in ptrace
    Date
    From: Andi Kleen <ak@linux.intel.com>

    Add ifdefs on CONFIG_HW_BREAKPOINTS to the hardware
    break point code in x86 ptrace.c. This prepares
    this file for being able to disable HW_BREAKPOINTS.

    The only debug register that needs to be handled
    without break points is DR6, so do that in a simple
    separate function without breakpoints.

    Cc: fweisbec@gmail.com
    Signed-off-by: Andi Kleen <ak@linux.intel.com>
    ---
    arch/x86/kernel/ptrace.c | 30 ++++++++++++++++++++++++++++++
    1 file changed, 30 insertions(+)

    diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
    index 7461f50..dda433f 100644
    --- a/arch/x86/kernel/ptrace.c
    +++ b/arch/x86/kernel/ptrace.c
    @@ -561,6 +561,8 @@ static int genregs_set(struct task_struct *target,
    return ret;
    }

    +#ifdef CONFIG_HW_BREAKPOINTS
    +
    static void ptrace_triggered(struct perf_event *bp,
    struct perf_sample_data *data,
    struct pt_regs *regs)
    @@ -778,6 +780,34 @@ static int ptrace_set_debugreg(struct task_struct *tsk, int n,
    return rc;
    }

    +#else
    +
    +/* Without breakpoints only handle DR6 */
    +static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
    +{
    + struct thread_struct *thread = &tsk->thread;
    +
    + if (n == 6)
    + return thread->debugreg6;
    + return 0;
    +}
    +
    +/* Without breakpoints only handle DR6 */
    +static int ptrace_set_debugreg(struct task_struct *tsk, int n,
    + unsigned long val)
    +{
    + struct thread_struct *thread = &tsk->thread;
    + int rc = -EIO;
    +
    + if (n == 6) {
    + thread->debugreg6 = val;
    + rc = 0;
    + }
    + return rc;
    +}
    +
    +#endif
    +
    /*
    * These access the current or another (stopped) task's io permission
    * bitmap for debugging or core dump.
    --
    1.8.3.1


    \
     
     \ /
      Last update: 2013-10-05 00:01    [W:4.204 / U:0.544 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site