[PATCH v2 02/25] powerpc/ftrace: Remove redundant create_branch() calls

2022-05-06 Thread Christophe Leroy
Since commit d5937db114e4 ("powerpc/code-patching: Fix patch_branch() return on out-of-range failure") patch_branch() fails with -ERANGE when trying to branch out of range. No need to perform the test twice. Remove redundant create_branch() calls. Signed-off-by: Christophe Leroy --- arch/powerp

[PATCH v2 10/25] powerpc: Finalise cleanup around ABI use

2022-05-06 Thread Christophe Leroy
Now that we have CONFIG_PPC64_ELF_ABI_V1 and CONFIG_PPC64_ELF_ABI_V2, get rid of all indirect detection of ABI version. Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig| 2 +- arch/powerpc/Makefile | 2 +- arch/powerpc/include/asm/types.h| 8

[PATCH v2 00/25] powerpc: ftrace optimisation and cleanup and more [v2]

2022-05-06 Thread Christophe Leroy
This series provides optimisation and cleanup of ftrace on powerpc. With this series ftrace activation is about 20% faster on an 8xx. At the end of the series come additional cleanups around ppc-opcode, that would likely conflict with this series if posted separately. Main changes since v1 (deta

[PATCH v2 13/25] powerpc/ftrace: Use CONFIG_FUNCTION_TRACER instead of CONFIG_DYNAMIC_FTRACE

2022-05-06 Thread Christophe Leroy
Since commit 0c0c52306f47 ("powerpc: Only support DYNAMIC_FTRACE not static"), CONFIG_DYNAMIC_FTRACE is always selected when CONFIG_FUNCTION_TRACER is selected. To avoid confusion and have the reader wonder what's happen when CONFIG_FUNCTION_TRACER is selected and CONFIG_DYNAMIC_FTRACE is not, use

[PATCH v2 05/25] powerpc/code-patching: Inline create_branch()

2022-05-06 Thread Christophe Leroy
create_branch() is a good candidate for inlining because: - Flags can be folded in. - Range tests are likely to be already done. Hence reducing the create_branch() to only a set of instructions. So inline it. It improves ftrace activation by 10%. Signed-off-by: Christophe Leroy --- arch/power

[PATCH v2 20/25] powerpc/inst: Add __copy_inst_from_kernel_nofault()

2022-05-06 Thread Christophe Leroy
On the same model as get_user() versus __get_user(), introduce __copy_inst_from_kernel_nofault() which doesn't check address. To be used by callers that have already checked that the adress is a kernel address. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/inst.h | 13 +--

[PATCH v2 12/25] powerpc/ftrace: Don't include ftrace.o for CONFIG_FTRACE_SYSCALLS

2022-05-06 Thread Christophe Leroy
Since commit 7bea7ac0ca01 ("powerpc/syscalls: Fix syscall tracing") ftrace.o is not needed anymore for CONFIG_FTRACE_SYSCALLS. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kernel/trace/Makefile b/arch/powe

[PATCH v2 22/25] powerpc/inst: Remove PPC_INST_BRANCH

2022-05-06 Thread Christophe Leroy
Convert last users of PPC_INST_BRANCH to PPC_RAW_BRANCH() And remove PPC_INST_BRANCH. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 3 +-- arch/powerpc/lib/feature-fixups.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/incl

[PATCH v2 06/25] powerpc/ftrace: Inline ftrace_modify_code()

2022-05-06 Thread Christophe Leroy
Inlining ftrace_modify_code(), it increases a bit the size of ftrace code but brings 5% improvment on ftrace activation. Usually in C files we let gcc decide what to do but here it really help to 'help' gcc to decide to inline, thought we don't want to force it with an __always_inline that would b

[PATCH v2 07/25] powerpc/ftrace: Use patch_instruction() return directly

2022-05-06 Thread Christophe Leroy
Instead of returning -EPERM when patch_instruction() fails, just return what patch_instruction returns. That simplifies ftrace_modify_code(): 0: 94 21 ff c0 stwur1,-64(r1) 4: 93 e1 00 3c stw r31,60(r1) 8: 7c 7f 1b 79 mr. r31,r3

[PATCH v2 15/25] powerpc/ftrace: Use BRANCH_SET_LINK instead of value 1

2022-05-06 Thread Christophe Leroy
To make it explicit, use BRANCH_SET_LINK instead of value 1 when calling create_branch(). Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftr

[PATCH v2 04/25] powerpc/ftrace: Use is_offset_in_branch_range()

2022-05-06 Thread Christophe Leroy
Use is_offset_in_branch_range() instead of create_branch() to check if a target is within branch range. This patch together with the previous one improves ftrace activation time by 7% Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 8 ++-- 1 file changed, 2 insertio

[PATCH v2 24/25] powerpc/inst: Remove PPC_INST_BL

2022-05-06 Thread Christophe Leroy
Convert last users of PPC_INST_BL to PPC_RAW_BL() And remove PPC_INST_BL. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 1 - arch/powerpc/net/bpf_jit.h| 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/ppc-opc

[PATCH v2 16/25] powerpc/ftrace: Use PPC_RAW_xxx() macros instead of opencoding.

2022-05-06 Thread Christophe Leroy
PPC_RAW_xxx() macros are self explanatory and less error prone than open coding. Use them in ftrace.c Signed-off-by: Christophe Leroy --- v2: - Replaced PPC_INST_OFFSET24_MASK by PPC_LI_MASK and added PPC_LI(). - Fix ADDI instead of ADDIS --- arch/powerpc/include/asm/ppc-opcode.h | 5 + ar

[PATCH v2 18/25] powerpc/ftrace: Simplify expected_nop_sequence()

2022-05-06 Thread Christophe Leroy
Avoid ifdefs around expected_nop_sequence(). While at it make it a bool. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 22 ++ 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/t

[PATCH v2 11/25] powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64

2022-05-06 Thread Christophe Leroy
Since c93d4f6ecf4b ("powerpc/ftrace: Add module_trampoline_target() for PPC32"), __ftrace_make_nop() for PPC32 is very similar to the one for PPC64. Same for __ftrace_make_call(). Make them common. Signed-off-by: Christophe Leroy --- v2: - Fixed comment to -mprofile-kernel versus -mkernel_profi

[PATCH v2 19/25] powerpc/ftrace: Minimise number of #ifdefs

2022-05-06 Thread Christophe Leroy
A lot of #ifdefs can be replaced by IS_ENABLED() Do so. This requires to have kernel_toc_addr() defined at all time as well as PPC_INST_LD_TOC and PPC_INST_STD_LR. Signed-off-by: Christophe Leroy --- v2: Moved the setup of pop outside of the big if()/else() in __ftrace_make_nop() --- arch/powe

[PATCH v2 01/25] powerpc/ftrace: Refactor prepare_ftrace_return()

2022-05-06 Thread Christophe Leroy
When we have CONFIG_DYNAMIC_FTRACE_WITH_ARGS, prepare_ftrace_return() is called by ftrace_graph_func() otherwise prepare_ftrace_return() is called from assembly. Refactor prepare_ftrace_return() into a static __prepare_ftrace_return() that will be called by both prepare_ftrace_return() and ftrace_

[PATCH v2 25/25] powerpc/opcodes: Remove unused PPC_INST_XXX macros

2022-05-06 Thread Christophe Leroy
The following PPC_INST_XXX macros are not used anymore outside ppc-opcode.h: - PPC_INST_LD - PPC_INST_STD - PPC_INST_ADDIS - PPC_INST_ADD - PPC_INST_DIVD Remove them. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/ppc-opcode.h | 13 -

[PATCH v2 08/25] powerpc: Add CONFIG_PPC64_ELF_ABI_V1 and CONFIG_PPC64_ELF_ABI_V2

2022-05-06 Thread Christophe Leroy
At the time being, we use CONFIG_CPU_LITTLE_ENDIAN and CONFIG_CPU_BIG_ENDIAN to pass -mabi=elfv1 or elfv2 to compiler, then define a PPC64_ELF_ABI_v1 or PPC64_ELF_ABI_v2 macro in asm/types.h based on _CALL_ELF define set by the compiler. Make it more straight forward with a CONFIG option that is d

[PATCH v2 23/25] powerpc/modules: Use PPC_LI macros instead of opencoding

2022-05-06 Thread Christophe Leroy
Use PPC_LI_MASK and PPC_LI() instead of opencoding. Signed-off-by: Christophe Leroy --- v2: Utilisation de PPC_LI() et PPC_LI_MASK --- arch/powerpc/kernel/module_32.c | 11 --- arch/powerpc/kernel/module_64.c | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/p

[PATCH v2 09/25] powerpc: Replace PPC64_ELF_ABI_v{1/2} by CONFIG_PPC64_ELF_ABI_V{1/2}

2022-05-06 Thread Christophe Leroy
Replace all uses of PPC64_ELF_ABI_v1 and PPC64_ELF_ABI_v2 by resp CONFIG_PPC64_ELF_ABI_V1 and CONFIG_PPC64_ELF_ABI_V2. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/code-patching.h | 12 ++-- arch/powerpc/include/asm/ftrace.h| 4 ++-- arch/powerpc/include/asm/link

[PATCH v2 21/25] powerpc/ftrace: Don't use copy_from_kernel_nofault() in module_trampoline_target()

2022-05-06 Thread Christophe Leroy
module_trampoline_target() is quite a hot path used when activating/deactivating function tracer. Avoid the heavy copy_from_kernel_nofault() by doing four calls to copy_inst_from_kernel_nofault(). Use __copy_inst_from_kernel_nofault() for the 3 last calls. First call is done to copy_from_kernel_n

<    1   2