All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Naveen N Rao <naveen@kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH 07/17] powerpc/ftrace: Consolidate ftrace support into fewer files
Date: Fri, 23 Jun 2023 05:25:48 +0000	[thread overview]
Message-ID: <057806e4-5bf3-9b0f-8019-a8114245c4c6@csgroup.eu> (raw)
In-Reply-To: <b900c9a8bba9d6c3c295e0f99886acf3e5bf6f7b.1687166935.git.naveen@kernel.org>



Le 19/06/2023 à 11:47, Naveen N Rao a écrit :
> ftrace_low.S has just the _mcount stub and return_to_handler(). Merge
> this back into ftrace_mprofile.S and ftrace_64_pg.S to keep all ftrace
> code together, and to allow those to evolve independently.
> 
> ftrace_mprofile.S is also not an entirely accurate name since this also
> holds ppc32 code. This will be all the more incorrect once support for
> -fpatchable-function-entry is added. Rename files here to more
> accurately describe the code:
> - ftrace_mprofile.S is renamed to ftrace_entry.S
> - ftrace_pg.c is renamed to ftrace_64_pg.c
> - ftrace_64_pg.S is rename to ftrace_64_pg_entry.S

The stats from git do not match., it says {ftrace_low.S => 
ftrace_64_pg_entry.S

> 
> Signed-off-by: Naveen N Rao <naveen@kernel.org>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   arch/powerpc/kernel/trace/Makefile            | 17 +++--
>   arch/powerpc/kernel/trace/ftrace_64_pg.S      | 67 -------------------
>   .../trace/{ftrace_pg.c => ftrace_64_pg.c}     |  0
>   .../{ftrace_low.S => ftrace_64_pg_entry.S}    | 58 +++++++++++++++-
>   .../{ftrace_mprofile.S => ftrace_entry.S}     | 65 ++++++++++++++++++
>   5 files changed, 130 insertions(+), 77 deletions(-)
>   delete mode 100644 arch/powerpc/kernel/trace/ftrace_64_pg.S
>   rename arch/powerpc/kernel/trace/{ftrace_pg.c => ftrace_64_pg.c} (100%)
>   rename arch/powerpc/kernel/trace/{ftrace_low.S => ftrace_64_pg_entry.S} (55%)
>   rename arch/powerpc/kernel/trace/{ftrace_mprofile.S => ftrace_entry.S} (83%)
> 
> diff --git a/arch/powerpc/kernel/trace/Makefile b/arch/powerpc/kernel/trace/Makefile
> index 342a2d1ae86cd0..125f4ca588b98a 100644
> --- a/arch/powerpc/kernel/trace/Makefile
> +++ b/arch/powerpc/kernel/trace/Makefile
> @@ -6,16 +6,15 @@
>   ifdef CONFIG_FUNCTION_TRACER
>   # do not trace tracer code
>   CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
> -CFLAGS_REMOVE_ftrace_pg.o = $(CC_FLAGS_FTRACE)
> +CFLAGS_REMOVE_ftrace_64_pg.o = $(CC_FLAGS_FTRACE)
>   endif
>   
> -obj32-$(CONFIG_FUNCTION_TRACER)		+= ftrace_mprofile.o ftrace.o
> +obj32-$(CONFIG_FUNCTION_TRACER)		+= ftrace.o ftrace_entry.o
>   ifdef CONFIG_MPROFILE_KERNEL
> -obj64-$(CONFIG_FUNCTION_TRACER)		+= ftrace_mprofile.o ftrace.o
> +obj64-$(CONFIG_FUNCTION_TRACER)		+= ftrace.o ftrace_entry.o
>   else
> -obj64-$(CONFIG_FUNCTION_TRACER)		+= ftrace_64_pg.o ftrace_pg.o
> +obj64-$(CONFIG_FUNCTION_TRACER)		+= ftrace_64_pg.o ftrace_64_pg_entry.o
>   endif
> -obj-$(CONFIG_FUNCTION_TRACER)		+= ftrace_low.o
>   obj-$(CONFIG_TRACING)			+= trace_clock.o
>   
>   obj-$(CONFIG_PPC64)			+= $(obj64-y)
> @@ -26,7 +25,7 @@ GCOV_PROFILE_ftrace.o := n
>   KCOV_INSTRUMENT_ftrace.o := n
>   KCSAN_SANITIZE_ftrace.o := n
>   UBSAN_SANITIZE_ftrace.o := n
> -GCOV_PROFILE_ftrace_pg.o := n
> -KCOV_INSTRUMENT_ftrace_pg.o := n
> -KCSAN_SANITIZE_ftrace_pg.o := n
> -UBSAN_SANITIZE_ftrace_pg.o := n
> +GCOV_PROFILE_ftrace_64_pg.o := n
> +KCOV_INSTRUMENT_ftrace_64_pg.o := n
> +KCSAN_SANITIZE_ftrace_64_pg.o := n
> +UBSAN_SANITIZE_ftrace_64_pg.o := n
> diff --git a/arch/powerpc/kernel/trace/ftrace_64_pg.S b/arch/powerpc/kernel/trace/ftrace_64_pg.S
> deleted file mode 100644
> index 6708e24db0aba8..00000000000000
> --- a/arch/powerpc/kernel/trace/ftrace_64_pg.S
> +++ /dev/null
> @@ -1,67 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-or-later */
> -/*
> - * Split from ftrace_64.S
> - */
> -
> -#include <linux/magic.h>
> -#include <asm/ppc_asm.h>
> -#include <asm/asm-offsets.h>
> -#include <asm/ftrace.h>
> -#include <asm/ppc-opcode.h>
> -#include <asm/export.h>
> -
> -_GLOBAL_TOC(ftrace_caller)
> -	lbz	r3, PACA_FTRACE_ENABLED(r13)
> -	cmpdi	r3, 0
> -	beqlr
> -
> -	/* Taken from output of objdump from lib64/glibc */
> -	mflr	r3
> -	ld	r11, 0(r1)
> -	stdu	r1, -112(r1)
> -	std	r3, 128(r1)
> -	ld	r4, 16(r11)
> -	subi	r3, r3, MCOUNT_INSN_SIZE
> -.globl ftrace_call
> -ftrace_call:
> -	bl	ftrace_stub
> -	nop
> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> -.globl ftrace_graph_call
> -ftrace_graph_call:
> -	b	ftrace_graph_stub
> -_GLOBAL(ftrace_graph_stub)
> -#endif
> -	ld	r0, 128(r1)
> -	mtlr	r0
> -	addi	r1, r1, 112
> -
> -_GLOBAL(ftrace_stub)
> -	blr
> -
> -#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> -_GLOBAL(ftrace_graph_caller)
> -	addi	r5, r1, 112
> -	/* load r4 with local address */
> -	ld	r4, 128(r1)
> -	subi	r4, r4, MCOUNT_INSN_SIZE
> -
> -	/* Grab the LR out of the caller stack frame */
> -	ld	r11, 112(r1)
> -	ld	r3, 16(r11)
> -
> -	bl	prepare_ftrace_return
> -	nop
> -
> -	/*
> -	 * prepare_ftrace_return gives us the address we divert to.
> -	 * Change the LR in the callers stack frame to this.
> -	 */
> -	ld	r11, 112(r1)
> -	std	r3, 16(r11)
> -
> -	ld	r0, 128(r1)
> -	mtlr	r0
> -	addi	r1, r1, 112
> -	blr
> -#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> diff --git a/arch/powerpc/kernel/trace/ftrace_pg.c b/arch/powerpc/kernel/trace/ftrace_64_pg.c
> similarity index 100%
> rename from arch/powerpc/kernel/trace/ftrace_pg.c
> rename to arch/powerpc/kernel/trace/ftrace_64_pg.c
> diff --git a/arch/powerpc/kernel/trace/ftrace_low.S b/arch/powerpc/kernel/trace/ftrace_64_pg_entry.S
> similarity index 55%
> rename from arch/powerpc/kernel/trace/ftrace_low.S
> rename to arch/powerpc/kernel/trace/ftrace_64_pg_entry.S
> index 2fc7dd0a5ae968..81dbaf70b1513a 100644
> --- a/arch/powerpc/kernel/trace/ftrace_low.S
> +++ b/arch/powerpc/kernel/trace/ftrace_64_pg_entry.S
> @@ -1,6 +1,6 @@
>   /* SPDX-License-Identifier: GPL-2.0-or-later */
>   /*
> - * Split from entry_64.S
> + * Split from ftrace_64.S
>    */
>   
>   #include <linux/magic.h>
> @@ -10,6 +10,62 @@
>   #include <asm/ppc-opcode.h>
>   #include <asm/export.h>
>   
> +_GLOBAL_TOC(ftrace_caller)
> +	lbz	r3, PACA_FTRACE_ENABLED(r13)
> +	cmpdi	r3, 0
> +	beqlr
> +
> +	/* Taken from output of objdump from lib64/glibc */
> +	mflr	r3
> +	ld	r11, 0(r1)
> +	stdu	r1, -112(r1)
> +	std	r3, 128(r1)
> +	ld	r4, 16(r11)
> +	subi	r3, r3, MCOUNT_INSN_SIZE
> +.globl ftrace_call
> +ftrace_call:
> +	bl	ftrace_stub
> +	nop
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +.globl ftrace_graph_call
> +ftrace_graph_call:
> +	b	ftrace_graph_stub
> +_GLOBAL(ftrace_graph_stub)
> +#endif
> +	ld	r0, 128(r1)
> +	mtlr	r0
> +	addi	r1, r1, 112
> +
> +_GLOBAL(ftrace_stub)
> +	blr
> +
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +_GLOBAL(ftrace_graph_caller)
> +	addi	r5, r1, 112
> +	/* load r4 with local address */
> +	ld	r4, 128(r1)
> +	subi	r4, r4, MCOUNT_INSN_SIZE
> +
> +	/* Grab the LR out of the caller stack frame */
> +	ld	r11, 112(r1)
> +	ld	r3, 16(r11)
> +
> +	bl	prepare_ftrace_return
> +	nop
> +
> +	/*
> +	 * prepare_ftrace_return gives us the address we divert to.
> +	 * Change the LR in the callers stack frame to this.
> +	 */
> +	ld	r11, 112(r1)
> +	std	r3, 16(r11)
> +
> +	ld	r0, 128(r1)
> +	mtlr	r0
> +	addi	r1, r1, 112
> +	blr
> +#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> +
>   .pushsection ".tramp.ftrace.text","aw",@progbits;
>   .globl ftrace_tramp_text
>   ftrace_tramp_text:
> diff --git a/arch/powerpc/kernel/trace/ftrace_mprofile.S b/arch/powerpc/kernel/trace/ftrace_entry.S
> similarity index 83%
> rename from arch/powerpc/kernel/trace/ftrace_mprofile.S
> rename to arch/powerpc/kernel/trace/ftrace_entry.S
> index ffb1db38684998..e8339706e735b1 100644
> --- a/arch/powerpc/kernel/trace/ftrace_mprofile.S
> +++ b/arch/powerpc/kernel/trace/ftrace_entry.S
> @@ -249,3 +249,68 @@ livepatch_handler:
>   	/* Return to original caller of live patched function */
>   	blr
>   #endif /* CONFIG_LIVEPATCH */
> +
> +_GLOBAL(mcount)
> +_GLOBAL(_mcount)
> +EXPORT_SYMBOL(_mcount)
> +	mflr	r12
> +	mtctr	r12
> +	mtlr	r0
> +	bctr
> +
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +_GLOBAL(return_to_handler)
> +	/* need to save return values */
> +#ifdef CONFIG_PPC64
> +	std	r4,  -32(r1)
> +	std	r3,  -24(r1)
> +	/* save TOC */
> +	std	r2,  -16(r1)
> +	std	r31, -8(r1)
> +	mr	r31, r1
> +	stdu	r1, -112(r1)
> +
> +	/*
> +	 * We might be called from a module.
> +	 * Switch to our TOC to run inside the core kernel.
> +	 */
> +	LOAD_PACA_TOC()
> +#else
> +	stwu	r1, -16(r1)
> +	stw	r3, 8(r1)
> +	stw	r4, 12(r1)
> +#endif
> +
> +	bl	ftrace_return_to_handler
> +	nop
> +
> +	/* return value has real return address */
> +	mtlr	r3
> +
> +#ifdef CONFIG_PPC64
> +	ld	r1, 0(r1)
> +	ld	r4,  -32(r1)
> +	ld	r3,  -24(r1)
> +	ld	r2,  -16(r1)
> +	ld	r31, -8(r1)
> +#else
> +	lwz	r3, 8(r1)
> +	lwz	r4, 12(r1)
> +	addi	r1, r1, 16
> +#endif
> +
> +	/* Jump back to real return address */
> +	blr
> +#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> +
> +.pushsection ".tramp.ftrace.text","aw",@progbits;
> +.globl ftrace_tramp_text
> +ftrace_tramp_text:
> +	.space 32
> +.popsection
> +
> +.pushsection ".tramp.ftrace.init","aw",@progbits;
> +.globl ftrace_tramp_init
> +ftrace_tramp_init:
> +	.space 32
> +.popsection

  reply	other threads:[~2023-06-23  5:27 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19  9:47 [PATCH 00/17] powerpc/ftrace: refactor and add support for -fpatchable-function-entry Naveen N Rao
2023-06-19  9:47 ` [PATCH 01/17] powerpc/ftrace: Fix dropping weak symbols with older toolchains Naveen N Rao
2023-06-23  5:10   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 02/17] powerpc/module: Remove unused .ftrace.tramp section Naveen N Rao
2023-06-23  5:12   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 03/17] powerpc64/ftrace: Move ELFv1 and -pg support code into a separate file Naveen N Rao
2023-06-23  5:13   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 04/17] powerpc/ftrace: Simplify function_graph support in ftrace.c Naveen N Rao
2023-06-23  5:14   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 05/17] powerpc/ftrace: Use FTRACE_REGS_ADDR to identify the correct ftrace trampoline Naveen N Rao
2023-06-23  5:15   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 06/17] powerpc/ftrace: Extend ftrace support for large kernels to ppc32 Naveen N Rao
2023-06-23  5:21   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 07/17] powerpc/ftrace: Consolidate ftrace support into fewer files Naveen N Rao
2023-06-23  5:25   ` Christophe Leroy [this message]
2023-06-28  7:32     ` Naveen N Rao
2023-06-19  9:47 ` [PATCH 08/17] powerpc/ftrace: Refactor ftrace_modify_code() Naveen N Rao
2023-06-23  5:27   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 09/17] powerpc/ftrace: Stop re-purposing linker generated long branches for ftrace Naveen N Rao
2023-06-23  5:28   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 10/17] powerpc/ftrace: Add separate ftrace_init_nop() with additional validation Naveen N Rao
2023-06-23  5:29   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 11/17] powerpc/ftrace: Simplify ftrace_make_nop() Naveen N Rao
2023-06-23  5:30   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 12/17] powerpc/ftrace: Simplify ftrace_make_call() Naveen N Rao
2023-06-23  5:30   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 13/17] powerpc/ftrace: Simplify ftrace_modify_call() Naveen N Rao
2023-06-23  5:31   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 14/17] powerpc/ftrace: Replace use of ftrace_call_replace() with ftrace_create_branch_inst() Naveen N Rao
2023-06-23  5:32   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 15/17] powerpc/ftrace: Implement ftrace_replace_code() Naveen N Rao
2023-06-23  5:32   ` Christophe Leroy
2023-06-19  9:47 ` [PATCH 16/17] powerpc/ftrace: Add support for -fpatchable-function-entry Naveen N Rao
2023-06-23  5:37   ` Christophe Leroy
2023-06-28  7:40     ` Naveen N Rao
2023-06-19  9:47 ` [PATCH 17/17] powerpc/ftrace: Create a dummy stackframe to fix stack unwind Naveen N Rao
2023-06-23  5:40   ` Christophe Leroy
2023-06-28  7:43     ` Naveen N Rao
2023-08-23 11:55 ` [PATCH 00/17] powerpc/ftrace: refactor and add support for -fpatchable-function-entry Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=057806e4-5bf3-9b0f-8019-a8114245c4c6@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=naveen@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.