Re: [PATCH bpf-next v4 08/10] bpf, x86: Support load-acquire and store-release instructions

Peilin Ye
2025-03-03T05:46:17Z

Hi Alexei,

On Mon, Mar 03, 2025 at 05:38:07AM +0000, Peilin Ye wrote:
> Recently we introduced BPF load-acquire (BPF_LOAD_ACQ) and store-release
> (BPF_STORE_REL) instructions. For x86-64, simply implement them as
> regular BPF_LDX/BPF_STX loads and stores. The verifier always rejects
> misaligned load-acquires/store-releases (even if BPF_F_ANY_ALIGNMENT is
> set), so emitted MOV* instructions are guaranteed to be atomic.
>
> Arena accesses are supported. 8- and 16-bit load-acquires are
> zero-extending (i.e., MOVZBQ, MOVZWQ).
>
> Rename emit_atomic{,_index}() to emit_atomic_rmw{,_index}() to make it
> clear that they only handle read-modify-write atomics, and extend their
> @atomic_op parameter from u8 to u32, since we are starting to use more
> than the lowest 8 bits of the 'imm' field.

For x86-64, v4 PATCH 08/10 implements ld_acq/st_rel as regular LDX/STX
(aligned) loads/stores. Please take another look. Thanks!

Peilin Ye