lkml.org 
[lkml]   [2020]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 8/8] riscv: add two hook functions of ftrace
    Date
    After the text section be mask as non-writable, the ftrace have to
    change the permission of text for dynamic patching the intructions.
    Add ftrace_arch_code_modify_prepare and
    ftrace_arch_code_modify_post_process to change permission.

    Signed-off-by: Zong Li <zong.li@sifive.com>
    ---
    arch/riscv/kernel/ftrace.c | 18 ++++++++++++++++++
    1 file changed, 18 insertions(+)

    diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
    index c40fdcdeb950..576df0807200 100644
    --- a/arch/riscv/kernel/ftrace.c
    +++ b/arch/riscv/kernel/ftrace.c
    @@ -7,9 +7,27 @@

    #include <linux/ftrace.h>
    #include <linux/uaccess.h>
    +#include <linux/memory.h>
    +#include <asm/set_memory.h>
    #include <asm/cacheflush.h>

    #ifdef CONFIG_DYNAMIC_FTRACE
    +int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
    +{
    + mutex_lock(&text_mutex);
    + set_kernel_text_rw();
    + set_all_modules_text_rw();
    + return 0;
    +}
    +
    +int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
    +{
    + set_all_modules_text_ro();
    + set_kernel_text_ro();
    + mutex_unlock(&text_mutex);
    + return 0;
    +}
    +
    static int ftrace_check_current_call(unsigned long hook_pos,
    unsigned int *expected)
    {
    --
    2.25.0
    \
     
     \ /
      Last update: 2020-02-17 09:33    [W:3.941 / U:0.364 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site