All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info
@ 2022-02-26 12:19 ` Hou Tao
  0 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-26 12:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, houtao1,
	Zi Shen Lim, Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

Hi,

The patchset addresses two issues in bpf line info for arm64:

(1) insn_to_jit_off only considers the body itself and ignores
    prologue before the body. Fixed in patch #1.

(2) insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is
    calculated in instruction granularity instead of bytes
    granularity. Fixed in patch #2.

Comments are always welcome.

Regards,
Tao

Change Log:
v4:
 * patch #2: convert ctx.offset into byte offset before call
   bpf_prog_fill_jited_linfo() instead of converting it back and forth.

v3: https://lore.kernel.org/bpf/20220208012539.491753-1-houtao1@huawei.com
 * patch #2: explain why bpf2a64_offset() needs update
 * add Fixes tags in both patches

v2: https://lore.kernel.org/bpf/20220125105707.292449-1-houtao1@huawei.com
 * split into two independent patches (from Daniel)
 * use AARCH64_INSN_SIZE instead of defining INSN_SIZE

v1: https://lore.kernel.org/bpf/20220104014236.1512639-1-houtao1@huawei.com

Hou Tao (2):
  bpf, arm64: call build_prologue() first in first JIT pass
  bpf, arm64: feed byte-offset into bpf line info

 arch/arm64/net/bpf_jit_comp.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
2.18.2


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

* [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info
@ 2022-02-26 12:19 ` Hou Tao
  0 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-26 12:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, houtao1,
	Zi Shen Lim, Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

Hi,

The patchset addresses two issues in bpf line info for arm64:

(1) insn_to_jit_off only considers the body itself and ignores
    prologue before the body. Fixed in patch #1.

(2) insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is
    calculated in instruction granularity instead of bytes
    granularity. Fixed in patch #2.

Comments are always welcome.

Regards,
Tao

Change Log:
v4:
 * patch #2: convert ctx.offset into byte offset before call
   bpf_prog_fill_jited_linfo() instead of converting it back and forth.

v3: https://lore.kernel.org/bpf/20220208012539.491753-1-houtao1@huawei.com
 * patch #2: explain why bpf2a64_offset() needs update
 * add Fixes tags in both patches

v2: https://lore.kernel.org/bpf/20220125105707.292449-1-houtao1@huawei.com
 * split into two independent patches (from Daniel)
 * use AARCH64_INSN_SIZE instead of defining INSN_SIZE

v1: https://lore.kernel.org/bpf/20220104014236.1512639-1-houtao1@huawei.com

Hou Tao (2):
  bpf, arm64: call build_prologue() first in first JIT pass
  bpf, arm64: feed byte-offset into bpf line info

 arch/arm64/net/bpf_jit_comp.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
2.18.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH bpf-next v4 1/2] bpf, arm64: call build_prologue() first in first JIT pass
  2022-02-26 12:19 ` Hou Tao
@ 2022-02-26 12:19   ` Hou Tao
  -1 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-26 12:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, houtao1,
	Zi Shen Lim, Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

BPF line info needs ctx->offset to be the instruction offset
in the whole jited image instead of the body itself, so also
call build_prologue() first in first JIT pass.

Fixes: 37ab566c178d ("bpf: arm64: Enable arm64 jit to provide bpf_line_info")
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 arch/arm64/net/bpf_jit_comp.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 2375ed3e4c8a..68b35c83e637 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -1190,15 +1190,18 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 		goto out_off;
 	}
 
-	/* 1. Initial fake pass to compute ctx->idx. */
-
-	/* Fake pass to fill in ctx->offset. */
-	if (build_body(&ctx, extra_pass)) {
+	/*
+	 * 1. Initial fake pass to compute ctx->idx and ctx->offset.
+	 *
+	 * BPF line info needs ctx->offset[i] to be the offset of
+	 * instruction[i] in jited image, so build prologue first.
+	 */
+	if (build_prologue(&ctx, was_classic)) {
 		prog = orig_prog;
 		goto out_off;
 	}
 
-	if (build_prologue(&ctx, was_classic)) {
+	if (build_body(&ctx, extra_pass)) {
 		prog = orig_prog;
 		goto out_off;
 	}
-- 
2.18.2


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

* [PATCH bpf-next v4 1/2] bpf, arm64: call build_prologue() first in first JIT pass
@ 2022-02-26 12:19   ` Hou Tao
  0 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-26 12:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, houtao1,
	Zi Shen Lim, Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

BPF line info needs ctx->offset to be the instruction offset
in the whole jited image instead of the body itself, so also
call build_prologue() first in first JIT pass.

Fixes: 37ab566c178d ("bpf: arm64: Enable arm64 jit to provide bpf_line_info")
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 arch/arm64/net/bpf_jit_comp.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 2375ed3e4c8a..68b35c83e637 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -1190,15 +1190,18 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 		goto out_off;
 	}
 
-	/* 1. Initial fake pass to compute ctx->idx. */
-
-	/* Fake pass to fill in ctx->offset. */
-	if (build_body(&ctx, extra_pass)) {
+	/*
+	 * 1. Initial fake pass to compute ctx->idx and ctx->offset.
+	 *
+	 * BPF line info needs ctx->offset[i] to be the offset of
+	 * instruction[i] in jited image, so build prologue first.
+	 */
+	if (build_prologue(&ctx, was_classic)) {
 		prog = orig_prog;
 		goto out_off;
 	}
 
-	if (build_prologue(&ctx, was_classic)) {
+	if (build_body(&ctx, extra_pass)) {
 		prog = orig_prog;
 		goto out_off;
 	}
-- 
2.18.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH bpf-next v4 2/2] bpf, arm64: feed byte-offset into bpf line info
  2022-02-26 12:19 ` Hou Tao
@ 2022-02-26 12:19   ` Hou Tao
  -1 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-26 12:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, houtao1,
	Zi Shen Lim, Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is calculated in
instruction granularity instead of bytes granularity, but bpf line info
requires byte offset.

bpf_prog_fill_jited_linfo() will be the last user of ctx.offset before
its free, so convert the offset into byte-offset before call
bpf_prog_fill_jited_linfo().

Fixes: 37ab566c178d ("bpf: arm64: Enable arm64 jit to provide bpf_line_info")
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 arch/arm64/net/bpf_jit_comp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 68b35c83e637..e850c69e128c 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -1274,6 +1274,11 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 	prog->jited_len = prog_size;
 
 	if (!prog->is_func || extra_pass) {
+		int i;
+
+		/* offset[prog->len] is the size of program */
+		for (i = 0; i <= prog->len; i++)
+			ctx.offset[i] *= AARCH64_INSN_SIZE;
 		bpf_prog_fill_jited_linfo(prog, ctx.offset + 1);
 out_off:
 		kfree(ctx.offset);
-- 
2.18.2


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

* [PATCH bpf-next v4 2/2] bpf, arm64: feed byte-offset into bpf line info
@ 2022-02-26 12:19   ` Hou Tao
  0 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-26 12:19 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, houtao1,
	Zi Shen Lim, Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is calculated in
instruction granularity instead of bytes granularity, but bpf line info
requires byte offset.

bpf_prog_fill_jited_linfo() will be the last user of ctx.offset before
its free, so convert the offset into byte-offset before call
bpf_prog_fill_jited_linfo().

Fixes: 37ab566c178d ("bpf: arm64: Enable arm64 jit to provide bpf_line_info")
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 arch/arm64/net/bpf_jit_comp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 68b35c83e637..e850c69e128c 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -1274,6 +1274,11 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 	prog->jited_len = prog_size;
 
 	if (!prog->is_func || extra_pass) {
+		int i;
+
+		/* offset[prog->len] is the size of program */
+		for (i = 0; i <= prog->len; i++)
+			ctx.offset[i] *= AARCH64_INSN_SIZE;
 		bpf_prog_fill_jited_linfo(prog, ctx.offset + 1);
 out_off:
 		kfree(ctx.offset);
-- 
2.18.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info
  2022-02-26 12:19 ` Hou Tao
@ 2022-02-28  1:15   ` Hou Tao
  -1 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-28  1:15 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, Zi Shen Lim,
	Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

Hi,

On 2/26/2022 8:19 PM, Hou Tao wrote:
> Hi,
>
> The patchset addresses two issues in bpf line info for arm64:
>
> (1) insn_to_jit_off only considers the body itself and ignores
>     prologue before the body. Fixed in patch #1.
>
> (2) insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is
>     calculated in instruction granularity instead of bytes
>     granularity. Fixed in patch #2.
>
> Comments are always welcome.
>
> Regards,
> Tao
>
> Change Log:
> v4:
>  * patch #2: convert ctx.offset into byte offset before call
>    bpf_prog_fill_jited_linfo() instead of converting it back and forth.
Oops, forget to add Acked-by tag from Martin
>
> v3: https://lore.kernel.org/bpf/20220208012539.491753-1-houtao1@huawei.com
>  * patch #2: explain why bpf2a64_offset() needs update
>  * add Fixes tags in both patches
>
> v2: https://lore.kernel.org/bpf/20220125105707.292449-1-houtao1@huawei.com
>  * split into two independent patches (from Daniel)
>  * use AARCH64_INSN_SIZE instead of defining INSN_SIZE
>
> v1: https://lore.kernel.org/bpf/20220104014236.1512639-1-houtao1@huawei.com
>
> Hou Tao (2):
>   bpf, arm64: call build_prologue() first in first JIT pass
>   bpf, arm64: feed byte-offset into bpf line info
>
>  arch/arm64/net/bpf_jit_comp.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>


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

* Re: [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info
@ 2022-02-28  1:15   ` Hou Tao
  0 siblings, 0 replies; 10+ messages in thread
From: Hou Tao @ 2022-02-28  1:15 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, Zi Shen Lim,
	Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

Hi,

On 2/26/2022 8:19 PM, Hou Tao wrote:
> Hi,
>
> The patchset addresses two issues in bpf line info for arm64:
>
> (1) insn_to_jit_off only considers the body itself and ignores
>     prologue before the body. Fixed in patch #1.
>
> (2) insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is
>     calculated in instruction granularity instead of bytes
>     granularity. Fixed in patch #2.
>
> Comments are always welcome.
>
> Regards,
> Tao
>
> Change Log:
> v4:
>  * patch #2: convert ctx.offset into byte offset before call
>    bpf_prog_fill_jited_linfo() instead of converting it back and forth.
Oops, forget to add Acked-by tag from Martin
>
> v3: https://lore.kernel.org/bpf/20220208012539.491753-1-houtao1@huawei.com
>  * patch #2: explain why bpf2a64_offset() needs update
>  * add Fixes tags in both patches
>
> v2: https://lore.kernel.org/bpf/20220125105707.292449-1-houtao1@huawei.com
>  * split into two independent patches (from Daniel)
>  * use AARCH64_INSN_SIZE instead of defining INSN_SIZE
>
> v1: https://lore.kernel.org/bpf/20220104014236.1512639-1-houtao1@huawei.com
>
> Hou Tao (2):
>   bpf, arm64: call build_prologue() first in first JIT pass
>   bpf, arm64: feed byte-offset into bpf line info
>
>  arch/arm64/net/bpf_jit_comp.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info
  2022-02-26 12:19 ` Hou Tao
@ 2022-02-28 12:59   ` Daniel Borkmann
  -1 siblings, 0 replies; 10+ messages in thread
From: Daniel Borkmann @ 2022-02-28 12:59 UTC (permalink / raw)
  To: Hou Tao, Alexei Starovoitov, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, Zi Shen Lim,
	Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

On 2/26/22 1:19 PM, Hou Tao wrote:
> Hi,
> 
> The patchset addresses two issues in bpf line info for arm64:
> 
> (1) insn_to_jit_off only considers the body itself and ignores
>      prologue before the body. Fixed in patch #1.
> 
> (2) insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is
>      calculated in instruction granularity instead of bytes
>      granularity. Fixed in patch #2.
> 
> Comments are always welcome.
> 
> Regards,
> Tao

LGTM, applied, thanks Hou!

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

* Re: [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info
@ 2022-02-28 12:59   ` Daniel Borkmann
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Borkmann @ 2022-02-28 12:59 UTC (permalink / raw)
  To: Hou Tao, Alexei Starovoitov, Martin KaFai Lau, Will Deacon
  Cc: Song Liu, John Fastabend, Yonghong Song, Andrii Nakryiko,
	David S . Miller, Jakub Kicinski, netdev, bpf, Zi Shen Lim,
	Catalin Marinas, Ard Biesheuvel, linux-arm-kernel

On 2/26/22 1:19 PM, Hou Tao wrote:
> Hi,
> 
> The patchset addresses two issues in bpf line info for arm64:
> 
> (1) insn_to_jit_off only considers the body itself and ignores
>      prologue before the body. Fixed in patch #1.
> 
> (2) insn_to_jit_off passed to bpf_prog_fill_jited_linfo() is
>      calculated in instruction granularity instead of bytes
>      granularity. Fixed in patch #2.
> 
> Comments are always welcome.
> 
> Regards,
> Tao

LGTM, applied, thanks Hou!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-28 13:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-26 12:19 [PATCH bpf-next v4 0/2] bpf, arm64: fix bpf line info Hou Tao
2022-02-26 12:19 ` Hou Tao
2022-02-26 12:19 ` [PATCH bpf-next v4 1/2] bpf, arm64: call build_prologue() first in first JIT pass Hou Tao
2022-02-26 12:19   ` Hou Tao
2022-02-26 12:19 ` [PATCH bpf-next v4 2/2] bpf, arm64: feed byte-offset into bpf line info Hou Tao
2022-02-26 12:19   ` Hou Tao
2022-02-28  1:15 ` [PATCH bpf-next v4 0/2] bpf, arm64: fix " Hou Tao
2022-02-28  1:15   ` Hou Tao
2022-02-28 12:59 ` Daniel Borkmann
2022-02-28 12:59   ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.