-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv/ftrace: Add dynamic function tracer support
We now have dynamic ftrace with the following added items: * ftrace_make_call, ftrace_make_nop (in kernel/ftrace.c) The two functions turn each recorded call site of filtered functions into a call to ftrace_caller or nops * ftracce_update_ftrace_func (in kernel/ftrace.c) turns the nops at ftrace_call into a call to a generic entry for function tracers. * ftrace_caller (in kernel/mcount-dyn.S) The entry where each _mcount call sites calls to once they are filtered to be traced. Also, this patch fixes the semantic problems in mcount.S, which will be treated as only a reference implementation once we have the dynamic ftrace. Cc: Greentime Hu <greentime@andestech.com> Signed-off-by: Alan Kao <alankao@andestech.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
- Loading branch information
Alan Kao
authored and
Palmer Dabbelt
committed
Apr 3, 2018
1 parent
a1d2a6b
commit c15ac4f
Showing
6 changed files
with
223 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (C) 2017 Andes Technology Corporation */ | ||
|
||
#include <linux/init.h> | ||
#include <linux/linkage.h> | ||
#include <asm/asm.h> | ||
#include <asm/csr.h> | ||
#include <asm/unistd.h> | ||
#include <asm/thread_info.h> | ||
#include <asm/asm-offsets.h> | ||
#include <asm-generic/export.h> | ||
#include <asm/ftrace.h> | ||
|
||
.text | ||
|
||
.macro SAVE_ABI_STATE | ||
addi sp, sp, -16 | ||
sd s0, 0(sp) | ||
sd ra, 8(sp) | ||
addi s0, sp, 16 | ||
.endm | ||
|
||
.macro RESTORE_ABI_STATE | ||
ld ra, 8(sp) | ||
ld s0, 0(sp) | ||
addi sp, sp, 16 | ||
.endm | ||
|
||
ENTRY(ftrace_caller) | ||
/* | ||
* a0: the address in the caller when calling ftrace_caller | ||
* a1: the caller's return address | ||
*/ | ||
ld a1, -8(s0) | ||
addi a0, ra, -MCOUNT_INSN_SIZE | ||
SAVE_ABI_STATE | ||
ftrace_call: | ||
.global ftrace_call | ||
/* | ||
* For the dynamic ftrace to work, here we should reserve at least | ||
* 8 bytes for a functional auipc-jalr pair. The following call | ||
* serves this purpose. | ||
* | ||
* Calling ftrace_update_ftrace_func would overwrite the nops below. | ||
* Check ftrace_modify_all_code for details. | ||
*/ | ||
call ftrace_stub | ||
RESTORE_ABI_STATE | ||
ret | ||
ENDPROC(ftrace_caller) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters