linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp()
@ 2022-07-21 12:13 Xu Kuohai
  2022-07-21 12:45 ` Jiri Olsa
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xu Kuohai @ 2022-07-21 12:13 UTC (permalink / raw)
  To: bpf, linux-arm-kernel, linux-kernel
  Cc: Alexei Starovoitov, Andrii Nakryiko, Catalin Marinas,
	Daniel Borkmann, Hao Luo, Jakub Sitnicki, Jean-Philippe Brucker,
	Jiri Olsa, John Fastabend, Jon Hunter, KP Singh,
	Martin KaFai Lau, Song Liu, Stanislav Fomichev, Will Deacon,
	Yonghong Song, Zi Shen Lim

From: Xu Kuohai <xukuohai@huawei.com>

dummy_tramp() uses "lr" to refer to the x30 register, but some assembler
does not recognize "lr" and reports a build failure:

/tmp/cc52xO0c.s: Assembler messages:
/tmp/cc52xO0c.s:8: Error: operand 1 should be an integer register -- `mov lr,x9'
/tmp/cc52xO0c.s:7: Error: undefined symbol lr used as an immediate value
make[2]: *** [scripts/Makefile.build:250: arch/arm64/net/bpf_jit_comp.o] Error 1
make[1]: *** [scripts/Makefile.build:525: arch/arm64/net] Error 2

So replace "lr" with "x30" to fix it.

Fixes: b2ad54e1533e ("bpf, arm64: Implement bpf_arch_text_poke() for arm64")
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
---
 arch/arm64/net/bpf_jit_comp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index dcc572b7d4da..7ca8779ae34f 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -610,8 +610,8 @@ asm (
 #if IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)
 "	bti j\n" /* dummy_tramp is called via "br x10" */
 #endif
-"	mov x10, lr\n"
-"	mov lr, x9\n"
+"	mov x10, x30\n"
+"	mov x30, x9\n"
 "	ret x10\n"
 "	.size dummy_tramp, .-dummy_tramp\n"
 "	.popsection\n"
-- 
2.30.2


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

* Re: [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp()
  2022-07-21 12:13 [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp() Xu Kuohai
@ 2022-07-21 12:45 ` Jiri Olsa
  2022-07-21 13:41 ` Jean-Philippe Brucker
  2022-07-21 22:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2022-07-21 12:45 UTC (permalink / raw)
  To: Xu Kuohai, Jean-Philippe Brucker
  Cc: bpf, linux-arm-kernel, linux-kernel, Alexei Starovoitov,
	Andrii Nakryiko, Catalin Marinas, Daniel Borkmann, Hao Luo,
	Jakub Sitnicki, John Fastabend, Jon Hunter, KP Singh,
	Martin KaFai Lau, Song Liu, Stanislav Fomichev, Will Deacon,
	Yonghong Song, Zi Shen Lim

On Thu, Jul 21, 2022 at 08:13:19AM -0400, Xu Kuohai wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
> 
> dummy_tramp() uses "lr" to refer to the x30 register, but some assembler
> does not recognize "lr" and reports a build failure:
> 
> /tmp/cc52xO0c.s: Assembler messages:
> /tmp/cc52xO0c.s:8: Error: operand 1 should be an integer register -- `mov lr,x9'
> /tmp/cc52xO0c.s:7: Error: undefined symbol lr used as an immediate value
> make[2]: *** [scripts/Makefile.build:250: arch/arm64/net/bpf_jit_comp.o] Error 1
> make[1]: *** [scripts/Makefile.build:525: arch/arm64/net] Error 2
> 
> So replace "lr" with "x30" to fix it.
> 
> Fixes: b2ad54e1533e ("bpf, arm64: Implement bpf_arch_text_poke() for arm64")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Tested-by: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>

Jean-Philippe, could you please take a look?

thanks,
jirka

> ---
>  arch/arm64/net/bpf_jit_comp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index dcc572b7d4da..7ca8779ae34f 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -610,8 +610,8 @@ asm (
>  #if IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)
>  "	bti j\n" /* dummy_tramp is called via "br x10" */
>  #endif
> -"	mov x10, lr\n"
> -"	mov lr, x9\n"
> +"	mov x10, x30\n"
> +"	mov x30, x9\n"
>  "	ret x10\n"
>  "	.size dummy_tramp, .-dummy_tramp\n"
>  "	.popsection\n"
> -- 
> 2.30.2
> 

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

* Re: [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp()
  2022-07-21 12:13 [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp() Xu Kuohai
  2022-07-21 12:45 ` Jiri Olsa
@ 2022-07-21 13:41 ` Jean-Philippe Brucker
  2022-07-21 22:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jean-Philippe Brucker @ 2022-07-21 13:41 UTC (permalink / raw)
  To: Xu Kuohai
  Cc: bpf, linux-arm-kernel, linux-kernel, Alexei Starovoitov,
	Andrii Nakryiko, Catalin Marinas, Daniel Borkmann, Hao Luo,
	Jakub Sitnicki, Jiri Olsa, John Fastabend, Jon Hunter, KP Singh,
	Martin KaFai Lau, Song Liu, Stanislav Fomichev, Will Deacon,
	Yonghong Song, Zi Shen Lim

On Thu, Jul 21, 2022 at 08:13:19AM -0400, Xu Kuohai wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
> 
> dummy_tramp() uses "lr" to refer to the x30 register, but some assembler
> does not recognize "lr" and reports a build failure:
> 
> /tmp/cc52xO0c.s: Assembler messages:
> /tmp/cc52xO0c.s:8: Error: operand 1 should be an integer register -- `mov lr,x9'
> /tmp/cc52xO0c.s:7: Error: undefined symbol lr used as an immediate value
> make[2]: *** [scripts/Makefile.build:250: arch/arm64/net/bpf_jit_comp.o] Error 1
> make[1]: *** [scripts/Makefile.build:525: arch/arm64/net] Error 2
> 
> So replace "lr" with "x30" to fix it.
> 
> Fixes: b2ad54e1533e ("bpf, arm64: Implement bpf_arch_text_poke() for arm64")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Tested-by: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>

Right, it looks like the lr alias was only added to binutils 2.30, and
Linux supports 2.23+

Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

> ---
>  arch/arm64/net/bpf_jit_comp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index dcc572b7d4da..7ca8779ae34f 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -610,8 +610,8 @@ asm (
>  #if IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)
>  "	bti j\n" /* dummy_tramp is called via "br x10" */
>  #endif
> -"	mov x10, lr\n"
> -"	mov lr, x9\n"
> +"	mov x10, x30\n"
> +"	mov x30, x9\n"
>  "	ret x10\n"
>  "	.size dummy_tramp, .-dummy_tramp\n"
>  "	.popsection\n"
> -- 
> 2.30.2
> 

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

* Re: [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp()
  2022-07-21 12:13 [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp() Xu Kuohai
  2022-07-21 12:45 ` Jiri Olsa
  2022-07-21 13:41 ` Jean-Philippe Brucker
@ 2022-07-21 22:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-21 22:30 UTC (permalink / raw)
  To: Xu Kuohai
  Cc: bpf, linux-arm-kernel, linux-kernel, ast, andrii,
	catalin.marinas, daniel, haoluo, jakub, jean-philippe, jolsa,
	john.fastabend, jonathanh, kpsingh, martin.lau, song, sdf, will,
	yhs, zlim.lnx

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Thu, 21 Jul 2022 08:13:19 -0400 you wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
> 
> dummy_tramp() uses "lr" to refer to the x30 register, but some assembler
> does not recognize "lr" and reports a build failure:
> 
> /tmp/cc52xO0c.s: Assembler messages:
> /tmp/cc52xO0c.s:8: Error: operand 1 should be an integer register -- `mov lr,x9'
> /tmp/cc52xO0c.s:7: Error: undefined symbol lr used as an immediate value
> make[2]: *** [scripts/Makefile.build:250: arch/arm64/net/bpf_jit_comp.o] Error 1
> make[1]: *** [scripts/Makefile.build:525: arch/arm64/net] Error 2
> 
> [...]

Here is the summary with links:
  - [bpf-next] bpf, arm64: Fix compile error in dummy_tramp()
    https://git.kernel.org/bpf/bpf-next/c/339ed900b307

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-07-21 22:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 12:13 [PATCH bpf-next] bpf, arm64: Fix compile error in dummy_tramp() Xu Kuohai
2022-07-21 12:45 ` Jiri Olsa
2022-07-21 13:41 ` Jean-Philippe Brucker
2022-07-21 22:30 ` patchwork-bot+netdevbpf

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).