linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] samples: ftrace: replace bti assembly with hint for older compiler
@ 2023-08-20 11:15 GONG, Ruiqi
  2023-08-21 15:34 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: GONG, Ruiqi @ 2023-08-20 11:15 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Mark Rutland, Florent Revest
  Cc: linux-kernel, linux-trace-kernel, gongruiqi1

From: "GONG, Ruiqi" <gongruiqi1@huawei.com>

When cross-building the arm64 kernel with allmodconfig using GCC 9.4,
the following error occurs on multiple files under samples/ftrace/:

/tmp/ccPC1ODs.s: Assembler messages:
/tmp/ccPC1ODs.s:8: Error: selected processor does not support `bti c'

Fix this issue by replacing `bti c` with `hint 34`, which is compatible
for the older compiler.

Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
 samples/ftrace/ftrace-direct-modify.c       | 4 ++--
 samples/ftrace/ftrace-direct-multi-modify.c | 4 ++--
 samples/ftrace/ftrace-direct-multi.c        | 2 +-
 samples/ftrace/ftrace-direct-too.c          | 2 +-
 samples/ftrace/ftrace-direct.c              | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/samples/ftrace/ftrace-direct-modify.c b/samples/ftrace/ftrace-direct-modify.c
index e5ed08098ff3..e2a6a69352df 100644
--- a/samples/ftrace/ftrace-direct-modify.c
+++ b/samples/ftrace/ftrace-direct-modify.c
@@ -105,7 +105,7 @@ asm (
 "	.type		my_tramp1, @function\n"
 "	.globl		my_tramp1\n"
 "   my_tramp1:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #16\n"
 "	stp	x9, x30, [sp]\n"
 "	bl	my_direct_func1\n"
@@ -117,7 +117,7 @@ asm (
 "	.type		my_tramp2, @function\n"
 "	.globl		my_tramp2\n"
 "   my_tramp2:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #16\n"
 "	stp	x9, x30, [sp]\n"
 "	bl	my_direct_func2\n"
diff --git a/samples/ftrace/ftrace-direct-multi-modify.c b/samples/ftrace/ftrace-direct-multi-modify.c
index 292cff2b3f5d..2e349834d63c 100644
--- a/samples/ftrace/ftrace-direct-multi-modify.c
+++ b/samples/ftrace/ftrace-direct-multi-modify.c
@@ -112,7 +112,7 @@ asm (
 "	.type		my_tramp1, @function\n"
 "	.globl		my_tramp1\n"
 "   my_tramp1:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #32\n"
 "	stp	x9, x30, [sp]\n"
 "	str	x0, [sp, #16]\n"
@@ -127,7 +127,7 @@ asm (
 "	.type		my_tramp2, @function\n"
 "	.globl		my_tramp2\n"
 "   my_tramp2:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #32\n"
 "	stp	x9, x30, [sp]\n"
 "	str	x0, [sp, #16]\n"
diff --git a/samples/ftrace/ftrace-direct-multi.c b/samples/ftrace/ftrace-direct-multi.c
index b4391e08c913..9243dbfe4d0c 100644
--- a/samples/ftrace/ftrace-direct-multi.c
+++ b/samples/ftrace/ftrace-direct-multi.c
@@ -75,7 +75,7 @@ asm (
 "	.type		my_tramp, @function\n"
 "	.globl		my_tramp\n"
 "   my_tramp:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #32\n"
 "	stp	x9, x30, [sp]\n"
 "	str	x0, [sp, #16]\n"
diff --git a/samples/ftrace/ftrace-direct-too.c b/samples/ftrace/ftrace-direct-too.c
index e9804c5307c0..e39c3563ae4e 100644
--- a/samples/ftrace/ftrace-direct-too.c
+++ b/samples/ftrace/ftrace-direct-too.c
@@ -81,7 +81,7 @@ asm (
 "	.type		my_tramp, @function\n"
 "	.globl		my_tramp\n"
 "   my_tramp:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #48\n"
 "	stp	x9, x30, [sp]\n"
 "	stp	x0, x1, [sp, #16]\n"
diff --git a/samples/ftrace/ftrace-direct.c b/samples/ftrace/ftrace-direct.c
index 20f4a7caa810..32c477da1e9a 100644
--- a/samples/ftrace/ftrace-direct.c
+++ b/samples/ftrace/ftrace-direct.c
@@ -72,7 +72,7 @@ asm (
 "	.type		my_tramp, @function\n"
 "	.globl		my_tramp\n"
 "   my_tramp:"
-"	bti	c\n"
+"	hint	34\n" // bti	c
 "	sub	sp, sp, #32\n"
 "	stp	x9, x30, [sp]\n"
 "	str	x0, [sp, #16]\n"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] samples: ftrace: replace bti assembly with hint for older compiler
  2023-08-20 11:15 [PATCH] samples: ftrace: replace bti assembly with hint for older compiler GONG, Ruiqi
@ 2023-08-21 15:34 ` Steven Rostedt
  2023-08-21 15:41 ` Florent Revest
  2023-08-21 16:12 ` Mark Rutland
  2 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2023-08-21 15:34 UTC (permalink / raw)
  To: GONG, Ruiqi
  Cc: Masami Hiramatsu, Mark Rutland, Florent Revest, linux-kernel,
	linux-trace-kernel, gongruiqi1


Strange, I had to download this from lore. I only noticed this from
patchwork, but this email never made it to my inbox, nor to either my
kernel-tracing or LKML folders :-/

Anyway,

Mark, can you review this?

// patchwork link:
//    https://patchwork.kernel.org/project/linux-trace-kernel/patch/20230820111509.1470826-1-gongruiqi@huaweicloud.com/

-- Steve


On Sun, 20 Aug 2023 19:15:09 +0800
"GONG, Ruiqi" <gongruiqi@huaweicloud.com> wrote:

> From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
> 
> When cross-building the arm64 kernel with allmodconfig using GCC 9.4,
> the following error occurs on multiple files under samples/ftrace/:
> 
> /tmp/ccPC1ODs.s: Assembler messages:
> /tmp/ccPC1ODs.s:8: Error: selected processor does not support `bti c'
> 
> Fix this issue by replacing `bti c` with `hint 34`, which is compatible
> for the older compiler.
> 
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
> ---
>  samples/ftrace/ftrace-direct-modify.c       | 4 ++--
>  samples/ftrace/ftrace-direct-multi-modify.c | 4 ++--
>  samples/ftrace/ftrace-direct-multi.c        | 2 +-
>  samples/ftrace/ftrace-direct-too.c          | 2 +-
>  samples/ftrace/ftrace-direct.c              | 2 +-
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/samples/ftrace/ftrace-direct-modify.c b/samples/ftrace/ftrace-direct-modify.c
> index e5ed08098ff3..e2a6a69352df 100644
> --- a/samples/ftrace/ftrace-direct-modify.c
> +++ b/samples/ftrace/ftrace-direct-modify.c
> @@ -105,7 +105,7 @@ asm (
>  "	.type		my_tramp1, @function\n"
>  "	.globl		my_tramp1\n"
>  "   my_tramp1:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #16\n"
>  "	stp	x9, x30, [sp]\n"
>  "	bl	my_direct_func1\n"
> @@ -117,7 +117,7 @@ asm (
>  "	.type		my_tramp2, @function\n"
>  "	.globl		my_tramp2\n"
>  "   my_tramp2:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #16\n"
>  "	stp	x9, x30, [sp]\n"
>  "	bl	my_direct_func2\n"
> diff --git a/samples/ftrace/ftrace-direct-multi-modify.c b/samples/ftrace/ftrace-direct-multi-modify.c
> index 292cff2b3f5d..2e349834d63c 100644
> --- a/samples/ftrace/ftrace-direct-multi-modify.c
> +++ b/samples/ftrace/ftrace-direct-multi-modify.c
> @@ -112,7 +112,7 @@ asm (
>  "	.type		my_tramp1, @function\n"
>  "	.globl		my_tramp1\n"
>  "   my_tramp1:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> @@ -127,7 +127,7 @@ asm (
>  "	.type		my_tramp2, @function\n"
>  "	.globl		my_tramp2\n"
>  "   my_tramp2:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> diff --git a/samples/ftrace/ftrace-direct-multi.c b/samples/ftrace/ftrace-direct-multi.c
> index b4391e08c913..9243dbfe4d0c 100644
> --- a/samples/ftrace/ftrace-direct-multi.c
> +++ b/samples/ftrace/ftrace-direct-multi.c
> @@ -75,7 +75,7 @@ asm (
>  "	.type		my_tramp, @function\n"
>  "	.globl		my_tramp\n"
>  "   my_tramp:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> diff --git a/samples/ftrace/ftrace-direct-too.c b/samples/ftrace/ftrace-direct-too.c
> index e9804c5307c0..e39c3563ae4e 100644
> --- a/samples/ftrace/ftrace-direct-too.c
> +++ b/samples/ftrace/ftrace-direct-too.c
> @@ -81,7 +81,7 @@ asm (
>  "	.type		my_tramp, @function\n"
>  "	.globl		my_tramp\n"
>  "   my_tramp:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #48\n"
>  "	stp	x9, x30, [sp]\n"
>  "	stp	x0, x1, [sp, #16]\n"
> diff --git a/samples/ftrace/ftrace-direct.c b/samples/ftrace/ftrace-direct.c
> index 20f4a7caa810..32c477da1e9a 100644
> --- a/samples/ftrace/ftrace-direct.c
> +++ b/samples/ftrace/ftrace-direct.c
> @@ -72,7 +72,7 @@ asm (
>  "	.type		my_tramp, @function\n"
>  "	.globl		my_tramp\n"
>  "   my_tramp:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] samples: ftrace: replace bti assembly with hint for older compiler
  2023-08-20 11:15 [PATCH] samples: ftrace: replace bti assembly with hint for older compiler GONG, Ruiqi
  2023-08-21 15:34 ` Steven Rostedt
@ 2023-08-21 15:41 ` Florent Revest
  2023-08-21 16:04   ` Mark Rutland
  2023-08-21 16:12 ` Mark Rutland
  2 siblings, 1 reply; 5+ messages in thread
From: Florent Revest @ 2023-08-21 15:41 UTC (permalink / raw)
  To: GONG, Ruiqi
  Cc: Steven Rostedt, Masami Hiramatsu, Mark Rutland, linux-kernel,
	linux-trace-kernel, gongruiqi1

On Sun, Aug 20, 2023 at 1:10 PM GONG, Ruiqi <gongruiqi@huaweicloud.com> wrote:
>
> When cross-building the arm64 kernel with allmodconfig using GCC 9.4,
> the following error occurs on multiple files under samples/ftrace/:
>
> /tmp/ccPC1ODs.s: Assembler messages:
> /tmp/ccPC1ODs.s:8: Error: selected processor does not support `bti c'
>
> Fix this issue by replacing `bti c` with `hint 34`, which is compatible
> for the older compiler.

I see this hint is already used in
tools/testing/selftests/arm64/fp/rdvl.S but I'm curious why it isn't
used in other parts of the kernel like
arch/arm64/kernel/entry-ftrace.S or
tools/testing/selftests/arm64/bti/syscall.S

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] samples: ftrace: replace bti assembly with hint for older compiler
  2023-08-21 15:41 ` Florent Revest
@ 2023-08-21 16:04   ` Mark Rutland
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Rutland @ 2023-08-21 16:04 UTC (permalink / raw)
  To: Florent Revest
  Cc: GONG, Ruiqi, Steven Rostedt, Masami Hiramatsu, linux-kernel,
	linux-trace-kernel, gongruiqi1

On Mon, Aug 21, 2023 at 05:41:21PM +0200, Florent Revest wrote:
> On Sun, Aug 20, 2023 at 1:10 PM GONG, Ruiqi <gongruiqi@huaweicloud.com> wrote:
> >
> > When cross-building the arm64 kernel with allmodconfig using GCC 9.4,
> > the following error occurs on multiple files under samples/ftrace/:
> >
> > /tmp/ccPC1ODs.s: Assembler messages:
> > /tmp/ccPC1ODs.s:8: Error: selected processor does not support `bti c'
> >
> > Fix this issue by replacing `bti c` with `hint 34`, which is compatible
> > for the older compiler.
> 
> I see this hint is already used in
> tools/testing/selftests/arm64/fp/rdvl.S but I'm curious why it isn't
> used in other parts of the kernel like
> arch/arm64/kernel/entry-ftrace.S or
> tools/testing/selftests/arm64/bti/syscall.S

For assembly files, the macro in arch/arm64/include/asm/assembler.h handles
this automatically. See commit:

  9be34be87cc8d1af ("arm64: Add macro version of the BTI instruction")

For inline asembly, we need to explicitly instantiate all of that in the inline
asm block, and since clang treats each asm block independently, we can'y just
define that in one place in a header somewhere.

I'll reply to the patch in a sec...

Mark.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] samples: ftrace: replace bti assembly with hint for older compiler
  2023-08-20 11:15 [PATCH] samples: ftrace: replace bti assembly with hint for older compiler GONG, Ruiqi
  2023-08-21 15:34 ` Steven Rostedt
  2023-08-21 15:41 ` Florent Revest
@ 2023-08-21 16:12 ` Mark Rutland
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Rutland @ 2023-08-21 16:12 UTC (permalink / raw)
  To: GONG, Ruiqi, Steven Rostedt
  Cc: Masami Hiramatsu, Florent Revest, linux-kernel,
	linux-trace-kernel, gongruiqi1

On Sun, Aug 20, 2023 at 07:15:09PM +0800, GONG, Ruiqi wrote:
> From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
> 
> When cross-building the arm64 kernel with allmodconfig using GCC 9.4,
> the following error occurs on multiple files under samples/ftrace/:
> 
> /tmp/ccPC1ODs.s: Assembler messages:
> /tmp/ccPC1ODs.s:8: Error: selected processor does not support `bti c'
> 
> Fix this issue by replacing `bti c` with `hint 34`, which is compatible
> for the older compiler.
> 
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>

Sorry about this; I'd forgotten about earlier compilers when reviewing the
original patch. It's a bit unfortunate to have to hand-code this each time, but
I'm not sure that it'd actually be cleaner to have a macro.

For the moment, I reckon this is worth taking as-is.

Steve, are you happy to add:

  Fixes: 8c3526fb86060cb5 ("arm64: ftrace: Add direct call trampoline samples support")
  Acked-by: Mark Rutland <mark.rutland@arm.com>

... ?

Thanks,
Mark.

> ---
>  samples/ftrace/ftrace-direct-modify.c       | 4 ++--
>  samples/ftrace/ftrace-direct-multi-modify.c | 4 ++--
>  samples/ftrace/ftrace-direct-multi.c        | 2 +-
>  samples/ftrace/ftrace-direct-too.c          | 2 +-
>  samples/ftrace/ftrace-direct.c              | 2 +-
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/samples/ftrace/ftrace-direct-modify.c b/samples/ftrace/ftrace-direct-modify.c
> index e5ed08098ff3..e2a6a69352df 100644
> --- a/samples/ftrace/ftrace-direct-modify.c
> +++ b/samples/ftrace/ftrace-direct-modify.c
> @@ -105,7 +105,7 @@ asm (
>  "	.type		my_tramp1, @function\n"
>  "	.globl		my_tramp1\n"
>  "   my_tramp1:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #16\n"
>  "	stp	x9, x30, [sp]\n"
>  "	bl	my_direct_func1\n"
> @@ -117,7 +117,7 @@ asm (
>  "	.type		my_tramp2, @function\n"
>  "	.globl		my_tramp2\n"
>  "   my_tramp2:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #16\n"
>  "	stp	x9, x30, [sp]\n"
>  "	bl	my_direct_func2\n"
> diff --git a/samples/ftrace/ftrace-direct-multi-modify.c b/samples/ftrace/ftrace-direct-multi-modify.c
> index 292cff2b3f5d..2e349834d63c 100644
> --- a/samples/ftrace/ftrace-direct-multi-modify.c
> +++ b/samples/ftrace/ftrace-direct-multi-modify.c
> @@ -112,7 +112,7 @@ asm (
>  "	.type		my_tramp1, @function\n"
>  "	.globl		my_tramp1\n"
>  "   my_tramp1:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> @@ -127,7 +127,7 @@ asm (
>  "	.type		my_tramp2, @function\n"
>  "	.globl		my_tramp2\n"
>  "   my_tramp2:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> diff --git a/samples/ftrace/ftrace-direct-multi.c b/samples/ftrace/ftrace-direct-multi.c
> index b4391e08c913..9243dbfe4d0c 100644
> --- a/samples/ftrace/ftrace-direct-multi.c
> +++ b/samples/ftrace/ftrace-direct-multi.c
> @@ -75,7 +75,7 @@ asm (
>  "	.type		my_tramp, @function\n"
>  "	.globl		my_tramp\n"
>  "   my_tramp:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> diff --git a/samples/ftrace/ftrace-direct-too.c b/samples/ftrace/ftrace-direct-too.c
> index e9804c5307c0..e39c3563ae4e 100644
> --- a/samples/ftrace/ftrace-direct-too.c
> +++ b/samples/ftrace/ftrace-direct-too.c
> @@ -81,7 +81,7 @@ asm (
>  "	.type		my_tramp, @function\n"
>  "	.globl		my_tramp\n"
>  "   my_tramp:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #48\n"
>  "	stp	x9, x30, [sp]\n"
>  "	stp	x0, x1, [sp, #16]\n"
> diff --git a/samples/ftrace/ftrace-direct.c b/samples/ftrace/ftrace-direct.c
> index 20f4a7caa810..32c477da1e9a 100644
> --- a/samples/ftrace/ftrace-direct.c
> +++ b/samples/ftrace/ftrace-direct.c
> @@ -72,7 +72,7 @@ asm (
>  "	.type		my_tramp, @function\n"
>  "	.globl		my_tramp\n"
>  "   my_tramp:"
> -"	bti	c\n"
> +"	hint	34\n" // bti	c
>  "	sub	sp, sp, #32\n"
>  "	stp	x9, x30, [sp]\n"
>  "	str	x0, [sp, #16]\n"
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-21 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-20 11:15 [PATCH] samples: ftrace: replace bti assembly with hint for older compiler GONG, Ruiqi
2023-08-21 15:34 ` Steven Rostedt
2023-08-21 15:41 ` Florent Revest
2023-08-21 16:04   ` Mark Rutland
2023-08-21 16:12 ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).