diff mbox series

kbuild: dummy-tools: pretend we understand -fpatchable-function-entry

Message ID 20231030113416.5208-1-jirislaby@kernel.org (mailing list archive)
State New, archived
Headers show
Series kbuild: dummy-tools: pretend we understand -fpatchable-function-entry | expand

Commit Message

Jiri Slaby Oct. 30, 2023, 11:34 a.m. UTC
Commit 0f71dcfb4aef (powerpc/ftrace: Add support for
-fpatchable-function-entry) added a script to check for
-fpatchable-function-entry compiler support. The script expects compiler
to emit the section __patchable_function_entries and few nops after a
function entry.

If the compiler understands and emits the above,
CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY is set.

So teach dummy-tools' gcc about this.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: linux-kbuild@vger.kernel.org
Cc: Naveen N Rao <naveen@kernel.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Michael Ellerman <mpe@ellerman.id.au>
---
 scripts/dummy-tools/gcc | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Nathan Chancellor Oct. 31, 2023, 4:09 p.m. UTC | #1
On Mon, Oct 30, 2023 at 12:34:16PM +0100, Jiri Slaby (SUSE) wrote:
> Commit 0f71dcfb4aef (powerpc/ftrace: Add support for
> -fpatchable-function-entry) added a script to check for
> -fpatchable-function-entry compiler support. The script expects compiler
> to emit the section __patchable_function_entries and few nops after a
> function entry.
> 
> If the compiler understands and emits the above,
> CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY is set.
> 
> So teach dummy-tools' gcc about this.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Cc: Nicolas Schier <nicolas@fjasle.eu>
> Cc: linux-kbuild@vger.kernel.org
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> ---

This seems reasonable to me. I did not test it but it seems like it
should work based on my reading of gcc-check-fpatchable-function-entry.sh.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

One minor nit, there should be quotes around the subject of 0f71dcfb4aef
in the commit message, should there need to be a v2 for some reason.

>  scripts/dummy-tools/gcc | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc
> index 07f6dc4c5cf6..e6c41427c02f 100755
> --- a/scripts/dummy-tools/gcc
> +++ b/scripts/dummy-tools/gcc
> @@ -91,6 +91,16 @@ if arg_contain -S "$@"; then
>  		fi
>  		exit 0
>  	fi
> +
> +	# For arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh
> +	if arg_contain -m64 "$@" && arg_contain -fpatchable-function-entry=2 "$@"; then
> +		echo "func:"
> +		echo ".section __patchable_function_entries"
> +		echo ".localentry"
> +		echo "  nop"
> +		echo "  nop"
> +		exit 0
> +	fi
>  fi
>  
>  # To set GCC_PLUGINS
> -- 
> 2.42.0
>
Masahiro Yamada Nov. 1, 2023, 2:30 p.m. UTC | #2
On Mon, Oct 30, 2023 at 8:34 PM Jiri Slaby (SUSE) <jirislaby@kernel.org> wrote:
>
> Commit 0f71dcfb4aef (powerpc/ftrace: Add support for
> -fpatchable-function-entry) added a script to check for
> -fpatchable-function-entry compiler support. The script expects compiler
> to emit the section __patchable_function_entries and few nops after a
> function entry.
>
> If the compiler understands and emits the above,
> CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY is set.
>
> So teach dummy-tools' gcc about this.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Cc: Nicolas Schier <nicolas@fjasle.eu>
> Cc: linux-kbuild@vger.kernel.org
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> ---


Applied to linux-kbuild.
Thanks.
diff mbox series

Patch

diff --git a/scripts/dummy-tools/gcc b/scripts/dummy-tools/gcc
index 07f6dc4c5cf6..e6c41427c02f 100755
--- a/scripts/dummy-tools/gcc
+++ b/scripts/dummy-tools/gcc
@@ -91,6 +91,16 @@  if arg_contain -S "$@"; then
 		fi
 		exit 0
 	fi
+
+	# For arch/powerpc/tools/gcc-check-fpatchable-function-entry.sh
+	if arg_contain -m64 "$@" && arg_contain -fpatchable-function-entry=2 "$@"; then
+		echo "func:"
+		echo ".section __patchable_function_entries"
+		echo ".localentry"
+		echo "  nop"
+		echo "  nop"
+		exit 0
+	fi
 fi
 
 # To set GCC_PLUGINS