From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Luke Nelson <luke.r.nels@gmail.com>
Cc: "Xi Wang" <xi.wang@gmail.com>,
"Jesper Dangaard Brouer" <brouer@redhat.com>,
"Will Deacon" <will@kernel.org>, bpf <bpf@vger.kernel.org>,
ardb@kernel.org, naresh.kamboju@linaro.org,
"Jean-Philippe Brucker" <jean-philippe@linaro.org>,
"Yauheni Kaliuta" <yauheni.kaliuta@redhat.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Alexei Starovoitov" <ast@kernel.org>,
"Zi Shen Lim" <zlim.lnx@gmail.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"Andrii Nakryiko" <andriin@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@chromium.org>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
Networking <netdev@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Anders Roxell" <anders.roxell@linaro.org>,
"Björn Töpel" <bjorn.topel@gmail.com>
Subject: Re: [PATCH] arm64: bpf: Fix branch offset in JIT
Date: Mon, 14 Sep 2020 21:36:55 +0300 [thread overview]
Message-ID: <20200914183655.GA22481@apalos.home> (raw)
In-Reply-To: <CAB-e3NSPcYB6r=ZjFtXQ=s=LU-a9D9OfXJPtGGbY3dupB1Z1Qg@mail.gmail.com>
Hi Luke,
On Mon, Sep 14, 2020 at 11:21:58AM -0700, Luke Nelson wrote:
> On Mon, Sep 14, 2020 at 11:08 AM Xi Wang <xi.wang@gmail.com> wrote:
> > I don't think there's some consistent semantics of "offsets" across
> > the JITs of different architectures (maybe it's good to clean that
> > up). RV64 and RV32 JITs are doing something similar to arm64 with
> > respect to offsets. CCing Björn and Luke.
>
> As I understand it, there are two strategies JITs use to keep track of
> the ctx->offset table.
>
> Some JITs (RV32, RV64, arm32, arm64 currently, x86-32) track the end
> of each instruction (e.g., ctx->offset[i] marks the beginning of
> instruction i + 1).
> This requires care to handle jumps to the first instruction to avoid
> using ctx->offset[-1]. The RV32 and RV64 JITs have special handling
> for this case,
> while the arm32, arm64, and x86-32 JITs appear not to. The arm32 and
> x32 probably need to be fixed for the same reason arm64 does.
>
> The other strategy is for ctx->offset[i] to track the beginning of
> instruction i. The x86-64 JIT currently works this way.
> This can be easier to use (no need to special case -1) but looks to be
> trickier to construct. This patch changes the arm64 JIT to work this
> way.
>
> I don't think either strategy is inherently better, both can be
> "correct" as long as the JIT uses ctx->offset in the right way.
> This might be a good opportunity to change the JITs to be consistent
> about this (especially if the arm32, arm64, and x32 JITs all need to
> be fixed anyways).
> Having all JITs agree on the meaning of ctx->offset could help future
> readers debug / understand the code, and could help to someday verify
> the
> ctx->offset construction.
>
> Any thoughts?
The common strategy does make a lot of sense and yes, both patches will works
assuming the ctx->offset ends up being what the JIT engine expects it to be.
As I mentioned earlier we did consider both, but ended up using the later,
since as you said, removes the need for handling the special (-1) case.
Cheers
/Ilias
>
> - Luke
next prev parent reply other threads:[~2020-09-14 18:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-14 8:36 [PATCH] arm64: bpf: Fix branch offset in JIT Ilias Apalodimas
2020-09-14 12:20 ` Will Deacon
2020-09-14 12:35 ` Ilias Apalodimas
2020-09-14 13:23 ` Ilias Apalodimas
2020-09-14 14:01 ` Will Deacon
2020-09-14 16:02 ` Ilias Apalodimas
2020-09-14 16:12 ` Jesper Dangaard Brouer
2020-09-14 17:02 ` Ilias Apalodimas
2020-09-14 17:47 ` Xi Wang
2020-09-14 17:55 ` Ilias Apalodimas
2020-09-14 18:08 ` Xi Wang
2020-09-14 18:21 ` Luke Nelson
2020-09-14 18:36 ` Ilias Apalodimas [this message]
2020-09-14 18:27 ` Ilias Apalodimas
2020-09-14 18:52 ` Xi Wang
2020-09-14 19:24 ` Ilias Apalodimas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200914183655.GA22481@apalos.home \
--to=ilias.apalodimas@linaro.org \
--cc=anders.roxell@linaro.org \
--cc=andriin@fb.com \
--cc=ardb@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=jean-philippe@linaro.org \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luke.r.nels@gmail.com \
--cc=naresh.kamboju@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=will@kernel.org \
--cc=xi.wang@gmail.com \
--cc=yauheni.kaliuta@redhat.com \
--cc=yhs@fb.com \
--cc=zlim.lnx@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).