From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH net-next] bpf, arm64: implement jiting of BPF_XADD
Date: Fri, 2 Jun 2017 13:02:12 +0100 [thread overview]
Message-ID: <20170602120212.GF6371@arm.com> (raw)
In-Reply-To: <47ce6fc238596120f02fb6c7116f05b30be2f377.1493599299.git.daniel@iogearbox.net>
Hi Daniel,
[sorry, only just noticed that was queued]
On Mon, May 01, 2017 at 02:57:20AM +0200, Daniel Borkmann wrote:
> This work adds BPF_XADD for BPF_W/BPF_DW to the arm64 JIT and therefore
> completes JITing of all BPF instructions, meaning we can thus also remove
> the 'notyet' label and do not need to fall back to the interpreter when
> BPF_XADD is used in a program!
>
> This now also brings arm64 JIT in line with x86_64, s390x, ppc64, sparc64,
> where all current eBPF features are supported.
>
> BPF_W example from test_bpf:
>
> .u.insns_int = {
> BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
> BPF_ST_MEM(BPF_W, R10, -40, 0x10),
> BPF_STX_XADD(BPF_W, R10, R0, -40),
> BPF_LDX_MEM(BPF_W, R0, R10, -40),
> BPF_EXIT_INSN(),
> },
>
> [...]
> 00000020: 52800247 mov w7, #0x12 // #18
> 00000024: 928004eb mov x11, #0xffffffffffffffd8 // #-40
> 00000028: d280020a mov x10, #0x10 // #16
> 0000002c: b82b6b2a str w10, [x25,x11]
> // start of xadd mapping:
> 00000030: 928004ea mov x10, #0xffffffffffffffd8 // #-40
> 00000034: 8b19014a add x10, x10, x25
> 00000038: f9800151 prfm pstl1strm, [x10]
> 0000003c: 885f7d4b ldxr w11, [x10]
> 00000040: 0b07016b add w11, w11, w7
> 00000044: 880b7d4b stxr w11, w11, [x10]
This form of STXR (where s == t) is CONSTRAINED UNPREDICTABLE per the
architecture; you need to use separate registers for the data and the
status flag. You might also be interested in the atomic instructions
introduced in ARMv8.1, which includes the LDADD instruction. You can
check elf_hwcap & HWCAP_ATOMICS to see if it's supported.
Also, did we get a conclusion on the barrier semantics for this? Currently
you don't have any here: is that ok?
Will
next prev parent reply other threads:[~2017-06-02 12:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-01 0:57 [PATCH net-next] bpf, arm64: implement jiting of BPF_XADD Daniel Borkmann
2017-06-02 12:02 ` Will Deacon [this message]
2017-06-06 9:50 ` Daniel Borkmann
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=20170602120212.GF6371@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).