]> git.hungrycats.org Git - linux/commitdiff
powerpc/kernel: Use kprobe blacklist for asm functions
authorNicholas Piggin <npiggin@gmail.com>
Fri, 16 Sep 2016 10:48:17 +0000 (20:48 +1000)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 18 Jul 2017 17:40:30 +0000 (18:40 +0100)
commit 6f698df10cb24d466b9a790b9daedb9e7bcd5d2a upstream.

Rather than forcing the whole function into the ".kprobes.text" section,
just add the symbol's address to the kprobe blacklist.

This also lets us drop the three versions of the_KPROBE macro, in
exchange for just one version of _ASM_NOKPROBE_SYMBOL - which is a good
cleanup.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/powerpc/include/asm/ppc_asm.h
arch/powerpc/kernel/misc_32.S
arch/powerpc/kernel/misc_64.S

index 7e4612528546b710cb13d7b9346d394d5cd4d99e..6d23045555c684064e28fe273966b71295b847d6 100644 (file)
@@ -217,13 +217,6 @@ name: \
        addi r2,r2,(.TOC.-0b)@l; \
        .localentry name,.-name
 
-#define _KPROBE(name) \
-       .section ".kprobes.text","a"; \
-       .align 2 ; \
-       .type name,@function; \
-       .globl name; \
-name:
-
 #define DOTSYM(a)      a
 
 #else
@@ -247,20 +240,6 @@ GLUE(.,name):
 
 #define _GLOBAL_TOC(name) _GLOBAL(name)
 
-#define _KPROBE(name) \
-       .section ".kprobes.text","a"; \
-       .align 2 ; \
-       .globl name; \
-       .globl GLUE(.,name); \
-       .section ".opd","aw"; \
-name: \
-       .quad GLUE(.,name); \
-       .quad .TOC.@tocbase; \
-       .quad 0; \
-       .previous; \
-       .type GLUE(.,name),@function; \
-GLUE(.,name):
-
 #define DOTSYM(a)      GLUE(.,a)
 
 #endif
@@ -279,13 +258,22 @@ n:
 
 #define _GLOBAL_TOC(name) _GLOBAL(name)
 
-#define _KPROBE(n)     \
-       .section ".kprobes.text","a";   \
-       .globl  n;      \
-n:
-
 #endif
 
+/*
+ * __kprobes (the C annotation) puts the symbol into the .kprobes.text
+ * section, which gets emitted at the end of regular text.
+ *
+ * _ASM_NOKPROBE_SYMBOL and NOKPROBE_SYMBOL just adds the symbol to
+ * a blacklist. The former is for core kprobe functions/data, the
+ * latter is for those that incdentially must be excluded from probing
+ * and allows them to be linked at more optimal location within text.
+ */
+#define _ASM_NOKPROBE_SYMBOL(entry)                    \
+       .pushsection "_kprobe_blacklist","aw";          \
+       PPC_LONG (entry) ;                              \
+       .popsection
+
 /* 
  * LOAD_REG_IMMEDIATE(rn, expr)
  *   Loads the value of the constant expression 'expr' into register 'rn'
index 2c70bbcb006f3cca99f384ce4dd5444731222c09..0703738d092f0bd126341a2f301e8cc828230fce 100644 (file)
@@ -345,7 +345,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID_CACHE)
  *
  * flush_icache_range(unsigned long start, unsigned long stop)
  */
-_KPROBE(flush_icache_range)
+_GLOBAL(flush_icache_range)
 BEGIN_FTR_SECTION
        PURGE_PREFETCHED_INS
        blr                             /* for 601, do nothing */
@@ -376,6 +376,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
        sync                            /* additional sync needed on g4 */
        isync
        blr
+_ASM_NOKPROBE_SYMBOL(flush_icache_range)
+
 /*
  * Write any modified data cache blocks out to memory.
  * Does not invalidate the corresponding cache lines (especially for
index 4e314b90c75d699edda82589c8a5a983bcc5dc6e..7f0f06d788b6b9cf5082903c93b0497c49501155 100644 (file)
@@ -65,7 +65,7 @@ PPC64_CACHES:
  *   flush all bytes from start through stop-1 inclusive
  */
 
-_KPROBE(flush_icache_range)
+_GLOBAL(flush_icache_range)
 BEGIN_FTR_SECTION
        PURGE_PREFETCHED_INS
        blr
@@ -108,7 +108,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
        bdnz    2b
        isync
        blr
-       .previous .text
+_ASM_NOKPROBE_SYMBOL(flush_icache_range)
+
 /*
  * Like above, but only do the D-cache.
  *