[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM1=_QRN+aioWWNfeS5Tddo2u6UG86bVj66BJoYyzaUDSkDZ1w@mail.gmail.com>
Date: Thu, 29 Jul 2021 15:24:29 +0200
From: Johan Almbladh <johan.almbladh@...finetworks.com>
To: Yonghong Song <yhs@...com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Tony Ambardar <Tony.Ambardar@...il.com>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH 10/14] bpf/tests: Add branch conversion JIT test
On Thu, Jul 29, 2021 at 2:55 AM Yonghong Song <yhs@...com> wrote:
> > +static int bpf_fill_long_jmp(struct bpf_test *self)
> > +{
> > + unsigned int len = BPF_MAXINSNS;
>
> BPF_MAXINSNS is 4096 as defined in uapi/linux/bpf_common.h.
> Will it be able to trigger a PC relative branch + long
> conditional jump?
It does, on the MIPS32 JIT. The ALU64 MUL instruction with a large
immediate was chosen since it expands to a lot of MIPS32 instructions:
2 to load the immediate, 1 to zero/sign extend it, and then 9 for the
64x64 multiply.
Other JITs will be different of course. On the other hand, other
architectures have other limitations that this test may not trigger
anyway. I added the test because I was implementing a non-trivial
iterative branch conversion logic in the MIPS32 JIT. One can argue
that when such complex JIT mechanisms are added, the test suite should
also be updated to cover that, especially if the mechanism handles
something that almost never occur in practice.
Since I was able to trigger the branch conversion with BPF_MAXINSNS
instructions, and no other test was using more, I left it at that.
However, should I or someone else work on the MIPS64 JIT, I think
updating the test suite so that similar special cases there are
triggered would be a valuable contribution.
Powered by blists - more mailing lists