linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Kprobes for book-e
@ 2008-06-03  5:30 Kumar Gala
  2008-06-03  5:48 ` Ananth N Mavinakayanahalli
  0 siblings, 1 reply; 21+ messages in thread
From: Kumar Gala @ 2008-06-03  5:30 UTC (permalink / raw)
  To: linuxppc-dev, Paul Mackerras; +Cc: madhvesh.s, rsmadhvesh

This is a patch that adds kprobes support for book-e style debug.  Its
based on the patch posted by Madhvesh and assumes the exception cleanup
that I've already posted.

Post to get any feedback.  The code needs some cleaning up but wanted to
see if there were any initial comments.

- k

---
 arch/powerpc/kernel/kprobes.c |   35 +++++++++++++++++++++++++++++++----
 arch/powerpc/kernel/misc_32.S |    2 +-
 arch/powerpc/kernel/traps.c   |   26 +++++++++++++++++++++++++-
 3 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 23545a2..2c9940c 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -35,6 +35,21 @@
 #include <asm/sstep.h>
 #include <asm/uaccess.h>

+
+#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#define single_stepping(regs)	(current->thread.dbcr0 & DBCR0_IC)
+#define clear_single_step(regs)	(current->thread.dbcr0 &= ~DBCR0_IC)
+#else
+#define single_stepping(regs)	((regs)->msr & MSR_SE)
+#define clear_single_step(regs)	((regs)->msr &= ~MSR_SE)
+#endif
+
+#ifdef CONFIG_BOOKE
+#define MSR_SINGLESTEP	(MSR_DE)
+#else
+#define MSR_SINGLESTEP	(MSR_SE)
+#endif
+
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);

@@ -53,7 +68,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 		ret = -EINVAL;
 	}

-	/* insn must be on a special executable page on ppc64 */
+	/* insn must be on a special executable page on ppc64.  This is
+	 * explicitly required on ppc32 (right now), but it doesn't hurt */
 	if (!ret) {
 		p->ainsn.insn = get_insn_slot();
 		if (!p->ainsn.insn)
@@ -95,7 +111,14 @@ void __kprobes arch_remove_kprobe(struct kprobe *p)

 static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
 {
+#ifdef CONFIG_BOOKE
+	regs->msr &= ~(MSR_EE); /* Turn off 'Externel Interrupt' bits */
+	regs->msr &= ~(MSR_CE); /* Turn off 'Critical Interrupt' bits */
+	regs->msr |= MSR_DE;
+	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
+#else
 	regs->msr |= MSR_SE;
+#endif

 	/*
 	 * On powerpc we should single step on the original
@@ -124,6 +147,10 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
 				struct kprobe_ctlblk *kcb)
 {
 	__get_cpu_var(current_kprobe) = p;
+#ifdef CONFIG_BOOKE
+	regs->msr |= (MSR_EE); /* Turn on 'External Interrupt' bits */
+	regs->msr |= (MSR_CE); /* Turn on 'Critical Interrupt' bits */
+#endif
 	kcb->kprobe_saved_msr = regs->msr;
 }

@@ -158,7 +185,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
 			kprobe_opcode_t insn = *p->ainsn.insn;
 			if (kcb->kprobe_status == KPROBE_HIT_SS &&
 					is_trap(insn)) {
-				regs->msr &= ~MSR_SE;
+				regs->msr &= ~MSR_SINGLESTEP; /* Turn off 'trace' bits */
 				regs->msr |= kcb->kprobe_saved_msr;
 				goto no_kprobe;
 			}
@@ -398,7 +425,7 @@ out:
 	 * will have SE set, in which case, continue the remaining processing
 	 * of do_debug, as if this is not a probe hit.
 	 */
-	if (regs->msr & MSR_SE)
+	if (single_stepping(regs))
 		return 0;

 	return 1;
@@ -421,7 +448,7 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
 		 * normal page fault.
 		 */
 		regs->nip = (unsigned long)cur->addr;
-		regs->msr &= ~MSR_SE;
+		regs->msr &= ~MSR_SINGLESTEP; /* Turn off 'trace' bits */
 		regs->msr |= kcb->kprobe_saved_msr;
 		if (kcb->kprobe_status == KPROBE_REENTER)
 			restore_previous_kprobe(kcb);
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 89aaaa6..6321ae3 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -489,7 +489,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID_CACHE)
  *
  * flush_icache_range(unsigned long start, unsigned long stop)
  */
-_GLOBAL(__flush_icache_range)
+_KPROBE(__flush_icache_range)
 BEGIN_FTR_SECTION
 	blr				/* for 601, do nothing */
 END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 4b5b7ff..dc97207 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1030,10 +1030,34 @@ void SoftwareEmulation(struct pt_regs *regs)

 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)

-void DebugException(struct pt_regs *regs, unsigned long debug_status)
+void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status)
 {
 	if (debug_status & DBSR_IC) {	/* instruction completion */
 		regs->msr &= ~MSR_DE;
+
+#ifdef CONFIG_KPROBES
+		/* Disable instruction completion */
+		mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
+		/* Clear the instruction completion event */
+		mtspr(SPRN_DBSR, DBSR_IC);
+
+		/*
+		 * On Book E and perhaps other processsors, singlestep is
+		 * handled on the critical exception stack.  This causes
+		 * current_thread_info() to fail, since it locates the
+		 * thread_info by masking off the low bits of the current
+		 * stack pointer.  We work around this issue by copying
+		 * the thread_info from the kernel stack before calling
+		 * kprobe_post_handler, and copying it back afterwards.
+		 * On most processors the copy is avoided since
+		 * exception_thread_info == thread_info.
+		 */
+		if (notify_die(DIE_SSTEP, "single_step", regs, 5,
+			       5, SIGTRAP) == NOTIFY_STOP) {
+			return;
+		}
+#endif
+
 		if (user_mode(regs)) {
 			current->thread.dbcr0 &= ~DBCR0_IC;
 		} else {
-- 
1.5.4.5

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03  5:30 Kumar Gala
@ 2008-06-03  5:48 ` Ananth N Mavinakayanahalli
  2008-06-03  5:50   ` Kumar Gala
  0 siblings, 1 reply; 21+ messages in thread
From: Ananth N Mavinakayanahalli @ 2008-06-03  5:48 UTC (permalink / raw)
  To: Kumar Gala; +Cc: madhvesh.s, linuxppc-dev, Paul Mackerras, rsmadhvesh

On Tue, Jun 03, 2008 at 12:30:51AM -0500, Kumar Gala wrote:
> This is a patch that adds kprobes support for book-e style debug.  Its
> based on the patch posted by Madhvesh and assumes the exception cleanup
> that I've already posted.
> 
> Post to get any feedback.  The code needs some cleaning up but wanted to
> see if there were any initial comments.
> 
> - k

...
 
> @@ -53,7 +68,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
>  		ret = -EINVAL;
>  	}
> 
> -	/* insn must be on a special executable page on ppc64 */
> +	/* insn must be on a special executable page on ppc64.  This is
> +	 * explicitly required on ppc32 (right now), but it doesn't hurt */
	^^^^^^^^
	not required?

I don't have much (any) knowledge about Book-E details, but the generic
powerpc changes look fine to me.

Ananth

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03  5:48 ` Ananth N Mavinakayanahalli
@ 2008-06-03  5:50   ` Kumar Gala
  0 siblings, 0 replies; 21+ messages in thread
From: Kumar Gala @ 2008-06-03  5:50 UTC (permalink / raw)
  To: ananth; +Cc: madhvesh.s, linuxppc-dev, Paul Mackerras, rsmadhvesh


On Jun 3, 2008, at 12:48 AM, Ananth N Mavinakayanahalli wrote:

> On Tue, Jun 03, 2008 at 12:30:51AM -0500, Kumar Gala wrote:
>> This is a patch that adds kprobes support for book-e style debug.   
>> Its
>> based on the patch posted by Madhvesh and assumes the exception  
>> cleanup
>> that I've already posted.
>>
>> Post to get any feedback.  The code needs some cleaning up but  
>> wanted to
>> see if there were any initial comments.
>>
>> - k
>
> ...
>
>> @@ -53,7 +68,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
>> 		ret = -EINVAL;
>> 	}
>>
>> -	/* insn must be on a special executable page on ppc64 */
>> +	/* insn must be on a special executable page on ppc64.  This is
>> +	 * explicitly required on ppc32 (right now), but it doesn't hurt */
> 	^^^^^^^^
> 	not required?

yes.  that should be 'not required'..

> I don't have much (any) knowledge about Book-E details, but the  
> generic
> powerpc changes look fine to me.

- k

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-03  8:23 Sulibhavi, Madhvesh
  2008-06-03 11:52 ` Josh Boyer
  2008-06-03 15:46 ` Kumar Gala
  0 siblings, 2 replies; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-03  8:23 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Sulibhavi, Madhvesh, linuxppc-dev, rsmadhvesh, Paul Mackerras

Kumar Gala wrote on Tuesday, June 03, 2008 11:01 AM
> This is a patch that adds kprobes support for book-e style debug.  Its
> based on the patch posted by Madhvesh and assumes the=20
> exception cleanup
> that I've already posted.

Thanks for your forward port of my previous kprobes patches.
Few months back i did a port to 2.6.22.y but using ppc arch.
As part of 2.6.22 port, i had to retain the debug exception handling=20
fixes in DebugException and head_booke.h. I have to look into
exception cleanup fixes posted by you.

....
>=20

> @@ -124,6 +147,10 @@ static void __kprobes=20
> set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
>  				struct kprobe_ctlblk *kcb)
>  {
>  	__get_cpu_var(current_kprobe) =3D p;
> +#ifdef CONFIG_BOOKE
> +	regs->msr |=3D (MSR_EE); /* Turn on 'External Interrupt' bits */
> +	regs->msr |=3D (MSR_CE); /* Turn on 'Critical Interrupt' bits */
> +#endif
>  	kcb->kprobe_saved_msr =3D regs->msr;
>  }

I think the block code under CONFIG_BOOKE may not=20
be required now if exception cleanup fixes address the stack
problem which i had explained in my port. I have to look into=20
exception fix patches and confirm about these changes. Can
you please provide me the thread where exception cleanup
is posted as i haven't tracked the list from long time.

> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -1030,10 +1030,34 @@ void SoftwareEmulation(struct pt_regs *regs)
>=20
>  #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
>=20
> -void DebugException(struct pt_regs *regs, unsigned long debug_status)
> +void __kprobes DebugException(struct pt_regs *regs, unsigned=20
> long debug_status)
>  {
>  	if (debug_status & DBSR_IC) {	/* instruction completion */
>  		regs->msr &=3D ~MSR_DE;
> +
> +#ifdef CONFIG_KPROBES
> +		/* Disable instruction completion */
> +		mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
> +		/* Clear the instruction completion event */
> +		mtspr(SPRN_DBSR, DBSR_IC);
> +
> +		/*
> +		 * On Book E and perhaps other processsors,=20
> singlestep is
> +		 * handled on the critical exception stack.  This causes
> +		 * current_thread_info() to fail, since it locates the
> +		 * thread_info by masking off the low bits of=20
> the current
> +		 * stack pointer.  We work around this issue by copying
> +		 * the thread_info from the kernel stack before calling
> +		 * kprobe_post_handler, and copying it back afterwards.
> +		 * On most processors the copy is avoided since
> +		 * exception_thread_info =3D=3D thread_info.
> +		 */

The above comment will not be valid now as stack copy is removed.


Below is the other change what i have in my kprobes ported code.=20

@@ -180,9 +180,7 @@ void __kprobes arch_disarm_kprobe(struct
=20
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
-       mutex_lock(&kprobe_mutex);
        free_insn_slot(p->ainsn.insn,0);
-       mutex_unlock(&kprobe_mutex);
 }
=20
This change is mainly to fix some build issues while working
with lttng patches. I think this is coming from sched-devel git
posted from here http://lkml.org/lkml/2008/4/9/159
So the above changes are not required as mainline tree
still uses global mutex. This needs to be addressed in future.

Kumar, i would like to test the updated kprobes patches on my
ebony target using latest kernel. But i am facing build issues using
2.6.26.rc3 for powerpc arch while using the ebony configuration.
I tried it using paulus git tree, but could not succeed. If you have
any ideas on any stable version of latest tree where ebony config
can be built using powerpc arch, please let me know.

Thanks
Madhvesh



-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03  8:23 Sulibhavi, Madhvesh
@ 2008-06-03 11:52 ` Josh Boyer
  2008-06-03 15:46 ` Kumar Gala
  1 sibling, 0 replies; 21+ messages in thread
From: Josh Boyer @ 2008-06-03 11:52 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh
  Cc: linuxppc-dev, Paul Mackerras, Sulibhavi, Madhvesh, rsmadhvesh

On Tue, 3 Jun 2008 13:53:37 +0530
"Sulibhavi, Madhvesh" <madhvesh.s@ap.sony.com> wrote:
 
> Kumar, i would like to test the updated kprobes patches on my
> ebony target using latest kernel. But i am facing build issues using
> 2.6.26.rc3 for powerpc arch while using the ebony configuration.
> I tried it using paulus git tree, but could not succeed. If you have
> any ideas on any stable version of latest tree where ebony config
> can be built using powerpc arch, please let me know.

What build issues?  Ebony should build fine for 2.6.26-rc3, unless
you're trying to apply this patchset to it without the other patches it
requires.

You'll need to use either my git tree with Kumar's exception series
applied, or use Kumar's tree.  The kprobes code is 2.6.27 material,
so .26-rc3 (or -rc4) is too old.

josh

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-03 14:10 Sulibhavi, Madhvesh
  2008-06-03 14:18 ` Josh Boyer
  0 siblings, 1 reply; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-03 14:10 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

Josh Boyer wrote on Tuesday, June 03, 2008 5:22 PM
> What build issues?  Ebony should build fine for 2.6.26-rc3, unless
> you're trying to apply this patchset to it without the other=20
> patches it
> requires.

I am trying without kprobes patches. I get build error
as below

--------------------------------------------------------------
BFD: ./vmlinux.strip.28275: section .bss lma 0xc034f000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section `.text' can't be allocated in
segment 0
/usr/local/powerpc-linux/bin/powerpc-linux-objcopy:
./vmlinux.strip.28275: Bad value
BFD: ./vmlinux.strip.28275: section .text lma 0xc0000000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .ref.text lma 0xc024e000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .devinit.text lma 0xc024f860
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .devexit.text lma 0xc0253624
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .rodata lma 0xc0254000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .pci_fixup lma 0xc02ebcc8 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section __ksymtab lma 0xc02ec280 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section __ksymtab_gpl lma 0xc02f0c58
overlaps previous sections
BFD: ./vmlinux.strip.28275: section __kcrctab lma 0xc02f2620 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section __kcrctab_gpl lma 0xc02f4b0c
overlaps previous sections
BFD: ./vmlinux.strip.28275: section __ksymtab_strings lma 0xc02f57f0
overlaps previous sections
BFD: ./vmlinux.strip.28275: section __param lma 0xc0302d74 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section __ex_table lma 0xc0304000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section __bug_table lma 0xc0305780 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .init.text lma 0xc0309000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .exit.text lma 0xc0321010 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .init.data lma 0xc0321bd4 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .init.setup lma 0xc03253e0 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .initcall.init lma 0xc032568c
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .con_initcall.init lma 0xc03258c4
overlaps previous sections
BFD: ./vmlinux.strip.28275: section __ftr_fixup lma 0xc03258d0 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .machine.desc lma 0xc0326000
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .data lma 0xc0327000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section .data.init_task lma 0xc0348000
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .data.page_aligned lma 0xc034a000
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .data.cacheline_aligned lma
0xc034d000 overlaps previous sections
BFD: ./vmlinux.strip.28275: section .data.read_mostly lma 0xc034d100
overlaps previous sections
BFD: ./vmlinux.strip.28275: section .bss lma 0xc034f000 overlaps
previous sections
BFD: ./vmlinux.strip.28275: section `.text' can't be allocated in
segment 0
/usr/local/powerpc-linux/bin/powerpc-linux-objcopy:
./vmlinux.strip.28275: Bad value
make[1]: *** [arch/powerpc/boot/treeImage.ebony] Error 1
rm arch/powerpc/boot/ebony.dtb
make: *** [zImage] Error 2
--------------------------------------------------------------


>=20
> You'll need to use either my git tree with Kumar's exception series
> applied, or use Kumar's tree.  The kprobes code is 2.6.27 material,
> so .26-rc3 (or -rc4) is too old.

I will try with kumar's git repository

-Madhvesh


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03 14:10 Sulibhavi, Madhvesh
@ 2008-06-03 14:18 ` Josh Boyer
  2008-06-03 14:37   ` Kumar Gala
  0 siblings, 1 reply; 21+ messages in thread
From: Josh Boyer @ 2008-06-03 14:18 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

On Tue, 3 Jun 2008 19:40:55 +0530
"Sulibhavi, Madhvesh" <madhvesh.s@ap.sony.com> wrote:

> Josh Boyer wrote on Tuesday, June 03, 2008 5:22 PM
> > What build issues?  Ebony should build fine for 2.6.26-rc3, unless
> > you're trying to apply this patchset to it without the other 
> > patches it
> > requires.
> 
> I am trying without kprobes patches. I get build error
> as below
> 
> --------------------------------------------------------------
> BFD: ./vmlinux.strip.28275: section .bss lma 0xc034f000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section `.text' can't be allocated in
> segment 0
> /usr/local/powerpc-linux/bin/powerpc-linux-objcopy:
> ./vmlinux.strip.28275: Bad value
> BFD: ./vmlinux.strip.28275: section .text lma 0xc0000000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .ref.text lma 0xc024e000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .devinit.text lma 0xc024f860
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .devexit.text lma 0xc0253624
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .rodata lma 0xc0254000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .pci_fixup lma 0xc02ebcc8 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section __ksymtab lma 0xc02ec280 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section __ksymtab_gpl lma 0xc02f0c58
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section __kcrctab lma 0xc02f2620 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section __kcrctab_gpl lma 0xc02f4b0c
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section __ksymtab_strings lma 0xc02f57f0
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section __param lma 0xc0302d74 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section __ex_table lma 0xc0304000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section __bug_table lma 0xc0305780 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .init.text lma 0xc0309000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .exit.text lma 0xc0321010 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .init.data lma 0xc0321bd4 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .init.setup lma 0xc03253e0 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .initcall.init lma 0xc032568c
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .con_initcall.init lma 0xc03258c4
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section __ftr_fixup lma 0xc03258d0 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .machine.desc lma 0xc0326000
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .data lma 0xc0327000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section .data.init_task lma 0xc0348000
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .data.page_aligned lma 0xc034a000
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .data.cacheline_aligned lma
> 0xc034d000 overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .data.read_mostly lma 0xc034d100
> overlaps previous sections
> BFD: ./vmlinux.strip.28275: section .bss lma 0xc034f000 overlaps
> previous sections
> BFD: ./vmlinux.strip.28275: section `.text' can't be allocated in
> segment 0
> /usr/local/powerpc-linux/bin/powerpc-linux-objcopy:
> ./vmlinux.strip.28275: Bad value
> make[1]: *** [arch/powerpc/boot/treeImage.ebony] Error 1
> rm arch/powerpc/boot/ebony.dtb
> make: *** [zImage] Error 2

Um, weird.  What version of binutils and gcc are you using?

I've heard of problems with binutils 2.17, but I have no idea why that
would be.

josh

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03 14:18 ` Josh Boyer
@ 2008-06-03 14:37   ` Kumar Gala
  0 siblings, 0 replies; 21+ messages in thread
From: Kumar Gala @ 2008-06-03 14:37 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Paul Mackerras, Sulibhavi, Madhvesh, rsmadhvesh


On Jun 3, 2008, at 9:18 AM, Josh Boyer wrote:

> On Tue, 3 Jun 2008 19:40:55 +0530
> "Sulibhavi, Madhvesh" <madhvesh.s@ap.sony.com> wrote:
>
>> Josh Boyer wrote on Tuesday, June 03, 2008 5:22 PM
>>> What build issues?  Ebony should build fine for 2.6.26-rc3, unless
>>> you're trying to apply this patchset to it without the other
>>> patches it
>>> requires.
>>
>> I am trying without kprobes patches. I get build error
>> as below
>>
>> --------------------------------------------------------------
>> BFD: ./vmlinux.strip.28275: section .bss lma 0xc034f000 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section `.text' can't be allocated in
>> segment 0
>> /usr/local/powerpc-linux/bin/powerpc-linux-objcopy:
>> ./vmlinux.strip.28275: Bad value
>> BFD: ./vmlinux.strip.28275: section .text lma 0xc0000000 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .ref.text lma 0xc024e000 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .devinit.text lma 0xc024f860
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .devexit.text lma 0xc0253624
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .rodata lma 0xc0254000 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .pci_fixup lma 0xc02ebcc8  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section __ksymtab lma 0xc02ec280 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section __ksymtab_gpl lma 0xc02f0c58
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section __kcrctab lma 0xc02f2620 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section __kcrctab_gpl lma 0xc02f4b0c
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section __ksymtab_strings lma 0xc02f57f0
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section __param lma 0xc0302d74 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section __ex_table lma 0xc0304000  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section __bug_table lma 0xc0305780  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .init.text lma 0xc0309000  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .exit.text lma 0xc0321010  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .init.data lma 0xc0321bd4  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .init.setup lma 0xc03253e0  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .initcall.init lma 0xc032568c
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .con_initcall.init lma 0xc03258c4
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section __ftr_fixup lma 0xc03258d0  
>> overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .machine.desc lma 0xc0326000
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .data lma 0xc0327000 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section .data.init_task lma 0xc0348000
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .data.page_aligned lma 0xc034a000
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .data.cacheline_aligned lma
>> 0xc034d000 overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .data.read_mostly lma 0xc034d100
>> overlaps previous sections
>> BFD: ./vmlinux.strip.28275: section .bss lma 0xc034f000 overlaps
>> previous sections
>> BFD: ./vmlinux.strip.28275: section `.text' can't be allocated in
>> segment 0
>> /usr/local/powerpc-linux/bin/powerpc-linux-objcopy:
>> ./vmlinux.strip.28275: Bad value
>> make[1]: *** [arch/powerpc/boot/treeImage.ebony] Error 1
>> rm arch/powerpc/boot/ebony.dtb
>> make: *** [zImage] Error 2
>
> Um, weird.  What version of binutils and gcc are you using?
>
> I've heard of problems with binutils 2.17, but I have no idea why that
> would be.

This looks like the binutils problem that cell was having and I  
believe Alan Modra fixed:

http://sourceware.org/ml/binutils/2008-05/msg00008.html

- k
>
>
> josh

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-03 14:39 Sulibhavi, Madhvesh
  0 siblings, 0 replies; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-03 14:39 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

> From: Josh Boyer [mailto:jwboyer@linux.vnet.ibm.com]=20
> Sent: Tuesday, June 03, 2008 7:49 PM
> To: Sulibhavi, Madhvesh
> Cc: Kumar Gala; linuxppc-dev@ozlabs.org; rsmadhvesh@vsnl.net;=20
> Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e
>=20
> Um, weird.  What version of binutils and gcc are you using?

binutils-> 2.17.50
gcc-> 4.1.2

-madhvesh


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03 14:48 [RFC] Kprobes for book-e Sulibhavi, Madhvesh
@ 2008-06-03 14:46 ` Josh Boyer
  0 siblings, 0 replies; 21+ messages in thread
From: Josh Boyer @ 2008-06-03 14:46 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

On Tue, 3 Jun 2008 20:18:01 +0530
"Sulibhavi, Madhvesh" <madhvesh.s@ap.sony.com> wrote:

> > -----Original Message-----
> > From: Kumar Gala [mailto:galak@kernel.crashing.org] 
> > Sent: Tuesday, June 03, 2008 8:08 PM
> > To: Josh Boyer
> > Cc: Sulibhavi, Madhvesh; linuxppc-dev@ozlabs.org; 
> > rsmadhvesh@vsnl.net; Paul Mackerras
> > Subject: Re: [RFC] Kprobes for book-e
> > 
> 
> > This looks like the binutils problem that cell was having and I  
> > believe Alan Modra fixed:
> > 
> > http://sourceware.org/ml/binutils/2008-05/msg00008.html
> > 
> Thanks, is it posible to get latest binutils binary which
> is applied with this fix? If i just upgrade binutils, will
> it solve this problem or i have to rebuild gcc etc etc..

A newer binutils should work just fine.  Also, and older one would
likely work too.  I use either 2.15 or 2.18.

josh

P.S.  You should really get rid of that disclaimer message at the
bottom of your emails.  You're sending to a public list so it makes no
sense.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-03 14:48 Sulibhavi, Madhvesh
  2008-06-03 14:46 ` Josh Boyer
  0 siblings, 1 reply; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-03 14:48 UTC (permalink / raw)
  To: Kumar Gala, Josh Boyer; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]=20
> Sent: Tuesday, June 03, 2008 8:08 PM
> To: Josh Boyer
> Cc: Sulibhavi, Madhvesh; linuxppc-dev@ozlabs.org;=20
> rsmadhvesh@vsnl.net; Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e
>=20

> This looks like the binutils problem that cell was having and I =20
> believe Alan Modra fixed:
>=20
> http://sourceware.org/ml/binutils/2008-05/msg00008.html
>=20
Thanks, is it posible to get latest binutils binary which
is applied with this fix? If i just upgrade binutils, will
it solve this problem or i have to rebuild gcc etc etc..

-madhvesh


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-03 15:01 Sulibhavi, Madhvesh
  0 siblings, 0 replies; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-03 15:01 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

> -----Original Message-----
> From: Josh Boyer [mailto:jwboyer@linux.vnet.ibm.com]=20
> Sent: Tuesday, June 03, 2008 8:17 PM
> To: Sulibhavi, Madhvesh
> Cc: Kumar Gala; linuxppc-dev@ozlabs.org; rsmadhvesh@vsnl.net;=20
> Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e
> A newer binutils should work just fine.  Also, and older one would
> likely work too.  I use either 2.15 or 2.18.

thanks,  will try with any one of this
>=20
> josh
>=20
> P.S.  You should really get rid of that disclaimer message at the
> bottom of your emails.  You're sending to a public list so it makes no
> sense.
This message is annoying for anyone. I don't have much
control on its removal and in some lists, it was accepted=20
and i just used..
I will have to switch my replies..

-madhvesh


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-03  8:23 Sulibhavi, Madhvesh
  2008-06-03 11:52 ` Josh Boyer
@ 2008-06-03 15:46 ` Kumar Gala
  1 sibling, 0 replies; 21+ messages in thread
From: Kumar Gala @ 2008-06-03 15:46 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras


On Jun 3, 2008, at 3:23 AM, Sulibhavi, Madhvesh wrote:

> Kumar Gala wrote on Tuesday, June 03, 2008 11:01 AM
>> This is a patch that adds kprobes support for book-e style debug.   
>> Its
>> based on the patch posted by Madhvesh and assumes the
>> exception cleanup
>> that I've already posted.
>
> Thanks for your forward port of my previous kprobes patches.
> Few months back i did a port to 2.6.22.y but using ppc arch.
> As part of 2.6.22 port, i had to retain the debug exception handling
> fixes in DebugException and head_booke.h. I have to look into
> exception cleanup fixes posted by you.
>
> ....
>>
>
>> @@ -124,6 +147,10 @@ static void __kprobes
>> set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
>> 				struct kprobe_ctlblk *kcb)
>> {
>> 	__get_cpu_var(current_kprobe) = p;
>> +#ifdef CONFIG_BOOKE
>> +	regs->msr |= (MSR_EE); /* Turn on 'External Interrupt' bits */
>> +	regs->msr |= (MSR_CE); /* Turn on 'Critical Interrupt' bits */
>> +#endif
>> 	kcb->kprobe_saved_msr = regs->msr;
>> }
>
> I think the block code under CONFIG_BOOKE may not
> be required now if exception cleanup fixes address the stack
> problem which i had explained in my port. I have to look into
> exception fix patches and confirm about these changes. Can
> you please provide me the thread where exception cleanup
> is posted as i haven't tracked the list from long time.

http://ozlabs.org/pipermail/linuxppc-dev/2008-May/056457.html

What was the original thinking about why you had to enable MSR_EE and  
MSR_CE?

>> --- a/arch/powerpc/kernel/traps.c
>> +++ b/arch/powerpc/kernel/traps.c
>> @@ -1030,10 +1030,34 @@ void SoftwareEmulation(struct pt_regs *regs)
>>
>> #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
>>
>> -void DebugException(struct pt_regs *regs, unsigned long  
>> debug_status)
>> +void __kprobes DebugException(struct pt_regs *regs, unsigned
>> long debug_status)
>> {
>> 	if (debug_status & DBSR_IC) {	/* instruction completion */
>> 		regs->msr &= ~MSR_DE;
>> +
>> +#ifdef CONFIG_KPROBES
>> +		/* Disable instruction completion */
>> +		mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
>> +		/* Clear the instruction completion event */
>> +		mtspr(SPRN_DBSR, DBSR_IC);
>> +
>> +		/*
>> +		 * On Book E and perhaps other processsors,
>> singlestep is
>> +		 * handled on the critical exception stack.  This causes
>> +		 * current_thread_info() to fail, since it locates the
>> +		 * thread_info by masking off the low bits of
>> the current
>> +		 * stack pointer.  We work around this issue by copying
>> +		 * the thread_info from the kernel stack before calling
>> +		 * kprobe_post_handler, and copying it back afterwards.
>> +		 * On most processors the copy is avoided since
>> +		 * exception_thread_info == thread_info.
>> +		 */
>
> The above comment will not be valid now as stack copy is removed.

Agreed, I think I can simplify down the code here and remove the  
CONFIG_KPROBES.

> Below is the other change what i have in my kprobes ported code.
>
> @@ -180,9 +180,7 @@ void __kprobes arch_disarm_kprobe(struct
>
> void __kprobes arch_remove_kprobe(struct kprobe *p)
> {
> -       mutex_lock(&kprobe_mutex);
>        free_insn_slot(p->ainsn.insn,0);
> -       mutex_unlock(&kprobe_mutex);
> }
>
> This change is mainly to fix some build issues while working
> with lttng patches. I think this is coming from sched-devel git
> posted from here http://lkml.org/lkml/2008/4/9/159
> So the above changes are not required as mainline tree
> still uses global mutex. This needs to be addressed in future.
>
> Kumar, i would like to test the updated kprobes patches on my
> ebony target using latest kernel. But i am facing build issues using
> 2.6.26.rc3 for powerpc arch while using the ebony configuration.
> I tried it using paulus git tree, but could not succeed. If you have
> any ideas on any stable version of latest tree where ebony config
> can be built using powerpc arch, please let me know.

- k

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-09 14:10 Sulibhavi, Madhvesh
  0 siblings, 0 replies; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-09 14:10 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

Kumar Gala wrote on Tuesday, June 03, 2008 9:16 PM
> To: Sulibhavi, Madhvesh
> Cc: rsmadhvesh@vsnl.net; ananth@in.ibm.com;=20
> linuxppc-dev@ozlabs.org; Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e

..<snip>
>=20
> >
> > I think the block code under CONFIG_BOOKE may not
> > be required now if exception cleanup fixes address the stack
> > problem which i had explained in my port. I have to look into
> > exception fix patches and confirm about these changes. Can
> > you please provide me the thread where exception cleanup
> > is posted as i haven't tracked the list from long time.
>=20
> http://ozlabs.org/pipermail/linuxppc-dev/2008-May/056457.html
>=20
> What was the original thinking about why you had to enable=20
> MSR_EE and =20
> MSR_CE?

I found that this code is redundant and it was added while debugging
the flags status during my port. This is a bug since it modifies the MSR

status and enables the critical and external bits which is not supposed
to.
The interrupts status should be kept back to original state without
enabling
interrupt bits after executing the post_handler. So this change is not
valid
and it can be taken out.

The code within the "prepare_single_step()" is already doing the job=20
of disabling interrupts and setting bits required for single step and
hence
no additional changes are required for Book-e version of kprobes.

I confirmed the above changes in my local tree and found no issues
for kprobes, jprobes and kretprobes. But this testing is done using
2.6.22.y+ppc arch.

Once after fixing the binutils-2.17 issue i am facing for latest kernel,

i will retest and inform if any problems to new patches.=20

-madhvesh



-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-11 14:18 Sulibhavi, Madhvesh
  2008-06-11 15:05 ` Kumar Gala
  0 siblings, 1 reply; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-11 14:18 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh, Kumar Gala; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

Hi Kumar,

I could switch to different version of binutils and
boot the recent git for ebony target. The kprobes
booke patches attached below got applied and
i didnot see any issues.  These patches can be=20
now pushed to main line?

Below is the revised patch set after addressing some=20
cleanups in traps.c and bug fixes to kprobes.c discussed=20
earlier. Also added the support to Documentation/kprobes.txt=20
and KRETPROBES check in powerpc/Kconfig file.

-Madhvesh

---------------------------------------------------------------------
arch/powerpc/kernel/kprobes.c |   35 +++++++++++++++++++++++++++++++----
 arch/powerpc/kernel/misc_32.S |    2 +-
 arch/powerpc/kernel/traps.c   |   26 +++++++++++++++++++++++++-
 3 files changed, 57 insertions(+), 6 deletions(-)

Index: b/arch/powerpc/kernel/kprobes.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -35,6 +35,21 @@
 #include <asm/sstep.h>
 #include <asm/uaccess.h>
=20
+
+#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#define single_stepping(regs)	(current->thread.dbcr0 & DBCR0_IC)
+#define clear_single_step(regs)	(current->thread.dbcr0 &=3D
~DBCR0_IC)
+#else
+#define single_stepping(regs)	((regs)->msr & MSR_SE)
+#define clear_single_step(regs)	((regs)->msr &=3D ~MSR_SE)
+#endif
+
+#ifdef CONFIG_BOOKE
+#define MSR_SINGLESTEP	(MSR_DE)
+#else
+#define MSR_SINGLESTEP	(MSR_SE)
+#endif
+
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) =3D NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
=20
@@ -53,7 +68,8 @@ int __kprobes arch_prepare_kprobe(struct
 		ret =3D -EINVAL;
 	}
=20
-	/* insn must be on a special executable page on ppc64 */
+	/* insn must be on a special executable page on ppc64.  This is
+	 * explicitly not required on ppc32 (right now), but it doesn't
hurt */
 	if (!ret) {
 		p->ainsn.insn =3D get_insn_slot();
 		if (!p->ainsn.insn)
@@ -95,7 +111,14 @@ void __kprobes arch_remove_kprobe(struct
=20
 static void __kprobes prepare_singlestep(struct kprobe *p, struct
pt_regs *regs)
 {
+#ifdef CONFIG_BOOKE
+	regs->msr &=3D ~(MSR_EE); /* Turn off 'Externel Interrupt' bits */
+	regs->msr &=3D ~(MSR_CE); /* Turn off 'Critical Interrupt' bits */
+	regs->msr |=3D MSR_DE;
+	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
+#else
 	regs->msr |=3D MSR_SE;
+#endif
=20
 	/*
 	 * On powerpc we should single step on the original
@@ -158,7 +181,7 @@ static int __kprobes kprobe_handler(stru
 			kprobe_opcode_t insn =3D *p->ainsn.insn;
 			if (kcb->kprobe_status =3D=3D KPROBE_HIT_SS &&
 					is_trap(insn)) {
-				regs->msr &=3D ~MSR_SE;
+				regs->msr &=3D ~MSR_SINGLESTEP; /* Turn
off 'trace' bits */
 				regs->msr |=3D kcb->kprobe_saved_msr;
 				goto no_kprobe;
 			}
@@ -398,7 +421,7 @@ out:
 	 * will have SE set, in which case, continue the remaining
processing
 	 * of do_debug, as if this is not a probe hit.
 	 */
-	if (regs->msr & MSR_SE)
+	if (single_stepping(regs))
 		return 0;
=20
 	return 1;
@@ -421,7 +444,7 @@ int __kprobes kprobe_fault_handler(struc
 		 * normal page fault.
 		 */
 		regs->nip =3D (unsigned long)cur->addr;
-		regs->msr &=3D ~MSR_SE;
+		regs->msr &=3D ~MSR_SINGLESTEP; /* Turn off 'trace' bits
*/
 		regs->msr |=3D kcb->kprobe_saved_msr;
 		if (kcb->kprobe_status =3D=3D KPROBE_REENTER)
 			restore_previous_kprobe(kcb);
Index: b/arch/powerpc/kernel/misc_32.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -489,7 +489,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID
  *
  * flush_icache_range(unsigned long start, unsigned long stop)
  */
-_GLOBAL(__flush_icache_range)
+_KPROBE(__flush_icache_range)
 BEGIN_FTR_SECTION
 	blr				/* for 601, do nothing */
 END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
Index: b/arch/powerpc/kernel/traps.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1030,7 +1030,7 @@ void SoftwareEmulation(struct pt_regs *r
=20
 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
=20
-void DebugException(struct pt_regs *regs, unsigned long debug_status)
+void __kprobes DebugException(struct pt_regs *regs, unsigned long
debug_status)
 {
 	if (debug_status & DBSR_IC) {	/* instruction completion */
 		regs->msr &=3D ~MSR_DE;
@@ -1041,6 +1041,12 @@ void DebugException(struct pt_regs *regs
 			mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) &
~DBCR0_IC);
 			/* Clear the instruction completion event */
 			mtspr(SPRN_DBSR, DBSR_IC);
+#ifdef CONFIG_KPROBES
+			if (notify_die(DIE_SSTEP, "single_step", regs,
5,
+			       5, SIGTRAP) =3D=3D NOTIFY_STOP) {
+				return;
+			}
+#endif
 			if (debugger_sstep(regs))
 				return;
 		}
Index: b/Documentation/kprobes.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -172,6 +172,7 @@ architectures:
 - ia64 (Does not support probes on instruction slot1.)
 - sparc64 (Return probes not yet implemented.)
 - arm
+- ppc32
=20
 3. Configuring Kprobes
=20
Index: b/arch/powerpc/Kconfig
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -108,7 +108,7 @@ config PPC
 	select HAVE_IDE
 	select HAVE_OPROFILE
 	select HAVE_KPROBES
-	select HAVE_KRETPROBES
+	select HAVE_KRETPROBES if (HAVE_KPROBES)
 	select HAVE_LMB
=20
 config EARLY_PRINTK


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-11 14:18 Sulibhavi, Madhvesh
@ 2008-06-11 15:05 ` Kumar Gala
  2008-06-11 15:59   ` Kumar Gala
  0 siblings, 1 reply; 21+ messages in thread
From: Kumar Gala @ 2008-06-11 15:05 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras


On Jun 11, 2008, at 9:18 AM, Sulibhavi, Madhvesh wrote:

> Hi Kumar,
>
> I could switch to different version of binutils and
> boot the recent git for ebony target. The kprobes
> booke patches attached below got applied and
> i didnot see any issues.  These patches can be
> now pushed to main line?

there's a bit more cleanup, but I don't see any reason we cant get  
this done quickly.

> Below is the revised patch set after addressing some
> cleanups in traps.c and bug fixes to kprobes.c discussed
> earlier. Also added the support to Documentation/kprobes.txt
> and KRETPROBES check in powerpc/Kconfig file.

See my comments below.

> -Madhvesh
>
> ---------------------------------------------------------------------
> arch/powerpc/kernel/kprobes.c |   35 ++++++++++++++++++++++++++++++ 
> +----
> arch/powerpc/kernel/misc_32.S |    2 +-
> arch/powerpc/kernel/traps.c   |   26 +++++++++++++++++++++++++-
> 3 files changed, 57 insertions(+), 6 deletions(-)

Your patch got line wrapped by your mailer.  Take a look at  
Documentation/email-clients.tx

> static void __kprobes prepare_singlestep(struct kprobe *p, struct
> pt_regs *regs)
> {
> +#ifdef CONFIG_BOOKE
> +	regs->msr &= ~(MSR_EE); /* Turn off 'Externel Interrupt' bits */
> +	regs->msr &= ~(MSR_CE); /* Turn off 'Critical Interrupt' bits */
> +	regs->msr |= MSR_DE;

can we remove MSR_EE and MSR_CE here?
>
> +	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
> +#else
> 	regs->msr |= MSR_SE;
> +#endif
>
> 	/*
> 	 * On powerpc we should single step on the original
> @@ -158,7 +181,7 @@ static int __kprobes kprobe_handler(stru
> 			kprobe_opcode_t insn = *p->ainsn.insn;
> 			if (kcb->kprobe_status == KPROBE_HIT_SS &&
> 					is_trap(insn)) {
> -				regs->msr &= ~MSR_SE;
> +				regs->msr &= ~MSR_SINGLESTEP; /* Turn
> off 'trace' bits */
> 				regs->msr |= kcb->kprobe_saved_msr;
> 				goto no_kprobe;
> 			}
> @@ -398,7 +421,7 @@ out:
> 	 * will have SE set, in which case, continue the remaining
> processing
> 	 * of do_debug, as if this is not a probe hit.
> 	 */
> -	if (regs->msr & MSR_SE)
> +	if (single_stepping(regs))
> 		return 0;
>
> 	return 1;
> @@ -421,7 +444,7 @@ int __kprobes kprobe_fault_handler(struc
> 		 * normal page fault.
> 		 */
> 		regs->nip = (unsigned long)cur->addr;
> -		regs->msr &= ~MSR_SE;
> +		regs->msr &= ~MSR_SINGLESTEP; /* Turn off 'trace' bits
> */
> 		regs->msr |= kcb->kprobe_saved_msr;
> 		if (kcb->kprobe_status == KPROBE_REENTER)
> 			restore_previous_kprobe(kcb);
> Index: b/arch/powerpc/kernel/misc_32.S
> ===================================================================
> --- a/arch/powerpc/kernel/misc_32.S
> +++ b/arch/powerpc/kernel/misc_32.S
> @@ -489,7 +489,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID
>  *
>  * flush_icache_range(unsigned long start, unsigned long stop)
>  */
> -_GLOBAL(__flush_icache_range)
> +_KPROBE(__flush_icache_range)
> BEGIN_FTR_SECTION
> 	blr				/* for 601, do nothing */
> END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> Index: b/arch/powerpc/kernel/traps.c
> ===================================================================
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -1030,7 +1030,7 @@ void SoftwareEmulation(struct pt_regs *r
>
> #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
>
> -void DebugException(struct pt_regs *regs, unsigned long debug_status)
> +void __kprobes DebugException(struct pt_regs *regs, unsigned long
> debug_status)
> {
> 	if (debug_status & DBSR_IC) {	/* instruction completion */
> 		regs->msr &= ~MSR_DE;
> @@ -1041,6 +1041,12 @@ void DebugException(struct pt_regs *regs
> 			mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) &
> ~DBCR0_IC);
> 			/* Clear the instruction completion event */
> 			mtspr(SPRN_DBSR, DBSR_IC);
> +#ifdef CONFIG_KPROBES
> +			if (notify_die(DIE_SSTEP, "single_step", regs,
> 5,
> +			       5, SIGTRAP) == NOTIFY_STOP) {
> +				return;
> +			}
> +#endif
> 			if (debugger_sstep(regs))
> 				return;
> 		}
> Index: b/Documentation/kprobes.txt
> ===================================================================
> --- a/Documentation/kprobes.txt
> +++ b/Documentation/kprobes.txt
> @@ -172,6 +172,7 @@ architectures:
> - ia64 (Does not support probes on instruction slot1.)
> - sparc64 (Return probes not yet implemented.)
> - arm
> +- ppc32
>
> 3. Configuring Kprobes
>
> Index: b/arch/powerpc/Kconfig
> ===================================================================
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -108,7 +108,7 @@ config PPC
> 	select HAVE_IDE
> 	select HAVE_OPROFILE
> 	select HAVE_KPROBES
> -	select HAVE_KRETPROBES
> +	select HAVE_KRETPROBES if (HAVE_KPROBES)

why bother?  we select HAVE_KPROBES one line earlier?

>
> 	select HAVE_LMB
>
> config EARLY_PRINTK
>
>
> -------------------------------------------------------------------
> This email is confidential and intended only for the use of the  
> individual or entity named above and may contain information that is  
> privileged. If you are not the intended recipient, you are notified  
> that any dissemination, distribution or copying of this email is  
> strictly prohibited. If you have received this email in error,  
> please notify us immediately by return email or telephone and  
> destroy the original message. - This mail is sent via Sony Asia  
> Pacific Mail Gateway.
> -------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-11 15:05 ` Kumar Gala
@ 2008-06-11 15:59   ` Kumar Gala
  0 siblings, 0 replies; 21+ messages in thread
From: Kumar Gala @ 2008-06-11 15:59 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras


---

Here's a cleaned up version of my patch incorporating the changes we've
discussed and some minor tweaks to traps.c.  Can you take a look and test
it out.  I'm wondering about having to clear MSR_EE & MSR_CE in
prepare_singlestep().  Doesnt seem like we need to do that at all.

- k

 Documentation/kprobes.txt     |    1 +
 arch/powerpc/kernel/kprobes.c |   23 +++++++++++++++++++----
 arch/powerpc/kernel/misc_32.S |    2 +-
 arch/powerpc/kernel/traps.c   |   32 +++++++++++++++++---------------
 include/asm-powerpc/system.h  |    9 +++++++++
 5 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index 6877e71..a79633d 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -172,6 +172,7 @@ architectures:
 - ia64 (Does not support probes on instruction slot1.)
 - sparc64 (Return probes not yet implemented.)
 - arm
+- ppc

 3. Configuring Kprobes

diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 23545a2..0dca55e 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -34,6 +34,13 @@
 #include <asm/cacheflush.h>
 #include <asm/sstep.h>
 #include <asm/uaccess.h>
+#include <asm/system.h>
+
+#ifdef CONFIG_BOOKE
+#define MSR_SINGLESTEP	(MSR_DE)
+#else
+#define MSR_SINGLESTEP	(MSR_SE)
+#endif

 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
@@ -53,7 +60,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 		ret = -EINVAL;
 	}

-	/* insn must be on a special executable page on ppc64 */
+	/* insn must be on a special executable page on ppc64.  This is
+	 * not explicitly required on ppc32 (right now), but it doesn't hurt */
 	if (!ret) {
 		p->ainsn.insn = get_insn_slot();
 		if (!p->ainsn.insn)
@@ -95,7 +103,14 @@ void __kprobes arch_remove_kprobe(struct kprobe *p)

 static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
 {
+#ifdef CONFIG_BOOKE
+	regs->msr &= ~(MSR_EE); /* Turn off 'Externel Interrupt' bits */
+	regs->msr &= ~(MSR_CE); /* Turn off 'Critical Interrupt' bits */
+	regs->msr |= MSR_DE;
+	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
+#else
 	regs->msr |= MSR_SE;
+#endif

 	/*
 	 * On powerpc we should single step on the original
@@ -158,7 +173,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
 			kprobe_opcode_t insn = *p->ainsn.insn;
 			if (kcb->kprobe_status == KPROBE_HIT_SS &&
 					is_trap(insn)) {
-				regs->msr &= ~MSR_SE;
+				regs->msr &= ~MSR_SINGLESTEP; /* Turn off 'trace' bits */
 				regs->msr |= kcb->kprobe_saved_msr;
 				goto no_kprobe;
 			}
@@ -398,7 +413,7 @@ out:
 	 * will have SE set, in which case, continue the remaining processing
 	 * of do_debug, as if this is not a probe hit.
 	 */
-	if (regs->msr & MSR_SE)
+	if (single_stepping(regs))
 		return 0;

 	return 1;
@@ -421,7 +436,7 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
 		 * normal page fault.
 		 */
 		regs->nip = (unsigned long)cur->addr;
-		regs->msr &= ~MSR_SE;
+		regs->msr &= ~MSR_SINGLESTEP; /* Turn off 'trace' bits */
 		regs->msr |= kcb->kprobe_saved_msr;
 		if (kcb->kprobe_status == KPROBE_REENTER)
 			restore_previous_kprobe(kcb);
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 89aaaa6..6321ae3 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -489,7 +489,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID_CACHE)
  *
  * flush_icache_range(unsigned long start, unsigned long stop)
  */
-_GLOBAL(__flush_icache_range)
+_KPROBE(__flush_icache_range)
 BEGIN_FTR_SECTION
 	blr				/* for 601, do nothing */
 END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 4b5b7ff..985bff5 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -316,10 +316,6 @@ static inline int check_io_access(struct pt_regs *regs)
 #define REASON_PRIVILEGED	ESR_PPR
 #define REASON_TRAP		ESR_PTR

-/* single-step stuff */
-#define single_stepping(regs)	(current->thread.dbcr0 & DBCR0_IC)
-#define clear_single_step(regs)	(current->thread.dbcr0 &= ~DBCR0_IC)
-
 #else
 /* On non-4xx, the reason for the machine check or program
    exception is in the MSR. */
@@ -330,8 +326,6 @@ static inline int check_io_access(struct pt_regs *regs)
 #define REASON_PRIVILEGED	0x40000
 #define REASON_TRAP		0x20000

-#define single_stepping(regs)	((regs)->msr & MSR_SE)
-#define clear_single_step(regs)	((regs)->msr &= ~MSR_SE)
 #endif

 #if defined(CONFIG_4xx)
@@ -1030,21 +1024,29 @@ void SoftwareEmulation(struct pt_regs *regs)

 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)

-void DebugException(struct pt_regs *regs, unsigned long debug_status)
+void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status)
 {
 	if (debug_status & DBSR_IC) {	/* instruction completion */
 		regs->msr &= ~MSR_DE;
+
+		/* Disable instruction completion */
+		mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
+		/* Clear the instruction completion event */
+		mtspr(SPRN_DBSR, DBSR_IC);
+
+		if (notify_die(DIE_SSTEP, "single_step", regs, 5,
+			       5, SIGTRAP) == NOTIFY_STOP) {
+			return;
+		}
+
+		if (debugger_sstep(regs))
+			return;
+
 		if (user_mode(regs)) {
 			current->thread.dbcr0 &= ~DBCR0_IC;
-		} else {
-			/* Disable instruction completion */
-			mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
-			/* Clear the instruction completion event */
-			mtspr(SPRN_DBSR, DBSR_IC);
-			if (debugger_sstep(regs))
-				return;
 		}
-		_exception(SIGTRAP, regs, TRAP_TRACE, 0);
+
+		_exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
 	}
 }
 #endif /* CONFIG_4xx || CONFIG_BOOKE */
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index df781ad..2926e29 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -66,6 +66,15 @@
 struct task_struct;
 struct pt_regs;

+/* single-step stuff */
+#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#define single_stepping(regs)	(current->thread.dbcr0 & DBCR0_IC)
+#define clear_single_step(regs)	(current->thread.dbcr0 &= ~DBCR0_IC)
+#else
+#define single_stepping(regs)	((regs)->msr & MSR_SE)
+#define clear_single_step(regs)	((regs)->msr &= ~MSR_SE)
+#endif
+
 #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)

 extern int (*__debugger)(struct pt_regs *regs);
-- 
1.5.5.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-12 14:29 Sulibhavi, Madhvesh
  0 siblings, 0 replies; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-12 14:29 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

Kumar Gala wrote Wednesday, June 11, 2008 8:36 PM
> To: Sulibhavi, Madhvesh
> Cc: rsmadhvesh@vsnl.net; ananth@in.ibm.com;=20
> linuxppc-dev@ozlabs.org; Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e
>=20
...

> ---------------------------------------------------------------------
> > arch/powerpc/kernel/kprobes.c |   35 ++++++++++++++++++++++++++++++=20
> > +----
> > arch/powerpc/kernel/misc_32.S |    2 +-
> > arch/powerpc/kernel/traps.c   |   26 +++++++++++++++++++++++++-
> > 3 files changed, 57 insertions(+), 6 deletions(-)
>=20
> Your patch got line wrapped by your mailer.  Take a look at =20
> Documentation/email-clients.tx

Yes, i need to correct my emailer (long pending)

>=20
> > static void __kprobes prepare_singlestep(struct kprobe *p, struct
> > pt_regs *regs)
> > {
> > +#ifdef CONFIG_BOOKE
> > +	regs->msr &=3D ~(MSR_EE); /* Turn off 'Externel Interrupt' bits */
> > +	regs->msr &=3D ~(MSR_CE); /* Turn off 'Critical Interrupt' bits */
> > +	regs->msr |=3D MSR_DE;
>=20
> can we remove MSR_EE and MSR_CE here?

Ah! yes? interrupts are enabled while executing the trap
instruction in ppc unlike int3 of x86 where interupts are=20
disabled. kprobe_handler already handles the reentrancy with=20
nmissed count. I think this code can be removed and=20
I will confirm after my test.


-Madhvesh


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-17 13:31 Sulibhavi, Madhvesh
  2008-06-19 16:44 ` Kumar Gala
  0 siblings, 1 reply; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-17 13:31 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh, Kumar Gala; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras

Sulibhavi, Madhvesh wrote on Thursday, June 12, 2008 7:59 PM
> > > static void __kprobes prepare_singlestep(struct kprobe *p, struct
> > > pt_regs *regs)
> > > {
> > > +#ifdef CONFIG_BOOKE
> > > +	regs->msr &=3D ~(MSR_EE); /* Turn off 'Externel Interrupt' bits =
*/
> > > +	regs->msr &=3D ~(MSR_CE); /* Turn off 'Critical Interrupt' bits =
*/
> > > +	regs->msr |=3D MSR_DE;
> >=20
> > can we remove MSR_EE and MSR_CE here?
>=20
> Ah! yes?=20

No!!, this code cannot be removed. My tests fail
while doing the probe test for do_gettimeofday and __kmalloc.
I get Oops and Segfault. I think i had got similar results
in my initial port using 2.6.26.39. Here is the log...

------------------------------------------------------------------------
---------------------------------
/ # modprobe k-008
Oops: Exception in kernel mode, sig: 4 [#1]
Ebony
Modules linked in: k_007 k_006 k_005 k_004 k_003 k_002 k_001
NIP: d100601c LR: c0195bfc CTR: 00000000
REGS: c79e56a0 TRAP: 0700   Not tainted  (2.6.26-rc5-dirty)=20
MSR: 00029200 <EE,ME>  CR: 24022088  XER: 00000000
TASK =3D c7854420[761] 'ash' THREAD: c79e4000
GPR00: 00000000 c79e5750 c7854420 00000000 00000000 00000000 000005bc
00000000
GPR08: 00037eec 00000000 00000092 00008000 00037e5a 1001f184 00000000
fff9ed50
GPR16: 8fa72401 fff837f1 00000000 c0a80001 00000000 00000801 00000000
00000070
GPR24: 00000000 00004000 00004000 00000040 c7997000 c786b3c0 c7a11010
00000000
NIP [d100601c] 0xd100601c
LR [c0195bfc] ip_cork_release+0x28/0x50
Call Trace:
[c79e5750] [c786b3c0] 0xc786b3c0 (unreliable)
[c79e5770] [c01972d4] ip_push_pending_frames+0x308/0x3dc
[c79e57a0] [c01b48d8] udp_push_pending_frames+0x104/0x320
[c79e57d0] [c01b4d3c] udp_sendmsg+0x248/0x59c
[c79e5870] [c01bccfc] inet_sendmsg+0x50/0x78
[c79e5890] [c016ce7c] sock_sendmsg+0xac/0xf4
[c79e5980] [c016d280] kernel_sendmsg+0x2c/0x44
[c79e59a0] [c01d09f4] xs_send_kvec+0x88/0x98
[c79e59e0] [c01d18fc] xs_sendpages+0x7c/0x20c
[c79e5a10] [c01d1f3c] xs_udp_send_request+0x48/0x170
[c79e5a30] [c01cfb60] xprt_transmit+0x64/0x224
[c79e5a60] [c01ce820] call_transmit+0x19c/0x274
[c79e5a80] [c01d456c] __rpc_execute+0x7c/0x29c
[c79e5aa0] [c01ccb38] rpc_run_task+0x68/0x94
[c79e5ac0] [c01ccf80] rpc_call_sync+0x4c/0x7c
[c79e5af0] [c00dc4ac] nfs_proc_getattr+0x6c/0xb0
[c79e5b20] [c00d5cc0] __nfs_revalidate_inode+0xf8/0x234
[c79e5be0] [c00d33ac] nfs_lookup_revalidate+0x2f0/0x388
[c79e5d40] [c0085328] do_lookup+0x54/0x1b8
[c79e5d70] [c0086240] __link_path_walk+0xb38/0xee0
[c79e5dc0] [c00860a8] __link_path_walk+0x9a0/0xee0
[c79e5e10] [c0085508] path_walk+0x7c/0x140
[c79e5e40] [c0086858] do_path_lookup+0x68/0x16c
[c79e5e70] [c0086ee8] __path_lookup_intent_open+0x58/0xc0
[c79e5e90] [c00815a4] open_exec+0x28/0xc8
[c79e5ef0] [c0081c4c] do_execve+0x58/0x1c8
[c79e5f20] [c0005f68] sys_execve+0x50/0x7c
[c79e5f40] [c000c710] ret_from_syscall+0x0/0x3c
Instruction dump:
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
---[ end trace eb93901908c2ca13 ]---
Illegal instructUnable to handle kernel paging request for data at
address 0x744
ion
Faulting instruction address: 0xc0076d64
Oops: Kernel access of bad area, sig: 11 [#2]
Ebony
Modules linked in: k_007 k_006 k_005 k_004 k_003 k_002 k_001
NIP: c0076d64 LR: c0090520 CTR: 00000002
REGS: c79bbe40 TRAP: 0300   Tainted: G      D    (2.6.26-rc5-dirty)
MSR: 00029000 <EE,ME>  CR: 42004024  XER: 00000000
DEAR: 74657374, ESR: 00000000
TASK =3D c7856d60[733] 'ash' THREAD: c79ba000
GPR00: 696e670a c79bbef0 c7856d60 1007a000 74657374 1007a000 10079ffc
00000000
GPR08: 00000000 00004000 c02e6000 c02d0000 82004028 1001f184 00000000
fff9ed50
GPR16: 8fa72401 fff837f1 03f940aa c0240000 c02a0000 00000000 00000000
1007a494
GPR24: 00000002 10075000 00000000 c79bbf10 1007a000 00001002 c79e8000
00000002
NIP [c0076d64] kfree+0x3c/0xc0
LR [c0090520] sys_getcwd+0x124/0x194
Call Trace:
[c79bbef0] [1007a000] 0x1007a000 (unreliable)
[c79bbf00] [c0090520] sys_getcwd+0x124/0x194
[c79bbf40] [c000c710] ret_from_syscall+0x0/0x3c
Instruction dump:
93e1000c 90010014 7c651b78 409d005c 3d60c02d 814b851c 3d234000 5529c9f4
7c09502e 7c895214 70094000 40820074 <80040000> 70090080 41820070
8064000c
---[ end trace eb93901908c2ca13 ]---
Segmentation fault


-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Kprobes for book-e
  2008-06-17 13:31 Sulibhavi, Madhvesh
@ 2008-06-19 16:44 ` Kumar Gala
  0 siblings, 0 replies; 21+ messages in thread
From: Kumar Gala @ 2008-06-19 16:44 UTC (permalink / raw)
  To: Sulibhavi, Madhvesh; +Cc: linuxppc-dev, rsmadhvesh, Paul Mackerras


On Jun 17, 2008, at 8:31 AM, Sulibhavi, Madhvesh wrote:

> Sulibhavi, Madhvesh wrote on Thursday, June 12, 2008 7:59 PM
>>>> static void __kprobes prepare_singlestep(struct kprobe *p, struct
>>>> pt_regs *regs)
>>>> {
>>>> +#ifdef CONFIG_BOOKE
>>>> +	regs->msr &= ~(MSR_EE); /* Turn off 'Externel Interrupt' bits */
>>>> +	regs->msr &= ~(MSR_CE); /* Turn off 'Critical Interrupt' bits */
>>>> +	regs->msr |= MSR_DE;
>>>
>>> can we remove MSR_EE and MSR_CE here?
>>
>> Ah! yes?
>
> No!!, this code cannot be removed. My tests fail
> while doing the probe test for do_gettimeofday and __kmalloc.
> I get Oops and Segfault. I think i had got similar results
> in my initial port using 2.6.26.39. Here is the log...

What is that test.  Can you send it to me.  Its not clear to me why  
this is an issue.

- k

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [RFC] Kprobes for book-e
@ 2008-06-20 15:21 Sulibhavi, Madhvesh
  0 siblings, 0 replies; 21+ messages in thread
From: Sulibhavi, Madhvesh @ 2008-06-20 15:21 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Sulibhavi, Madhvesh, linuxppc-dev, rsmadhvesh, Paul Mackerras

Kumar Gala wrote on Thursday, June 19, 2008 10:15 PM
> To: Sulibhavi, Madhvesh
> > No!!, this code cannot be removed. My tests fail
> > while doing the probe test for do_gettimeofday and __kmalloc.
> > I get Oops and Segfault. I think i had got similar results
> > in my initial port using 2.6.26.39. Here is the log...
>=20
> What is that test.  Can you send it to me.  Its not clear to me why =20
> this is an issue.

My test code is very simple and it is added at the
end of this mail. Brief steps include..

1. Build k-007.c and k-008.c as kernel modules
2. Insert the k-008.ko first=20
3. Insert k-007.ko
4. Do any operation like "ls"
5. Ooops will be seen followed by Segv


-Madhvesh

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
//k-008.c test code

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kprobes.h>
#include <linux/kallsyms.h>
=20
static struct kprobe k_008_kp1;
=20
static void __exit k_008_exit_probe(void)
{
        unregister_kprobe(&k_008_kp1);
}
=20
static int k_008_pre_handler(struct kprobe *k_008_kp1, struct pt_regs
*p)
{
        return 0;
}
=20
static int __init k_008_init_probe(void)
{

        /* Registering a kprobe */
        k_008_kp1.pre_handler =3D (kprobe_pre_handler_t)
k_008_pre_handler;
=20
        k_008_kp1.symbol_name =3D "do_gettimeofday";
=20
        if( register_kprobe(&k_008_kp1) <0 ) {
                printk("k-008.c: register_kprobe is failed\n");
                return -1;
        }
=20
        register_kprobe(&k_008_kp1);
=20
        return 0;
}
=20
module_init(k_008_init_probe);
module_exit(k_008_exit_probe);
=20
MODULE_DESCRIPTION("Kprobes test module");
MODULE_LICENSE("GPL");

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
//k-007.c test code

static struct kprobe k_007_kp, k_007_kp1;
int k_007_kmalloc_count =3D 0;
int k_007_kfree_count =3D 0;
=20
static int k_007_kmalloc_hndlr(struct kprobe *kpr, struct pt_regs *p)
{
        k_007_kmalloc_count++;
        return 0;
}
=20
static int k_007_kfree_hndlr(struct kprobe *kpr, struct pt_regs *p)
{
        k_007_kfree_count++;
        return 0;
}
=20
static int __init k_007_kmf_init(void)
{
        k_007_kp.pre_handler =3D k_007_kmalloc_hndlr;
        k_007_kp1.pre_handler =3D k_007_kfree_hndlr;
=20
        k_007_kp.symbol_name =3D "__kmalloc";
        k_007_kp1.symbol_name =3D "kfree";
=20
        if( (register_kprobe(&k_007_kp) <0) ||
(register_kprobe(&k_007_kp1) <0) ) {
                printk("k-007.c: register_kprobe is failed\n");
                return -1;
        }
=20
        return 0;
}
=20
static void __exit k_007_kmf_exit(void)
{
        printk("%%%%%%%%%%%%%%%%%%%%%%%%%\n\n");
        printk("kmalloc count is %d \n", k_007_kmalloc_count);
        printk("kfree count is %d \n", k_007_kfree_count);
        printk("\n\n\n%%%%%%%%%%%%%%%%%%%%%%\n");
        unregister_kprobe(&k_007_kp);
        unregister_kprobe(&k_007_kp1);
        printk(KERN_INFO "k-007 exiting...\n");
}
=20
module_init(k_007_kmf_init);
module_exit(k_007_kmf_exit);
MODULE_LICENSE("GPL");
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D







-------------------------------------------------------------------
This email is confidential and intended only for the use of the =
individual or entity named above and may contain information that is =
privileged. If you are not the intended recipient, you are notified that =
any dissemination, distribution or copying of this email is strictly =
prohibited. If you have received this email in error, please notify us =
immediately by return email or telephone and destroy the original =
message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2008-06-20 15:21 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-03 14:48 [RFC] Kprobes for book-e Sulibhavi, Madhvesh
2008-06-03 14:46 ` Josh Boyer
  -- strict thread matches above, loose matches on Subject: below --
2008-06-20 15:21 Sulibhavi, Madhvesh
2008-06-17 13:31 Sulibhavi, Madhvesh
2008-06-19 16:44 ` Kumar Gala
2008-06-12 14:29 Sulibhavi, Madhvesh
2008-06-11 14:18 Sulibhavi, Madhvesh
2008-06-11 15:05 ` Kumar Gala
2008-06-11 15:59   ` Kumar Gala
2008-06-09 14:10 Sulibhavi, Madhvesh
2008-06-03 15:01 Sulibhavi, Madhvesh
2008-06-03 14:39 Sulibhavi, Madhvesh
2008-06-03 14:10 Sulibhavi, Madhvesh
2008-06-03 14:18 ` Josh Boyer
2008-06-03 14:37   ` Kumar Gala
2008-06-03  8:23 Sulibhavi, Madhvesh
2008-06-03 11:52 ` Josh Boyer
2008-06-03 15:46 ` Kumar Gala
2008-06-03  5:30 Kumar Gala
2008-06-03  5:48 ` Ananth N Mavinakayanahalli
2008-06-03  5:50   ` Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).