linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: arm64: Replace STACK_ALIGN() with round_up() to align stack size
@ 2021-05-10 12:51 Tiezhu Yang
  2021-05-12 20:56 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2021-05-10 12:51 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Zi Shen Lim,
	Catalin Marinas, Will Deacon, Andrii Nakryiko, Martin KaFai Lau,
	Song Liu, Yonghong Song, John Fastabend, KP Singh
  Cc: netdev, bpf, linux-arm-kernel, linux-kernel

Use the common function round_up() directly to show the align size
explicitly, the function STACK_ALIGN() is needless, remove it.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/arm64/net/bpf_jit_comp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index f7b1948..81c380f 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -178,9 +178,6 @@ static bool is_addsub_imm(u32 imm)
 	return !(imm & ~0xfff) || !(imm & ~0xfff000);
 }
 
-/* Stack must be multiples of 16B */
-#define STACK_ALIGN(sz) (((sz) + 15) & ~15)
-
 /* Tail call offset to jump into */
 #if IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)
 #define PROLOGUE_OFFSET 8
@@ -255,7 +252,7 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)
 			emit(A64_BTI_J, ctx);
 	}
 
-	ctx->stack_size = STACK_ALIGN(prog->aux->stack_depth);
+	ctx->stack_size = round_up(prog->aux->stack_depth, 16);
 
 	/* Set up function call stack */
 	emit(A64_SUB_I(1, A64_SP, A64_SP, ctx->stack_size), ctx);
-- 
2.1.0


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

* Re: [PATCH bpf-next] bpf: arm64: Replace STACK_ALIGN() with round_up() to align stack size
  2021-05-10 12:51 [PATCH bpf-next] bpf: arm64: Replace STACK_ALIGN() with round_up() to align stack size Tiezhu Yang
@ 2021-05-12 20:56 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2021-05-12 20:56 UTC (permalink / raw)
  To: Tiezhu Yang, Alexei Starovoitov, Zi Shen Lim, Catalin Marinas,
	Will Deacon, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh
  Cc: netdev, bpf, linux-arm-kernel, linux-kernel

On 5/10/21 2:51 PM, Tiezhu Yang wrote:
> Use the common function round_up() directly to show the align size
> explicitly, the function STACK_ALIGN() is needless, remove it.
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   arch/arm64/net/bpf_jit_comp.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index f7b1948..81c380f 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -178,9 +178,6 @@ static bool is_addsub_imm(u32 imm)
>   	return !(imm & ~0xfff) || !(imm & ~0xfff000);
>   }
>   
> -/* Stack must be multiples of 16B */
> -#define STACK_ALIGN(sz) (((sz) + 15) & ~15)
> -
>   /* Tail call offset to jump into */
>   #if IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)
>   #define PROLOGUE_OFFSET 8
> @@ -255,7 +252,7 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)
>   			emit(A64_BTI_J, ctx);
>   	}
>   
> -	ctx->stack_size = STACK_ALIGN(prog->aux->stack_depth);
> +	ctx->stack_size = round_up(prog->aux->stack_depth, 16);
>   

Applied, thanks! (I retained the comment wrt stack requirement to have it explicitly stated.)

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

end of thread, other threads:[~2021-05-12 22:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 12:51 [PATCH bpf-next] bpf: arm64: Replace STACK_ALIGN() with round_up() to align stack size Tiezhu Yang
2021-05-12 20:56 ` Daniel Borkmann

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