LoongArch: modules/ftrace: Initialize PLT at load time
authorQing Zhang <zhangqing@loongson.cn>
Sat, 10 Dec 2022 14:40:21 +0000 (22:40 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 14 Dec 2022 00:41:54 +0000 (08:41 +0800)
commit28ac0a9e04d7dfb42220dc9d221164d93f20fb3a
tree520a7c5f68595d38a141a7866846f4cf40f19c1e
parenta51ac5246d2505b58229242959d2bc73d113ca50
LoongArch: modules/ftrace: Initialize PLT at load time

This patch implements ftrace trampolines through plt entry.

Tested by forcing ftrace_make_call() to use the module PLT, and then
loading up a module after setting up ftrace with:

| echo ":mod:<module-name>" > set_ftrace_filter;
| echo function > current_tracer;
| modprobe <module-name>

Since FTRACE_ADDR/FTRACE_REGS_ADDR is only defined when CONFIG_DYNAMIC_
FTRACE is selected, we wrap their usage in module_init_ftrace_plt() with
ifdeffery rather than using IS_ENABLED().

Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/ftrace.h
arch/loongarch/include/asm/inst.h
arch/loongarch/include/asm/module.h
arch/loongarch/include/asm/module.lds.h
arch/loongarch/kernel/ftrace_dyn.c
arch/loongarch/kernel/inst.c
arch/loongarch/kernel/module-sections.c
arch/loongarch/kernel/module.c