]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, arm64: use separate register for state in stxr
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 7 Jun 2017 11:45:37 +0000 (13:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 7 Jun 2017 19:27:20 +0000 (15:27 -0400)
commit6a99f020be13e47f52260a26d946fcee5cf76d4d
tree77db17f9c82e93e483ff877ae2df8ef0fed79bcc
parentc8aa7205a85de68112791b7443f3af1a72c6cd4c
bpf, arm64: use separate register for state in stxr

Will reported that in BPF_XADD we must use a different register in stxr
instruction for the status flag due to otherwise CONSTRAINED UNPREDICTABLE
behavior per architecture. Reference manual says [1]:

  If s == t, then one of the following behaviors must occur:

   * The instruction is UNDEFINED.
   * The instruction executes as a NOP.
   * The instruction performs the store to the specified address, but
     the value stored is UNKNOWN.

Thus, use a different temporary register for the status flag to fix it.

Disassembly extract from test 226/STX_XADD_DW from test_bpf.ko:

  [...]
  0000003c:  c85f7d4b  ldxr x11, [x10]
  00000040:  8b07016b  add x11, x11, x7
  00000044:  c80c7d4b  stxr w12, x11, [x10]
  00000048:  35ffffac  cbnz w12, 0x0000003c
  [...]

  [1] https://static.docs.arm.com/ddi0487/b/DDI0487B_a_armv8_arm.pdf, p.6132

Fixes: aa2c7e10646b ("bpf, arm64: implement jiting of BPF_XADD")
Reported-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/arm64/net/bpf_jit_comp.c