bpf: define READ_ONCE and WRITE_ONCE

These are convenience macros which do
(const|volatile) cast for atomic operations.

I've run into a case where two 32-bit writes get optimized
by the compiler into a single 64-bit write, which then fails
verification.  WRITE_ONCE() avoids that by virtue of the volatile annotation.

Technically I think the same thing could happen on read,
so add READ_ONCE too.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iade089aab3522916bd7b431d4064f89a21bc78b0
1 file changed