From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
john.fastabend@gmail.com, kpsingh@chromium.org,
naveen.n.rao@linux.ibm.com, sandipan@linux.ibm.com,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [RFC PATCH v1 7/7] powerpc/bpf: Implement extended BPF on PPC32
Date: Wed, 16 Dec 2020 22:11:33 -0800 [thread overview]
Message-ID: <20201217061133.lnfnhbzvikgtjb3i@ast-mbp> (raw)
In-Reply-To: <1fed5e11ba08ee28d12f3f57986e5b143a6aa937.1608112797.git.christophe.leroy@csgroup.eu>
On Wed, Dec 16, 2020 at 10:07:37AM +0000, Christophe Leroy wrote:
> Implement Extended Berkeley Packet Filter on Powerpc 32
>
> Test result with test_bpf module:
>
> test_bpf: Summary: 378 PASSED, 0 FAILED, [354/366 JIT'ed]
nice!
> Registers mapping:
>
> [BPF_REG_0] = r11-r12
> /* function arguments */
> [BPF_REG_1] = r3-r4
> [BPF_REG_2] = r5-r6
> [BPF_REG_3] = r7-r8
> [BPF_REG_4] = r9-r10
> [BPF_REG_5] = r21-r22 (Args 9 and 10 come in via the stack)
> /* non volatile registers */
> [BPF_REG_6] = r23-r24
> [BPF_REG_7] = r25-r26
> [BPF_REG_8] = r27-r28
> [BPF_REG_9] = r29-r30
> /* frame pointer aka BPF_REG_10 */
> [BPF_REG_FP] = r31
> /* eBPF jit internal registers */
> [BPF_REG_AX] = r19-r20
> [TMP_REG] = r18
>
> As PPC32 doesn't have a redzone in the stack,
> use r17 as tail call counter.
>
> r0 is used as temporary register as much as possible. It is referenced
> directly in the code in order to avoid misuse of it, because some
> instructions interpret it as value 0 instead of register r0
> (ex: addi, addis, stw, lwz, ...)
>
> The following operations are not implemented:
>
> case BPF_ALU64 | BPF_DIV | BPF_X: /* dst /= src */
> case BPF_ALU64 | BPF_MOD | BPF_X: /* dst %= src */
> case BPF_STX | BPF_XADD | BPF_DW: /* *(u64 *)(dst + off) += src */
>
> The following operations are only implemented for power of two constants:
>
> case BPF_ALU64 | BPF_MOD | BPF_K: /* dst %= imm */
> case BPF_ALU64 | BPF_DIV | BPF_K: /* dst /= imm */
Those are sensible limitations. MOD and DIV are rare, but XADD is common.
Please consider doing it as a cmpxchg loop in the future.
Also please run test_progs. It will give a lot better coverage than test_bpf.ko
next prev parent reply other threads:[~2020-12-17 6:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 10:07 [RFC PATCH v1 0/7] Implement EBPF on powerpc32 Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 1/7] powerpc/bpf: Remove classical BPF support for PPC32 Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 2/7] powerpc/bpf: Change register numbering for bpf_set/is_seen_register() Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 3/7] powerpc/bpf: Move common helpers into bpf_jit.h Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 4/7] powerpc/bpf: Move common functions into bpf_jit_comp.c Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 5/7] powerpc/bpf: Change values of SEEN_ flags Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 6/7] powerpc/asm: Add some opcodes in asm/ppc-opcode.h for PPC32 eBPF Christophe Leroy
2020-12-16 10:07 ` [RFC PATCH v1 7/7] powerpc/bpf: Implement extended BPF on PPC32 Christophe Leroy
2020-12-17 6:11 ` Alexei Starovoitov [this message]
2020-12-17 9:54 ` Christophe Leroy
2020-12-18 19:33 ` Andrii Nakryiko
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=20201217061133.lnfnhbzvikgtjb3i@ast-mbp \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=bpf@vger.kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=paulus@samba.org \
--cc=sandipan@linux.ibm.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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