]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: document V3 BPF atomic instructions in the GAS manual users/jemarch/new-bpf-atomics
authorJose E. Marchesi <jose.marchesi@oracle.com>
Wed, 10 May 2023 17:02:39 +0000 (19:02 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Wed, 10 May 2023 18:52:26 +0000 (20:52 +0200)
gas/ChangeLog:

2023-05-10  Jose E. Marchesi  <jose.marchesi@oracle.com>

* doc/c-bpf.texi (BPF Opcodes): Document the V3 BPF atomic
instructions.

gas/ChangeLog
gas/doc/c-bpf.texi

index a16647bb4a4e73763468221cb203fa91ceeb7e1b..987b0c8704fa2dbe32a8416263416d8ab9fd07bf 100644 (file)
@@ -1,3 +1,8 @@
+2023-05-10  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+       * doc/c-bpf.texi (BPF Opcodes): Document the V3 BPF atomic
+       instructions.
+
 2023-05-10  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * testsuite/gas/bpf/atomic-v3.s: New file.
index 0756796adc98789b902342ab3b9684688817ecee..917e0dc16287835439732029604c5ba4d874dd2b 100644 (file)
@@ -377,14 +377,60 @@ Terminate the eBPF program.
 
 @subsubsection Atomic instructions
 
-Atomic exchange-and-add instructions are provided in two flavors: one
-for swapping 64-bit quantities and another for 32-bit quantities.
+BPF provides a set of instructions to perform arithmetic and logical
+operations on stored data atomically.  These are:
 
 @table @code
-@item xadddw [%d+offset16],%s
-Exchange-and-add a 64-bit value at the specified location.
 @item xaddw [%d+offset16],%s
-Exchange-and-add a 32-bit value at the specified location.
+@itemx xadddw [%d+offset16],%s
+Add @code{%s} to the 32 or 64 bit signed integer stored in the
+specified memory location and store the result, atomically.
+@item xorw [%d+offset16],%s
+@itemx xordw [%d+offset16],%s
+Perform a bit-wise or operation between @code{%s} and the 32 or 64 bit
+signed integer stored in the specified memory location and store the
+result, atomically.
+@item xxorw [%d+offset16],%s
+@itemx xxordw [%d+offset16],%s
+Perform a bit-wise xor operation between @code{%s} and the 32 or 64 bit
+signed integer stored in the specified memory location and store the
+result, atomically.
+@end table
+
+@noindent
+Additionally, the following instructions allow to perform arithmetic
+and logical operations on stored data and then fetching the original
+stored value in a register, atomically:
+
+@table @code
+@item xfaddw [%d+offset16],%s
+@itemx xfadddw [%d+offset16],%s
+Add @code{%s} to the 32 or 64 bit signed integer stored in the
+specified memory location, store the result, and set @code{%s} to the
+value originally stored in the memory location, atomically.
+@item xforw [%d+offset16],%s
+@itemx xfordw [%d+offset16],%s
+Perform a bit-wise or operation between @code{%s} and the 32 or 64 bit
+signed integer stored in the specified memory location, store the
+result, and set @code{%s} to the value originally stored in the memory
+location, atomically.
+@item xfxorw [%d+offset16],%s
+@itemx xfxordw [%d+offset16],%s
+Perform a bit-wise xor operation between @code{%s} and the 32 or 64
+bit signed integer stored in the specified memory location, store the
+result, and set @code{%s} to the value originally stored in the memory
+location, atomically.
+@item xchgw [%d+offset16],%s
+@itemx xchgdw [%d+offset16],%s
+Exchange the 32 or 64 bit values in @code{%s} and the specified memory
+location, atomically.
+@item xcmpw [%d+offset16],%s
+@itemx xcmpdw [%d+offset16],%s
+Compare and exchange operation.  Compare the 32 or 64 bit value stored
+in the specified memory location to the contents of the @code{%r0}
+register.  If they are equal, store @code{%s} in the memory location.
+In any case, update @code{%r0} with the original contents of the
+memory location.
 @end table
 
 @node BPF Pseudo-C Syntax