[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1380922788-23112-4-git-send-email-andi@firstfloor.org>
Date: Fri, 4 Oct 2013 14:39:45 -0700
From: Andi Kleen <andi@...stfloor.org>
To: x86@...nel.org
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
Andi Kleen <ak@...ux.intel.com>, fweisbec@...il.com
Subject: [PATCH 3/6] x86, ptrace: Ifdef HW_BREAKPOINTS code in ptrace
From: Andi Kleen <ak@...ux.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@...il.com
Signed-off-by: Andi Kleen <ak@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists