Skip to contentSkip to conversation

help with ppc sections?

DISCUSSION Chris Friesen 3 participants 5 messages Jul 26, 2007 – Aug 8, 2007

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 6 lines · Chris Friesen

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?!? :-)

Quoted 6 lines

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.

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
[email protected]
(403) 399-0195
#2 lore raw
Quoted 2 lines · Grant Likely

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 5 lines
Quoted 2 lines

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

include/asm-ppc/processor.h +7 -0
Index: 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:
#3 lore raw
Quoted 3 lines

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

#4 lore raw

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

In reply to Chris Friesen

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

include/asm-ppc/processor.h +11 -0
Index: linux/include/asm-ppc/processor.h
===================================================================
@@ -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
arch/ppc/kernel/misc.S +1 -1
Index: linux/arch/ppc/kernel/misc.S
===================================================================
@@ -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