Skip to contentSkip to conversation

HW-BKPT: Allow per-cpu kernel-space Hardware Breakpoint requests

PATCH New K.Prasad 1 participant 1 message Aug 17, 2009 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

K.Prasad

author
#1 lore raw

PATCH 1/1 HW-BKPT: Allow per-cpu kernel-space Hardware Breakpoint requests

In reply to a message not in the archive

Allow kernel-space hw-breakpoints to be restricted only for a subset of CPUs using a cpumask field in 'struct hw_breakpoint'.

---
 arch/x86/include/asm/hw_breakpoint.h |    2 
 arch/x86/kernel/hw_breakpoint.c      |    8 +-
 include/asm-generic/hw_breakpoint.h  |    2 
 kernel/hw_breakpoint.c               |  121 ++++++++++++++++++++++++-----------
 4 files changed, 95 insertions(+), 38 deletions(-)
arch/x86/kernel/hw_breakpoint.c +6 -2
Index: linux-2.6-tip.hbkpt/arch/x86/kernel/hw_breakpoint.c
===================================================================
@@ -68,7 +68,7 @@ static unsigned long encode_dr7(int drnu
 	return bp_info;
 }
 
-void arch_update_kernel_hw_breakpoint(void *unused)
+void arch_update_kernel_hw_breakpoint(void)
 {
 	struct hw_breakpoint *bp;
 	int i, cpu = get_cpu();
@@ -78,7 +78,7 @@ void arch_update_kernel_hw_breakpoint(vo
 	set_debugreg(0UL, 7);
 
 	for (i = hbp_kernel_pos; i < HBP_NUM; i++) {
-		per_cpu(this_hbp_kernel[i], cpu) = bp = hbp_kernel[i];
+		bp = per_cpu(this_hbp_kernel[i], cpu);
 		if (bp) {
 			temp_kdr7 |= encode_dr7(i, bp->info.len, bp->info.type);
 			set_debugreg(bp->info.address, i);
@@ -207,6 +207,10 @@ int arch_validate_hwbkpt_settings(struct
 	unsigned int align;
 	int ret = -EINVAL;
 
+	/* User-space breakpoints cannot be restricted to a subset of CPUs */
+	if (tsk && bp->cpumask)
+		return ret;
+
 	switch (bp->info.type) {
 	/*
 	 * Ptrace-refactoring code
include/asm-generic/hw_breakpoint.h +2 -0
Index: linux-2.6-tip.hbkpt/include/asm-generic/hw_breakpoint.h
===================================================================
@@ -8,6 +8,7 @@
 #ifdef	__KERNEL__
 #include <linux/list.h>
 #include <linux/types.h>
+#include <linux/cpumask.h>
 #include <linux/kallsyms.h>
 
 /**
@@ -102,6 +103,7 @@
  */
 struct hw_breakpoint {
 	void (*triggered)(struct hw_breakpoint *, struct pt_regs *);
+	const cpumask_t *cpumask;
 	struct arch_hw_breakpoint info;
 };
 
kernel/hw_breakpoint.c +86 -35

178 lines not on this page · raw message

arch/x86/include/asm/hw_breakpoint.h +1 -1
Index: linux-2.6-tip.hbkpt/arch/x86/include/asm/hw_breakpoint.h
===================================================================
@@ -47,7 +47,7 @@ extern int arch_validate_hwbkpt_settings
 						struct task_struct *tsk);
 extern void arch_update_user_hw_breakpoint(int pos, struct task_struct *tsk);
 extern void arch_flush_thread_hw_breakpoint(struct task_struct *tsk);
-extern void arch_update_kernel_hw_breakpoint(void *);
+extern void arch_update_kernel_hw_breakpoint(void);
 extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
 				     unsigned long val, void *data);
 #endif	/* __KERNEL__ */