]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
bpf, arm64: Call build_prologue() first in first JIT pass
authorHou Tao <houtao1@huawei.com>
Sat, 26 Feb 2022 12:19:05 +0000 (20:19 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 13:18:58 +0000 (15:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1971497
[ Upstream commit 68e4f238b0e9d3670a1612ad900a6e98b2b3f7dd ]

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>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220226121906.5709-2-houtao1@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/arm64/net/bpf_jit_comp.c

index a343677837c7781815a192c9e734931136f4702c..6332288dfb44089f3e1aba990dded98b66529b46 100644 (file)
@@ -909,15 +909,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;
        }