Skip to contentSkip to conversation

S390-HWBKPT v5: S390 architecture specific Hardware

PATCH In review Mahesh Salgaonkar 1 participant 1 message May 27, 2010 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 S390-HWBKPT v5: S390 architecture specific Hardware

Introduce s390 specific implementation for the perf-events based hardware breakpoint interfaces defined in kernel/hw_breakpoint.c. Enable the HAVE_HW_BREAKPOINT flag and the Makefile.

Change:
- Use exclude_kernel attribute set to decide whether to install wide breakpoint in kernel or not. This flag will be used by ptrace breakpoint.
- Removed 'info->name' field as Name to address resolving is done in generic code.
- Select CONFIG_HAVE_MIXED_BREAKPOINTS_REGS as s390 uses same register for instruction as well as data breakpoint.

---

 arch/s390/Kconfig                       |    2 
 arch/s390/include/asm/Kbuild            |    1 
 arch/s390/include/asm/hw_breakpoint.h   |   64 ++++++
 arch/s390/include/asm/processor.h       |    6 +
 arch/s390/kernel/Makefile               |    2 
 arch/s390/kernel/hw_breakpoint.c        |  312 +++++++++++++++++++++++++++++++
 samples/hw_breakpoint/data_breakpoint.c |    2 
 7 files changed, 387 insertions(+), 2 deletions(-)
 create mode 100644 arch/s390/include/asm/hw_breakpoint.h
 create mode 100644 arch/s390/kernel/hw_breakpoint.c
arch/s390/Kconfig +2 -0
index 0d8cd9b..83abf4f 100644
@@ -130,6 +130,8 @@ config S390
 	select ARCH_INLINE_WRITE_UNLOCK_BH
 	select ARCH_INLINE_WRITE_UNLOCK_IRQ
 	select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
+	select HAVE_HW_BREAKPOINT
+	select HAVE_MIXED_BREAKPOINTS_REGS
 
 config SCHED_OMIT_FRAME_POINTER
 	bool
arch/s390/include/asm/Kbuild +1 -0
index 63a2341..a80fcdb 100644
@@ -8,6 +8,7 @@ header-y += ucontext.h
 header-y += vtoc.h
 header-y += zcrypt.h
 header-y += chsc.h
+header-y += hw_breakpoint.h
 
 unifdef-y += cmb.h
 unifdef-y += debug.h
arch/s390/include/asm/hw_breakpoint.h new file +64 -0

64 lines not on this page · raw message

arch/s390/include/asm/processor.h +6 -0
index 73e2598..f9e5bf5 100644
@@ -25,6 +25,8 @@
  * instruction pointer ("program counter").
  */
 #define current_text_addr() ({ void *pc; asm("basr %0,0" : "=a" (pc)); pc; })
+/* Total number of available HW breakpoint registers */
+#define HBP_NUM	1
 
 static inline void get_cpu_id(struct cpuid *ptr)
 {
@@ -71,6 +73,8 @@ typedef struct {
         __u32 ar4;
 } mm_segment_t;
 
+struct perf_event;
+
 /*
  * Thread structure
  */
@@ -86,6 +90,8 @@ struct thread_struct {
 	unsigned long ieee_instruction_pointer; 
         /* pfault_wait is used to block the process on a pfault event */
 	unsigned long pfault_wait;
+	/* Save middle states of ptrace breakpoints */
+	struct perf_event *ptrace_bps[HBP_NUM];
 };
 
 typedef struct thread_struct thread_struct;
arch/s390/kernel/Makefile +1 -1
index 64230bc..8625e46 100644
@@ -23,7 +23,7 @@ CFLAGS_sysinfo.o += -Iinclude/math-emu -Iarch/s390/math-emu -w
 obj-y	:=  bitmap.o traps.o time.o process.o base.o early.o setup.o \
 	    processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \
 	    s390_ext.o debug.o irq.o ipl.o dis.o diag.o mem_detect.o \
-	    vdso.o vtime.o sysinfo.o nmi.o sclp.o
+	    vdso.o vtime.o sysinfo.o nmi.o sclp.o hw_breakpoint.o
 
 obj-y	+= $(if $(CONFIG_64BIT),entry64.o,entry.o)
 obj-y	+= $(if $(CONFIG_64BIT),reipl64.o,reipl.o)
arch/s390/kernel/hw_breakpoint.c new file +312 -0

312 lines not on this page · raw message

samples/hw_breakpoint/data_breakpoint.c +1 -1
index bd0f337..5a29bb1 100644
@@ -58,7 +58,7 @@ static int __init hw_break_module_init(void)
 	hw_breakpoint_init(&attr);
 	attr.bp_addr = kallsyms_lookup_name(ksym_name);
 	attr.bp_len = HW_BREAKPOINT_LEN_4;
-	attr.bp_type = HW_BREAKPOINT_W | HW_BREAKPOINT_R;
+	attr.bp_type = HW_BREAKPOINT_W;
 
 	sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler);
 	if (IS_ERR((void __force *)sample_hbp)) {