Skip to content

Commit 10cb1e3

Browse files
author
Fox Snowpatch
committed
1 parent 960c1fd commit 10cb1e3

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

arch/powerpc/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ config ARCH_USING_PATCHABLE_FUNCTION_ENTRY
571571
depends on FUNCTION_TRACER && (PPC32 || PPC64_ELF_ABI_V2)
572572
depends on $(cc-option,-fpatchable-function-entry=2)
573573
def_bool y if PPC32
574-
def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh $(CC) -mlittle-endian) if PPC64 && CPU_LITTLE_ENDIAN
575-
def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh $(CC) -mbig-endian) if PPC64 && CPU_BIG_ENDIAN
574+
def_bool $(success,$(srctree)/arch/powerpc/tools/check-fpatchable-function-entry.sh $(CC) $(CLANG_FLAGS) -mlittle-endian) if PPC64 && CPU_LITTLE_ENDIAN
575+
def_bool $(success,$(srctree)/arch/powerpc/tools/check-fpatchable-function-entry.sh $(CC) -mbig-endian) if PPC64 && CPU_BIG_ENDIAN
576576

577577
config PPC_FTRACE_OUT_OF_LINE
578578
def_bool PPC64 && ARCH_USING_PATCHABLE_FUNCTION_ENTRY

arch/powerpc/kernel/trace/ftrace.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,29 @@ unsigned long ftrace_call_adjust(unsigned long addr)
3737
if (addr >= (unsigned long)__exittext_begin && addr < (unsigned long)__exittext_end)
3838
return 0;
3939

40-
if (IS_ENABLED(CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY) &&
41-
!IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {
42-
addr += MCOUNT_INSN_SIZE;
43-
if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
40+
if (IS_ENABLED(CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY)) {
41+
if (!IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {
4442
addr += MCOUNT_INSN_SIZE;
43+
if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
44+
addr += MCOUNT_INSN_SIZE;
45+
} else if (IS_ENABLED(CONFIG_CC_IS_CLANG) && IS_ENABLED(CONFIG_PPC64)) {
46+
/*
47+
* addr points to global entry point though the NOP was emitted at local
48+
* entry point due to https://github.com/llvm/llvm-project/issues/163706
49+
* Handle that here with ppc_function_entry() for kernel symbols while
50+
* adjusting module addresses in the else case, by looking for the below
51+
* module global entry point sequence:
52+
* ld r2, -8(r12)
53+
* add r2, r2, r12
54+
*/
55+
if (is_kernel_text(addr) || is_kernel_inittext(addr))
56+
addr = ppc_function_entry((void *)addr);
57+
else if ((ppc_inst_val(ppc_inst_read((u32 *)addr)) ==
58+
PPC_RAW_LD(_R2, _R12, -8)) &&
59+
(ppc_inst_val(ppc_inst_read((u32 *)(addr+4))) ==
60+
PPC_RAW_ADD(_R2, _R2, _R12)))
61+
addr += 8;
62+
}
4563
}
4664

4765
return addr;

arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh renamed to arch/powerpc/tools/check-fpatchable-function-entry.sh

File renamed without changes.

arch/powerpc/tools/ftrace-gen-ool-stubs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ if [ -z "$is_64bit" ]; then
1515
RELOCATION=R_PPC_ADDR32
1616
fi
1717

18-
num_ool_stubs_total=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
18+
num_ool_stubs_total=$($objdump -r -j __patchable_function_entries -d "$vmlinux_o" |
1919
grep -c "$RELOCATION")
20-
num_ool_stubs_inittext=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
20+
num_ool_stubs_inittext=$($objdump -r -j __patchable_function_entries -d "$vmlinux_o" |
2121
grep -e ".init.text" -e ".text.startup" | grep -c "$RELOCATION")
2222
num_ool_stubs_text=$((num_ool_stubs_total - num_ool_stubs_inittext))
2323

0 commit comments

Comments
 (0)