diff mbox

[RFC,1/2] PPC64-HWBKPT: Disable interrupts for data breakpoint exceptions

Message ID 20100323140702.GB21836@in.ibm.com (mailing list archive)
State Superseded
Delegated to: Benjamin Herrenschmidt
Headers show

Commit Message

K.Prasad March 23, 2010, 2:07 p.m. UTC
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.

Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/exceptions-64s.S |   12 ++++++++++++
 arch/powerpc/mm/fault.c              |    2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

Paul Mackerras March 30, 2010, 5:24 a.m. UTC | #1
On Tue, Mar 23, 2010 at 07:37:02PM +0530, K.Prasad wrote:

> Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
> ===================================================================
> --- linux-2.6.ppc64_test.orig/arch/powerpc/kernel/exceptions-64s.S
> +++ 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? */

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

> +	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.

> +	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
> ===================================================================
> --- linux-2.6.ppc64_test.orig/arch/powerpc/mm/fault.c
> +++ 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 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.
Benjamin Herrenschmidt March 30, 2010, 5:32 a.m. UTC | #2
On Tue, 2010-03-30 at 16:24 +1100, Paul Mackerras wrote:
> On Tue, Mar 23, 2010 at 07:37:02PM +0530, K.Prasad wrote:
> 
> > Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
> > ===================================================================
> > --- linux-2.6.ppc64_test.orig/arch/powerpc/kernel/exceptions-64s.S
> > +++ 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? */
> 
> Minor comment: why not DSISR_DABRMATCH@h instead of 0x0040?
> 
> > +	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.
K.Prasad March 30, 2010, 10:17 a.m. UTC | #3
On Tue, Mar 30, 2010 at 04:24:42PM +1100, Paul Mackerras wrote:
> On Tue, Mar 23, 2010 at 07:37:02PM +0530, K.Prasad wrote:
> 
> > Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
> > ===================================================================
> > --- linux-2.6.ppc64_test.orig/arch/powerpc/kernel/exceptions-64s.S
> > +++ 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? */
> 
> 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:20100330095809.GA14403@in.ibm.com.

> > +	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.
>

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

Thanks,
K.Prasad
K.Prasad March 30, 2010, 10:19 a.m. UTC | #4
On Tue, Mar 30, 2010 at 04:32:25PM +1100, Benjamin Herrenschmidt wrote:
> On Tue, 2010-03-30 at 16:24 +1100, Paul Mackerras wrote:
> > On Tue, Mar 23, 2010 at 07:37:02PM +0530, K.Prasad wrote:
> > 
> > > Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
> > > ===================================================================
> > > --- linux-2.6.ppc64_test.orig/arch/powerpc/kernel/exceptions-64s.S
> > > +++ 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? */
> > 
> > Minor comment: why not DSISR_DABRMATCH@h instead of 0x0040?
> > 
> > > +	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:
20100330095925.GB14403@in.ibm.com.

Thanks,
K.Prasad
diff mbox

Patch

Index: linux-2.6.ppc64_test/arch/powerpc/kernel/exceptions-64s.S
===================================================================
--- linux-2.6.ppc64_test.orig/arch/powerpc/kernel/exceptions-64s.S
+++ 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
Index: linux-2.6.ppc64_test/arch/powerpc/mm/fault.c
===================================================================
--- linux-2.6.ppc64_test.orig/arch/powerpc/mm/fault.c
+++ 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);