RE: [RFC] Kprobes for book-e

2008-06-20 Thread Sulibhavi, Madhvesh
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...
> 
> What is that test.  Can you send it to me.  Its not clear to me why  
> 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 
3. Insert k-007.ko
4. Do any operation like "ls"
5. Ooops will be seen followed by Segv


-Madhvesh

=
//k-008.c test code

#include 
#include 
#include 
#include 
 
static struct kprobe k_008_kp1;
 
static void __exit k_008_exit_probe(void)
{
unregister_kprobe(&k_008_kp1);
}
 
static int k_008_pre_handler(struct kprobe *k_008_kp1, struct pt_regs
*p)
{
return 0;
}
 
static int __init k_008_init_probe(void)
{

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

=
//k-007.c test code

static struct kprobe k_007_kp, k_007_kp1;
int k_007_kmalloc_count = 0;
int k_007_kfree_count = 0;
 
static int k_007_kmalloc_hndlr(struct kprobe *kpr, struct pt_regs *p)
{
k_007_kmalloc_count++;
return 0;
}
 
static int k_007_kfree_hndlr(struct kprobe *kpr, struct pt_regs *p)
{
k_007_kfree_count++;
return 0;
}
 
static int __init k_007_kmf_init(void)
{
k_007_kp.pre_handler = k_007_kmalloc_hndlr;
k_007_kp1.pre_handler = k_007_kfree_hndlr;
 
k_007_kp.symbol_name = "__kmalloc";
k_007_kp1.symbol_name = "kfree";
 
if( (register_kprobe(&k_007_kp) <0) ||
(register_kprobe(&k_007_kp1) <0) ) {
printk("k-007.c: register_kprobe is failed\n");
return -1;
}
 
return 0;
}
 
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");
}
 
module_init(k_007_kmf_init);
module_exit(k_007_kmf_exit);
MODULE_LICENSE("GPL");
===







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

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-19 Thread Kumar Gala


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
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [RFC] Kprobes for book-e

2008-06-17 Thread Sulibhavi, Madhvesh
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...


-
/ # 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: 
REGS: c79e56a0 TRAP: 0700   Not tainted  (2.6.26-rc5-dirty) 
MSR: 00029200   CR: 24022088  XER: 
TASK = c7854420[761] 'ash' THREAD: c79e4000
GPR00:  c79e5750 c7854420    05bc

GPR08: 00037eec  0092 8000 00037e5a 1001f184 
fff9ed50
GPR16: 8fa72401 fff837f1  c0a80001  0801 
0070
GPR24:  4000 4000 0040 c7997000 c786b3c0 c7a11010

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:
       
       
---[ 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: 0002
REGS: c79bbe40 TRAP: 0300   Tainted: G  D(2.6.26-rc5-dirty)
MSR: 00029000   CR: 42004024  XER: 
DEAR: 74657374, ESR: 
TASK = c7856d60[733] 'ash' THREAD: c79ba000
GPR00: 696e670a c79bbef0 c7856d60 1007a000 74657374 1007a000 10079ffc

GPR08:  4000 c02e6000 c02d 82004028 1001f184 
fff9ed50
GPR16: 8fa72401 fff837f1 03f940aa c024 c02a  
1007a494
GPR24: 0002 10075000  c79bbf10 1007a000 1002 c79e8000
0002
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 <8004> 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.
---

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listin

RE: [RFC] Kprobes for book-e

2008-06-12 Thread Sulibhavi, Madhvesh
Kumar Gala wrote Wednesday, June 11, 2008 8:36 PM
> To: Sulibhavi, Madhvesh
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
> linuxppc-dev@ozlabs.org; Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e
> 
...

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

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

> 
> > 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? interrupts are enabled while executing the trap
instruction in ppc unlike int3 of x86 where interupts are 
disabled. kprobe_handler already handles the reentrancy with 
nmissed count. I think this code can be removed and 
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.
---

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-11 Thread Kumar Gala

---

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 
 #include 
 #include 
+#include 
+
+#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 896..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_TRAPESR_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  0x4
 #define REASON_TRAP0x2

-#define single_stepping(regs)  ((regs)->msr &

Re: [RFC] Kprobes for book-e

2008-06-11 Thread Kumar Gala


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
sele

RE: [RFC] Kprobes for book-e

2008-06-11 Thread Sulibhavi, Madhvesh
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?

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.

-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
===
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -35,6 +35,21 @@
 #include 
 #include 
 
+
+#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
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 not 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
 
 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 +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 instruc

RE: [RFC] Kprobes for book-e

2008-06-09 Thread Sulibhavi, Madhvesh
Kumar Gala wrote on Tuesday, June 03, 2008 9:16 PM
> To: Sulibhavi, Madhvesh
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
> linuxppc-dev@ozlabs.org; Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e

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

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

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

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-03 Thread Kumar Gala


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
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [RFC] Kprobes for book-e

2008-06-03 Thread Sulibhavi, Madhvesh
> -Original Message-
> From: Josh Boyer [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 03, 2008 8:17 PM
> To: Sulibhavi, Madhvesh
> Cc: Kumar Gala; linuxppc-dev@ozlabs.org; [EMAIL PROTECTED]; 
> 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
> 
> 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.
This message is annoying for anyone. I don't have much
control on its removal and in some lists, it was accepted 
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.
---

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-03 Thread Josh Boyer
On Tue, 3 Jun 2008 20:18:01 +0530
"Sulibhavi, Madhvesh" <[EMAIL PROTECTED]> wrote:

> > -Original Message-
> > From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> > Sent: Tuesday, June 03, 2008 8:08 PM
> > To: Josh Boyer
> > Cc: Sulibhavi, Madhvesh; linuxppc-dev@ozlabs.org; 
> > [EMAIL PROTECTED]; 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/msg8.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.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [RFC] Kprobes for book-e

2008-06-03 Thread Sulibhavi, Madhvesh
> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 03, 2008 8:08 PM
> To: Josh Boyer
> Cc: Sulibhavi, Madhvesh; linuxppc-dev@ozlabs.org; 
> [EMAIL PROTECTED]; 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/msg8.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..

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

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-03 Thread Kumar Gala


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


On Tue, 3 Jun 2008 19:40:55 +0530
"Sulibhavi, Madhvesh" <[EMAIL PROTECTED]> 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 0xc000 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/msg8.html

- k



josh


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [RFC] Kprobes for book-e

2008-06-03 Thread Sulibhavi, Madhvesh
> From: Josh Boyer [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 03, 2008 7:49 PM
> To: Sulibhavi, Madhvesh
> Cc: Kumar Gala; linuxppc-dev@ozlabs.org; [EMAIL PROTECTED]; 
> Paul Mackerras
> Subject: Re: [RFC] Kprobes for book-e
> 
> 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.
---

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-03 Thread Josh Boyer
On Tue, 3 Jun 2008 19:40:55 +0530
"Sulibhavi, Madhvesh" <[EMAIL PROTECTED]> 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 0xc000 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
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [RFC] Kprobes for book-e

2008-06-03 Thread Sulibhavi, Madhvesh
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 0xc000 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
--


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

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-03 Thread Josh Boyer
On Tue, 3 Jun 2008 13:53:37 +0530
"Sulibhavi, Madhvesh" <[EMAIL PROTECTED]> 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
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [RFC] Kprobes for book-e

2008-06-03 Thread Sulibhavi, Madhvesh
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.

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


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.

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

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-02 Thread Kumar Gala


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

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] Kprobes for book-e

2008-06-02 Thread Ananth N Mavinakayanahalli
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
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC] Kprobes for book-e

2008-06-02 Thread Kumar Gala
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 
 #include 

+
+#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 896..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) {