]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Don't rely on preserving volatile in PT_REGS macros in loop3
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 6 Jan 2022 20:51:56 +0000 (12:51 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 6 Jan 2022 21:25:53 +0000 (22:25 +0100)
commit83a43ddf431655a49c19b1d99714e16191a54b66
tree4268e76853208cdcc9d54122b80e7772497da51e
parentc690aebe8b4d3d4489b2daf3dbb844d03fe07a07
selftests/bpf: Don't rely on preserving volatile in PT_REGS macros in loop3

PT_REGS*() macro on some architectures force-cast struct pt_regs to
other types (user_pt_regs, etc) and might drop volatile modifiers, if any.
Volatile isn't really required as pt_regs value isn't supposed to change
during the BPF program run, so this is correct behavior.

But progs/loop3.c relies on that volatile modifier to ensure that loop
is preserved. Fix loop3.c by declaring i and sum variables as volatile
instead. It preserves the loop and makes the test pass on all
architectures (including s390x which is currently broken).

Fixes: 4905bf9caf24 ("libbpf: Normalize PT_REGS_xxx() macro definitions")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220106205156.955373-1-andrii@kernel.org
tools/testing/selftests/bpf/progs/loop3.c