Skip to contentSkip to conversation

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

PATCH In review Jiri Slaby (SUSE) 3 participants 3 messages Oct 30, 2023 – Nov 1, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: dummy-tools: pretend we understand -fpatchable-function-entry

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.

Cc Masahiro Yamada <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Naveen N Rao <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Michael Ellerman <[email protected]>
---
 scripts/dummy-tools/gcc | 10 ++++++++++
 1 file changed, 10 insertions(+)
scripts/dummy-tools/gcc +10 -0
index 07f6dc4c5cf6..e6c41427c02f 100755
@@ -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
Signature · 1 line
2.42.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Jiri Slaby (SUSE)

Commit 0f71dcfb4aef (powerpc/ftrace: Add support for

(quoted diff) +0 -2
-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.

Cc Masahiro Yamada <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Naveen N Rao <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Michael Ellerman <[email protected]>
Quoted 1 line

---

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.

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.

Quoted 27 lines
 scripts/dummy-tools/gcc | 10 ++++++++++
 1 file changed, 10 insertions(+)
scripts/dummy-tools/gcc +10 -0
index 07f6dc4c5cf6..e6c41427c02f 100755
@@ -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
Signature · 1 line
2.42.0
#2 lore raw
In reply to Jiri Slaby (SUSE)
Quoted 21 lines · Jiri Slaby (SUSE)

Commit 0f71dcfb4aef (powerpc/ftrace: Add support for

(quoted diff) +0 -2
-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.

Cc Masahiro Yamada <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Naveen N Rao <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Michael Ellerman <[email protected]>
Quoted 1 line

---

Applied to linux-kbuild.
Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada