help with ppc sections?

5 messages, 3 authors, 2007-08-08 · open the first message on its own page

help with ppc sections?

From: Chris Friesen <hidden>
Date: 2007-07-26 19:38:12

Hi all,

I'm porting kprobes to 2.6.14, and I think I've got it mostly done.  The 
last thing that I want to do is to mark flush_icache_range() as part of 
the .kprobes.text section so that we don't accidently try to probe it.

On ppc64 this was done by duplicating the _GLOBAL macro and just 
modifying the ".section" line.

Unfortunately for me, ppc doesn't have a ".section" line in that macro, 
so I'm at a bit of a loss.

Anyone got any suggestions, or pointers on where I could read up on it?

Chris

Re: help with ppc sections?

From: Grant Likely <hidden>
Date: 2007-07-26 19:55:36

On 7/26/07, Chris Friesen [off-list ref] wrote:
Hi all,

I'm porting kprobes to 2.6.14, and I think I've got it mostly done.  The
last thing that I want to do is to mark flush_icache_range() as part of
the .kprobes.text section so that we don't accidently try to probe it.
Hey Chris,

Mild question; What the *@*#^$! are you doing trying to backport to a
2 year old kernel?!?  :-)

On ppc64 this was done by duplicating the _GLOBAL macro and just
modifying the ".section" line.

Unfortunately for me, ppc doesn't have a ".section" line in that macro,
so I'm at a bit of a loss.
Just add the section.  Should be trivial to do.  You might have to add
it to the linker script as well.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

Re: help with ppc sections?

From: Chris Friesen <hidden>
Date: 2007-07-27 18:56:04

Grant Likely wrote:
Mild question; What the *@*#^$! are you doing trying to backport to a
2 year old kernel?!?  :-)
That's what happens in the embedded space.  It's the current version 
from our distro vendor.  It's also the version that all our different 
board suppliers could agree to provide support for.

Of course, it's also a royal pain.
quoted
Unfortunately for me, ppc doesn't have a ".section" line in that macro,
so I'm at a bit of a loss.
Just add the section.  Should be trivial to do.  You might have to add
it to the linker script as well.
I've done the linker script part already.  As for the processor.h bit, 
does this seem reasonable?  It seems to do the trick based on the 
function addresses, but I may be missing something and I haven't 
actually booted it yet.

The ppc64 version appends ',"a"' to the kprobes.text section line.  Is 
this needed here as well?  Could someone elaborate on exactly what its 
purpose is?

Thanks,

Chris


Index: linux-ias/include/asm-ppc/processor.h
===================================================================
--- linux-ias.orig/include/asm-ppc/processor.h
+++ linux-ias/include/asm-ppc/processor.h
@@ -38,6 +38,13 @@

  #define _GLOBAL(n)\
  	.stabs __stringify(n:F-1),N_FUN,0,0,n;\
+	.section ".text"; \
+	.globl n;\
+n:
+
+#define _KPROBE(n)\
+	.stabs __stringify(n:F-1),N_FUN,0,0,n;\
+	.section ".kprobes.text","a"; \
  	.globl n;\
  n:

Re: help with ppc sections?

From: Segher Boessenkool <hidden>
Date: 2007-07-31 16:38:18

The ppc64 version appends ',"a"' to the kprobes.text section line.  Is
this needed here as well?  Could someone elaborate on exactly what its
purpose is?
It's the (ELF) section attributes for the section.  If this
is executable code, it should be "ax"; if it's writable, it
should be "wa"; if it's not initialised, it should be "".

If the section name followed the normal naming conventions,
(newer) GCC could figure out the section attributes itself;
but then, ".text.kprobes" would imply executable, maybe the
section is really misnamed?  Or maybe you need the "ax"
flags :-)


Segher

Re: help with ppc sections -- no luck, any ideas?

From: Chris Friesen <hidden>
Date: 2007-08-08 16:24:35

Well, I've played around with the sections a bit more, and just can't 
seem to get it to work.  As soon as I apply the following, the kernel 
refuses to boot.  (And if I remove the changes to _GLOBAL, then it 
refuses to boot if I enable CONFIG_KPROBES.)


Index: linux/include/asm-ppc/processor.h
===================================================================
--- linux.orig/include/asm-ppc/processor.h	2007-08-02 16:12:16.000000000 
-0600
+++ linux/include/asm-ppc/processor.h	2007-08-02 16:26:06.000000000 -0600
@@ -38,9 +38,20 @@

  #define _GLOBAL(n)\
  	.stabs __stringify(n:F-1),N_FUN,0,0,n;\
+	.section ".text"; \
  	.globl n;\
  n:

+#ifdef CONFIG_KPROBES
+#define _KPROBE(n)\
+	.stabs __stringify(n:F-1),N_FUN,0,0,n;\
+	.section ".kprobes.text","a"; \
+	.globl n;\
+n:
+#else
+#define _KPROBE(n) _GLOBAL(n)
+#endif
+
  /*
   * this is the minimum allowable io space due to the location
   * of the io areas on prep (first one at 0x80000000) but
Index: linux/arch/ppc/kernel/misc.S
===================================================================
--- linux.orig/arch/ppc/kernel/misc.S	2007-08-02 16:12:16.000000000 -0600
+++ linux/arch/ppc/kernel/misc.S	2007-08-02 16:24:43.000000000 -0600
@@ -624,7 +624,7 @@
   *
   * 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_IFCLR(CPU_FTR_SPLIT_ID_CACHE)




Based on Segher's comments I tried changing it to:

+	.section ".text","ax"; \


but that didn't work either.


Anyone else got any suggestions on how I might force 
flush_icache_range() into a ".kprobes.text" section?

Chris
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help