Skip to content

Commit 6f698df

Browse files
npigginmpe
authored andcommitted
powerpc/kernel: Use kprobe blacklist for asm functions
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 03465f8 commit 6f698df

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

arch/powerpc/include/asm/ppc_asm.h

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,6 @@ name: \
217217
addi r2,r2,(.TOC.-0b)@l; \
218218
.localentry name,.-name
219219

220-
#define _KPROBE(name) \
221-
.section ".kprobes.text","a"; \
222-
.align 2 ; \
223-
.type name,@function; \
224-
.globl name; \
225-
name:
226-
227220
#define DOTSYM(a) a
228221

229222
#else
@@ -247,20 +240,6 @@ GLUE(.,name):
247240

248241
#define _GLOBAL_TOC(name) _GLOBAL(name)
249242

250-
#define _KPROBE(name) \
251-
.section ".kprobes.text","a"; \
252-
.align 2 ; \
253-
.globl name; \
254-
.globl GLUE(.,name); \
255-
.section ".opd","aw"; \
256-
name: \
257-
.quad GLUE(.,name); \
258-
.quad .TOC.@tocbase; \
259-
.quad 0; \
260-
.previous; \
261-
.type GLUE(.,name),@function; \
262-
GLUE(.,name):
263-
264243
#define DOTSYM(a) GLUE(.,a)
265244

266245
#endif
@@ -279,13 +258,22 @@ GLUE(.,name):
279258

280259
#define _GLOBAL_TOC(name) _GLOBAL(name)
281260

282-
#define _KPROBE(n) \
283-
.section ".kprobes.text","a"; \
284-
.globl n; \
285-
n:
286-
287261
#endif
288262

263+
/*
264+
* __kprobes (the C annotation) puts the symbol into the .kprobes.text
265+
* section, which gets emitted at the end of regular text.
266+
*
267+
* _ASM_NOKPROBE_SYMBOL and NOKPROBE_SYMBOL just adds the symbol to
268+
* a blacklist. The former is for core kprobe functions/data, the
269+
* latter is for those that incdentially must be excluded from probing
270+
* and allows them to be linked at more optimal location within text.
271+
*/
272+
#define _ASM_NOKPROBE_SYMBOL(entry) \
273+
.pushsection "_kprobe_blacklist","aw"; \
274+
PPC_LONG (entry) ; \
275+
.popsection
276+
289277
#define FUNC_START(name) _GLOBAL(name)
290278
#define FUNC_END(name)
291279

arch/powerpc/kernel/misc_32.S

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID_CACHE)
328328
*
329329
* flush_icache_range(unsigned long start, unsigned long stop)
330330
*/
331-
_KPROBE(flush_icache_range)
331+
_GLOBAL(flush_icache_range)
332332
BEGIN_FTR_SECTION
333333
PURGE_PREFETCHED_INS
334334
blr /* for 601, do nothing */
@@ -358,6 +358,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
358358
sync /* additional sync needed on g4 */
359359
isync
360360
blr
361+
_ASM_NOKPROBE_SYMBOL(flush_icache_range)
362+
361363
/*
362364
* Flush a particular page from the data cache to RAM.
363365
* Note: this is necessary because the instruction cache does *not*

arch/powerpc/kernel/misc_64.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PPC64_CACHES:
6666
* flush all bytes from start through stop-1 inclusive
6767
*/
6868

69-
_KPROBE(flush_icache_range)
69+
_GLOBAL(flush_icache_range)
7070
BEGIN_FTR_SECTION
7171
PURGE_PREFETCHED_INS
7272
blr
@@ -109,7 +109,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
109109
bdnz 2b
110110
isync
111111
blr
112-
.previous .text
112+
_ASM_NOKPROBE_SYMBOL(flush_icache_range)
113+
113114
/*
114115
* Like above, but only do the D-cache.
115116
*

0 commit comments

Comments
 (0)