Skip to contentSkip to conversation

PPC64-HWBKPT: Disable interrupts for data breakpoint exceptions

RFC PATCH In review K.Prasad 4 participants 10 messages Mar 23, 2010 – Mar 30, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

K.Prasad

author
#1 lore raw

RFC PATCH 1/2 PPC64-HWBKPT: Disable interrupts for data breakpoint exceptions

In reply to a message not in the archive

Data address breakpoint exceptions are currently handled along with page-faults which require interrupts to remain in enabled state. Since exception handling for data breakpoints aren't pre-empt safe, we handle them separately.

---
 arch/powerpc/kernel/exceptions-64s.S |   12 ++++++++++++
 arch/powerpc/mm/fault.c              |    2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
arch/powerpc/kernel/exceptions-64s.S +12 -0
Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
===================================================================
@@ -735,6 +735,9 @@ _STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
+	andis.  r0,r4,0x0040		/* Data Address Breakpoint match? */
+	bne-    handle_dabr_fault
+
 	andis.	r0,r4,0xa450		/* weird error? */
 	bne-	handle_page_fault	/* if not, try to insert a HPTE */
 BEGIN_FTR_SECTION
@@ -823,6 +826,15 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER
 	bl	.raw_local_irq_restore
 	b	11f
 
+/* We have a data breakpoint exception - handle it */
+handle_dabr_fault:
+	/* Populate the pt_regs structure */
+	ld      r4,_DAR(r1)
+	ld      r5,_DSISR(r1)
+	addi    r3,r1,STACK_FRAME_OVERHEAD
+	bl      .do_dabr
+	b       .ret_from_except_lite
+
 /* Here we have a page fault that hash_page can't handle. */
 handle_page_fault:
 	ENABLE_INTS
arch/powerpc/mm/fault.c +1 -1
Index: linux-2.6.ppc64_test/arch/powerpc/mm/fault.c
===================================================================
@@ -151,7 +151,7 @@ int __kprobes do_page_fault(struct pt_re
 	if (!user_mode(regs) && (address >= TASK_SIZE))
 		return SIGSEGV;
 
-#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
+#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE) || defined(CONFIG_PPC64))
   	if (error_code & DSISR_DABRMATCH) {
 		/* DABR match */
 		do_dabr(regs, address, error_code);
author
#6 lore raw

RFC PATCH 2/2 PPC64-HWBKPT: Implement hw-breakpoints for PPC64

In reply to a message not in the archive

Implement perf-events based hw-breakpoint interfaces for PPC64 processors. These interfaces help arbitrate requests from various users and schedules them as appropriate.

---
 arch/powerpc/Kconfig                     |    1 
 arch/powerpc/include/asm/cputable.h      |    7 
 arch/powerpc/include/asm/hw_breakpoint.h |   50 ++++
 arch/powerpc/include/asm/processor.h     |    6 
 arch/powerpc/kernel/Makefile             |    3 
 arch/powerpc/kernel/hw_breakpoint.c      |  324 +++++++++++++++++++++++++++++++
 arch/powerpc/kernel/process.c            |    3 
 arch/powerpc/kernel/ptrace.c             |   79 +++++++
 8 files changed, 473 insertions(+)
arch/powerpc/include/asm/hw_breakpoint.h new file +50 -0
Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/hw_breakpoint.h
===================================================================
@@ -0,0 +1,50 @@
+#ifndef	_PPC64_HW_BREAKPOINT_H
+#define	_PPC64_HW_BREAKPOINT_H
+
+#ifdef	__KERNEL__
+#define	__ARCH_HW_BREAKPOINT_H
+#ifdef CPU_FTR_HAS_DABR
+
+struct arch_hw_breakpoint {
+	u8		len; /* length of the target data symbol */
+	int		type;
+	unsigned long	address;
+};
+
+#include <linux/kdebug.h>
+#include <asm/reg.h>
+#include <asm/system.h>
+
+struct perf_event;
+struct pmu;
+struct perf_sample_data;
+
+#define HW_BREAKPOINT_ALIGN 0x7
+/* Maximum permissible length of any HW Breakpoint */
+#define HW_BREAKPOINT_LEN 0x8
+
+extern int arch_validate_hwbkpt_settings(struct perf_event *bp,
+						struct task_struct *tsk);
+extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
+						unsigned long val, void *data);
+int arch_install_hw_breakpoint(struct perf_event *bp);
+void arch_uninstall_hw_breakpoint(struct perf_event *bp);
+void hw_breakpoint_pmu_read(struct perf_event *bp);
+extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
+
+extern struct pmu perf_ops_bp;
+extern void ptrace_triggered(struct perf_event *bp, int nmi,
+			struct perf_sample_data *data, struct pt_regs *regs);
+static inline void hw_breakpoint_disable(void)
+{
+	set_dabr(0);
+}
+
+#else
+static inline void hw_breakpoint_disable(void)
+{
+	/* Function is defined only on PPC64 for now */
+}
+#endif	/* CPU_FTR_HAS_DABR */
+#endif	/* __KERNEL__ */
+#endif	/* _PPC64_HW_BREAKPOINT_H */
arch/powerpc/kernel/hw_breakpoint.c new file +324 -0

324 lines not on this page · raw message

arch/powerpc/Kconfig +1 -0
Index: linux-2.6.ppc64_test/arch/powerpc/Kconfig
===================================================================
@@ -140,6 +140,7 @@ config PPC
 	select HAVE_SYSCALL_WRAPPERS if PPC64
 	select GENERIC_ATOMIC64 if PPC32
 	select HAVE_PERF_EVENTS
+	select HAVE_HW_BREAKPOINT if PPC64 && !PPC_ADV_DEBUG_REGS
 
 config EARLY_PRINTK
 	bool
arch/powerpc/kernel/Makefile +3 -0
Index: linux-2.6.ppc64_test/arch/powerpc/kernel/Makefile
===================================================================
@@ -34,6 +34,9 @@ obj-y				+= vdso32/
 obj-$(CONFIG_PPC64)		+= setup_64.o sys_ppc32.o \
 				   signal_64.o ptrace32.o \
 				   paca.o nvram_64.o firmware.o
+ifneq ($(CONFIG_PPC_ADV_DEBUG_REGS),y)
+obj-$(CONFIG_PPC64)		+= hw_breakpoint.o
+endif
 obj-$(CONFIG_PPC_BOOK3S_64)	+= cpu_setup_ppc970.o cpu_setup_pa6t.o
 obj64-$(CONFIG_RELOCATABLE)	+= reloc_64.o
 obj-$(CONFIG_PPC_BOOK3E_64)	+= exceptions-64e.o
arch/powerpc/include/asm/processor.h +6 -0
Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/processor.h
===================================================================
@@ -209,6 +209,12 @@ struct thread_struct {
 #ifdef CONFIG_PPC64
 	unsigned long	start_tb;	/* Start purr when proc switched in */
 	unsigned long	accum_tb;	/* Total accumilated purr for process */
+	struct perf_event *ptrace_bps[HBP_NUM];
+	/*
+	 * Helps identify source of single-step exception and subsequent
+	 * hw-breakpoint enablement
+	 */
+	struct perf_event *last_hit_ubp;
 #endif
 	unsigned long	dabr;		/* Data address breakpoint register */
 #ifdef CONFIG_ALTIVEC
arch/powerpc/kernel/ptrace.c +79 -0

100 lines not on this page · raw message

arch/powerpc/kernel/process.c +3 -0
Index: linux-2.6.ppc64_test/arch/powerpc/kernel/process.c
===================================================================
@@ -459,8 +459,11 @@ struct task_struct *__switch_to(struct t
 #ifdef CONFIG_PPC_ADV_DEBUG_REGS
 	switch_booke_debug_regs(&new->thread);
 #else
+/* For PPC64, we use the hw-breakpoint interfaces that would schedule DABR */
+#ifndef CONFIG_PPC64
 	if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr))
 		set_dabr(new->thread.dabr);
+#endif /* CONFIG_PPC64 */
 #endif
 
 
arch/powerpc/include/asm/cputable.h +7 -0
Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/cputable.h
===================================================================
@@ -511,6 +511,13 @@ static inline int cpu_has_feature(unsign
 		& feature);
 }
 
+#define CPU_FTR_HAS_DABR (defined(CONFIG_PPC64) && \
+			  !defined(CONFIG_PPC_ADV_DEBUG_REGS))
+#ifdef CPU_FTR_HAS_DABR
+/* Number of physical HW breakpoint registers */
+#define HBP_NUM 1
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
#7 lore raw

Re: [RFC Patch 2/2] PPC64-HWBKPT: Implement hw-breakpoints for PPC64

Quoted 6 lines · K.Prasad

plain text document attachment (ppc64_hbkpt_02)
Implement perf-events based hw-breakpoint interfaces for PPC64 processors. These interfaces help arbitrate requests from various users and schedules them as appropriate.

SNIP

Quoted 8 lines

Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/cputable.h
===================================================================

arch/powerpc/include/asm/cputable.h +0 -0
@@ -511,6 +511,13 @@ static inline int cpu_has_feature(unsign
 		& feature);
 }
 

arch/powerpc/include/asm/cputable.h static inline int cpu_has_feature(unsign · line 523

Quoted 10 lines
arch/powerpc/include/asm/cputable.h +7 -0
+#define CPU_FTR_HAS_DABR (defined(CONFIG_PPC64) && \
+			  !defined(CONFIG_PPC_ADV_DEBUG_REGS))
+#ifdef CPU_FTR_HAS_DABR
+/* Number of physical HW breakpoint registers */
+#define HBP_NUM 1
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */

These new defines don't really correlate to the cpu table. One would expect cpu_has_feature(CPU_FTR_HAS_DABR) to have meaning, but it would have to be defined similar to the other CPU_FTR_ constants, and or-ed with CPU_FTRS_ALWAYS (when appropriate).

Similarly, I would expect the cpu_spec structure to have a new field, hbp_num, which is initialized in cputable.c. Maybe a longer name would be better, num_hw_brkpts?

When I added the PPC_ADV_DEBUG config options for the bookE features, I didn't see an immediate need to clutter the cputable since their values are fixed at compile time. We should be consistent with these, but unless we are going to determine any of these at run-time, I don't know that they belong in the cpu table.

Thanks,
Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
author
#8 lore raw

Re: [RFC Patch 2/2] PPC64-HWBKPT: Implement hw-breakpoints for PPC64

Quoted 27 lines · Dave Kleikamp
Quoted 6 lines · K.Prasad

plain text document attachment (ppc64_hbkpt_02)
Implement perf-events based hw-breakpoint interfaces for PPC64 processors. These interfaces help arbitrate requests from various users and schedules them as appropriate.

SNIP

Quoted 17 lines

Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/cputable.h
===================================================================

arch/powerpc/include/asm/cputable.h +7 -0
@@ -511,6 +511,13 @@ static inline int cpu_has_feature(unsign
 		& feature);
 }
 
+#define CPU_FTR_HAS_DABR (defined(CONFIG_PPC64) && \
+			  !defined(CONFIG_PPC_ADV_DEBUG_REGS))
+#ifdef CPU_FTR_HAS_DABR
+/* Number of physical HW breakpoint registers */
+#define HBP_NUM 1
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
Quoted 7 lines

arch/powerpc/include/asm/cputable.h static inline int cpu_has_feature(unsign · line 523

Quoted 1 line
arch/powerpc/include/asm/cputable.h +0 -0
 #endif /* __KERNEL__ */

These new defines don't really correlate to the cpu table. One would expect cpu_has_feature(CPU_FTR_HAS_DABR) to have meaning, but it would have to be defined similar to the other CPU_FTR_ constants, and or-ed with CPU_FTRS_ALWAYS (when appropriate).

The code can be changed as below:

#if (defined(CONFIG_PPC64) && !defined(CONFIG_PPC_ADV_DEBUG_REGS)) #define CPU_FTR_HAS_DABR 1
/* Number of physical HW breakpoint registers */ #define HBP_NUM 1
#endif

However, a config option CONFIG_PPC_BOOK3S_64 (I just found) whose scope includes only 64-bit server processors (having one DABR) to be the most suitable.

I think it must be used in lieu of introducing a new CPU_FTR_HAS_DABR definition in cputable.h

Quoted 4 lines

Similarly, I would expect the cpu_spec structure to have a new field, hbp_num, which is initialized in cputable.c. Maybe a longer name would be better, num_hw_brkpts?

There are a few issues with such an approach:
i) Two such fields would be required in 'struct cpu_spec' - one for instruction breakpoints and other for data.
ii) As pointed out by you below, hbp_num or num_hw_brkpts would always be assigned to the compile time constant HBP_NUM (hence a variable is not required to store it).
iii) HBP_NUM still cannot be entirely removed as it is used by generic kernel/hw_breakpoint.c code (and is used by x86 code as well).

I think the simplest approach would be to have the following entry in cputable.h (and get away with the rest of the additions seen in patch ver XV)

#ifdef CONFIG_PPC_BOOK3S_64
#define HBP_NUM 1
#endif

The next version of the patch should contain changes to that effect (assuming I hear no objections).

Quoted 3 lines

When I added the PPC_ADV_DEBUG config options for the bookE features, I didn't see an immediate need to clutter the cputable since their values are fixed at compile time. We should be consistent with these, but

It is even more true with ppc64-server processors, where the number of debug registers (denoted by HBP_NUM) is fixed to 1 (unlike BookE where the DACs can be used in standalone or as a pair of registers).

Quoted 6 lines

unless we are going to determine any of these at run-time, I don't know that they belong in the cpu table.

Thanks,
Shaggy

Thanks,
K.Prasad

#9 lore raw

Re: [RFC Patch 2/2] PPC64-HWBKPT: Implement hw-breakpoints for PPC64

Quoted 70 lines · K.Prasad
Quoted 27 lines · Dave Kleikamp
Quoted 6 lines · K.Prasad

plain text document attachment (ppc64_hbkpt_02)
Implement perf-events based hw-breakpoint interfaces for PPC64 processors. These interfaces help arbitrate requests from various users and schedules them as appropriate.

SNIP

Quoted 17 lines

Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/cputable.h
===================================================================

arch/powerpc/include/asm/cputable.h +7 -0
@@ -511,6 +511,13 @@ static inline int cpu_has_feature(unsign
 		& feature);
 }
 
+#define CPU_FTR_HAS_DABR (defined(CONFIG_PPC64) && \
+			  !defined(CONFIG_PPC_ADV_DEBUG_REGS))
+#ifdef CPU_FTR_HAS_DABR
+/* Number of physical HW breakpoint registers */
+#define HBP_NUM 1
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
Quoted 7 lines

arch/powerpc/include/asm/cputable.h static inline int cpu_has_feature(unsign · line 523

Quoted 1 line
arch/powerpc/include/asm/cputable.h +0 -0
 #endif /* __KERNEL__ */

These new defines don't really correlate to the cpu table. One would expect cpu_has_feature(CPU_FTR_HAS_DABR) to have meaning, but it would have to be defined similar to the other CPU_FTR_ constants, and or-ed with CPU_FTRS_ALWAYS (when appropriate).

The code can be changed as below:

#if (defined(CONFIG_PPC64) && !defined(CONFIG_PPC_ADV_DEBUG_REGS)) #define CPU_FTR_HAS_DABR 1
/* Number of physical HW breakpoint registers */ #define HBP_NUM 1
#endif

However, a config option CONFIG_PPC_BOOK3S_64 (I just found) whose scope includes only 64-bit server processors (having one DABR) to be the most suitable.

I think it must be used in lieu of introducing a new CPU_FTR_HAS_DABR definition in cputable.h

Quoted 4 lines

Similarly, I would expect the cpu_spec structure to have a new field, hbp_num, which is initialized in cputable.c. Maybe a longer name would be better, num_hw_brkpts?

There are a few issues with such an approach:
i) Two such fields would be required in 'struct cpu_spec' - one for instruction breakpoints and other for data.
ii) As pointed out by you below, hbp_num or num_hw_brkpts would always be assigned to the compile time constant HBP_NUM (hence a variable is not required to store it).
iii) HBP_NUM still cannot be entirely removed as it is used by generic kernel/hw_breakpoint.c code (and is used by x86 code as well).

I think the simplest approach would be to have the following entry in cputable.h (and get away with the rest of the additions seen in patch ver XV)

Quoted 6 lines

#ifdef CONFIG_PPC_BOOK3S_64
#define HBP_NUM 1
#endif

The next version of the patch should contain changes to that effect (assuming I hear no objections).

I just don't think this belongs in cputable.h. Why not put this in hw_breakpoint.h?

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#2 lore raw
In reply to K.Prasad

arch/powerpc/kernel/exceptions-64s.S _STATIC(do_hash_page) · line 738

Quoted 9 lines · K.Prasad

Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
===================================================================

arch/powerpc/kernel/exceptions-64s.S +1 -0
@@ -735,6 +735,9 @@ _STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
+	andis.  r0,r4,0x0040		/* Data Address Breakpoint match? */

Minor comment: why not DSISR_DABRMATCH@h instead of 0x0040?

arch/powerpc/kernel/exceptions-64s.S END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER · line 831

Quoted 12 lines
arch/powerpc/kernel/exceptions-64s.S +5 -0
+	bne-    handle_dabr_fault
+
 	andis.	r0,r4,0xa450		/* weird error? */
 	bne-	handle_page_fault	/* if not, try to insert a HPTE */
 BEGIN_FTR_SECTION
@@ -823,6 +826,15 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER
 	bl	.raw_local_irq_restore
 	b	11f
 
+/* We have a data breakpoint exception - handle it */
+handle_dabr_fault:
+	/* Populate the pt_regs structure */

Another minor comment: that comment isn't accurate since you're not putting anything in the pt_regs, just getting arguments to do_dabr from it.

Quoted 14 lines
arch/powerpc/kernel/exceptions-64s.S +6 -0
+	ld      r4,_DAR(r1)
+	ld      r5,_DSISR(r1)
+	addi    r3,r1,STACK_FRAME_OVERHEAD
+	bl      .do_dabr
+	b       .ret_from_except_lite
+
 /* Here we have a page fault that hash_page can't handle. */
 handle_page_fault:
 	ENABLE_INTS

Index: linux-2.6.ppc64_test/arch/powerpc/mm/fault.c
===================================================================

arch/powerpc/mm/fault.c int __kprobes do_page_fault(struct pt_re · line 154

Quoted 5 lines
arch/powerpc/mm/fault.c +1 -1
@@ -151,7 +151,7 @@ int __kprobes do_page_fault(struct pt_re
 	if (!user_mode(regs) && (address >= TASK_SIZE))
 		return SIGSEGV;
 
-#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
+#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE) || defined(CONFIG_PPC64))

If we added similar code to head_32.S, we could probably remove this whole ifdef block. But that can be done in a later patch.

Paul.

#3 lore raw
Quoted 14 lines · Paul Mackerras

arch/powerpc/kernel/exceptions-64s.S _STATIC(do_hash_page) · line 738

Quoted 9 lines · K.Prasad

Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
===================================================================

arch/powerpc/kernel/exceptions-64s.S +1 -0
@@ -735,6 +735,9 @@ _STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
+	andis.  r0,r4,0x0040		/* Data Address Breakpoint match? */

Minor comment: why not DSISR_DABRMATCH@h instead of 0x0040?

Quoted 8 lines

arch/powerpc/kernel/exceptions-64s.S END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER · line 827

Quoted 8 lines
arch/powerpc/kernel/exceptions-64s.S +2 -0
+	bne-    handle_dabr_fault
+
 	andis.	r0,r4,0xa450		/* weird error? */
 	bne-	handle_page_fault	/* if not, try to insert a HPTE */
 BEGIN_FTR_SECTION
@@ -823,6 +826,15 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER
 	bl	.raw_local_irq_restore
 	b	11f

I would move your new test to the "weird error" case (ie, after the bne- handle_page_fault) to avoid hitting the fast path.

Cheers,
Ben.

author
#10 lore raw

Re: [RFC Patch 2/2] PPC64-HWBKPT: Implement hw-breakpoints for PPC64

In reply to Dave Kleikamp
Quoted 37 lines · Dave Kleikamp
Quoted 36 lines · K.Prasad
Quoted 34 lines · Dave Kleikamp
Quoted 6 lines · K.Prasad

plain text document attachment (ppc64_hbkpt_02)
Implement perf-events based hw-breakpoint interfaces for PPC64 processors. These interfaces help arbitrate requests from various users and schedules them as appropriate.

SNIP

Quoted 8 lines

Index: linux-2.6.ppc64_test/arch/powerpc/include/asm/cputable.h
===================================================================

arch/powerpc/include/asm/cputable.h +0 -0
@@ -511,6 +511,13 @@ static inline int cpu_has_feature(unsign
 		& feature);
 }
 

arch/powerpc/include/asm/cputable.h static inline int cpu_has_feature(unsign · line 523

Quoted 10 lines
arch/powerpc/include/asm/cputable.h +7 -0
+#define CPU_FTR_HAS_DABR (defined(CONFIG_PPC64) && \
+			  !defined(CONFIG_PPC_ADV_DEBUG_REGS))
+#ifdef CPU_FTR_HAS_DABR
+/* Number of physical HW breakpoint registers */
+#define HBP_NUM 1
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */

These new defines don't really correlate to the cpu table. One would expect cpu_has_feature(CPU_FTR_HAS_DABR) to have meaning, but it would have to be defined similar to the other CPU_FTR_ constants, and or-ed with CPU_FTRS_ALWAYS (when appropriate).

[snipped]

Quoted 17 lines
Quoted 17 lines

There are a few issues with such an approach:
i) Two such fields would be required in 'struct cpu_spec' - one for instruction breakpoints and other for data.
ii) As pointed out by you below, hbp_num or num_hw_brkpts would always be assigned to the compile time constant HBP_NUM (hence a variable is not required to store it).
iii) HBP_NUM still cannot be entirely removed as it is used by generic kernel/hw_breakpoint.c code (and is used by x86 code as well).

I think the simplest approach would be to have the following entry in cputable.h (and get away with the rest of the additions seen in patch ver XV)

#ifdef CONFIG_PPC_BOOK3S_64
#define HBP_NUM 1
#endif

Quoted 6 lines
Quoted 2 lines

The next version of the patch should contain changes to that effect (assuming I hear no objections).

I just don't think this belongs in cputable.h. Why not put this in hw_breakpoint.h?

HBP_NUM was originally defined in hw_breakpoint.h (until ver XIV) but was moved to cputable.h as it introduces a duplicate definition in processor.h (which is how it is done in the x86 implementation). linux/hw_breakpoint.h inclusion in processor.h, to circumvent the duplication leads to circular dependancies w.r.t. declarations.

I think leaving it in cputable.h (as in version XVI of the patch sent
here: message-id:[email protected]) gives us a much cleaner implementation (than x86 which has duplicate HBP_NUM definitions).

Thanks,
K.Prasad

author
#5 lore raw
In reply to Paul Mackerras
Quoted 10 lines · Paul Mackerras
Quoted 8 lines · K.Prasad

Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
===================================================================

arch/powerpc/kernel/exceptions-64s.S +0 -0
@@ -735,6 +735,9 @@ _STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
Quoted 4 lines

arch/powerpc/kernel/exceptions-64s.S _STATIC(do_hash_page) · line 738

Quoted 1 line
arch/powerpc/kernel/exceptions-64s.S +1 -0
+	andis.  r0,r4,0x0040		/* Data Address Breakpoint match? */

Minor comment: why not DSISR_DABRMATCH@h instead of 0x0040?

Sure...I didn't realise that the upper 16-bits could be extracted as shown above....I've implemented the suggestion in the next version of the patch sent here:
linuxppc-dev message-id:[email protected].

Quoted 9 lines
Quoted 9 lines
arch/powerpc/kernel/exceptions-64s.S +2 -0
+	bne-    handle_dabr_fault
+
 	andis.	r0,r4,0xa450		/* weird error? */
 	bne-	handle_page_fault	/* if not, try to insert a HPTE */
 BEGIN_FTR_SECTION
@@ -823,6 +826,15 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER
 	bl	.raw_local_irq_restore
 	b	11f
 
Quoted 8 lines

arch/powerpc/kernel/exceptions-64s.S END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER · line 831

Quoted 3 lines
arch/powerpc/kernel/exceptions-64s.S +3 -0
+/* We have a data breakpoint exception - handle it */
+handle_dabr_fault:
+	/* Populate the pt_regs structure */

Another minor comment: that comment isn't accurate since you're not putting anything in the pt_regs, just getting arguments to do_dabr from it.

Thanks for pointing it out...it has been removed.

Thanks,
K.Prasad

author
#4 lore raw
In reply to Benjamin Herrenschmidt
Quoted 15 lines · Benjamin Herrenschmidt
Quoted 14 lines · Paul Mackerras

arch/powerpc/kernel/exceptions-64s.S _STATIC(do_hash_page) · line 738

Quoted 9 lines · K.Prasad

Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
===================================================================

arch/powerpc/kernel/exceptions-64s.S +1 -0
@@ -735,6 +735,9 @@ _STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
+	andis.  r0,r4,0x0040		/* Data Address Breakpoint match? */

Minor comment: why not DSISR_DABRMATCH@h instead of 0x0040?

Quoted 12 lines
Quoted 8 lines

arch/powerpc/kernel/exceptions-64s.S END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER · line 827

Quoted 8 lines
arch/powerpc/kernel/exceptions-64s.S +2 -0
+	bne-    handle_dabr_fault
+
 	andis.	r0,r4,0xa450		/* weird error? */
 	bne-	handle_page_fault	/* if not, try to insert a HPTE */
 BEGIN_FTR_SECTION
@@ -823,6 +826,15 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISER
 	bl	.raw_local_irq_restore
 	b	11f

I would move your new test to the "weird error" case (ie, after the bne- handle_page_fault) to avoid hitting the fast path.

Done that...so basically the branch to handle_page_fault will happen only if 0xa410 matches.

The changes can be seen here: linuxppc-dev: message-id:
[email protected].

Thanks,
K.Prasad