diff options
author | Alexei Starovoitov <ast@kernel.org> | 2024-06-12 18:38:14 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2024-06-14 21:52:40 +0200 |
commit | 6870bdb3f4f2991193449f9de57109b3e263f55c (patch) | |
tree | e7bc6dbe46f4e6c89ec64f572250d2856e63a8a4 /tools/testing/selftests/bpf/bpf_experimental.h | |
parent | 98d7ca374ba4b39e7535613d40e159f09ca14da2 (diff) |
bpf: Support can_loop/cond_break on big endian
Add big endian support for can_loop/cond_break macros.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20240613013815.953-4-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_experimental.h')
-rw-r--r-- | tools/testing/selftests/bpf/bpf_experimental.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h index 8ee7a00b7c82..eede6fc2ccb4 100644 --- a/tools/testing/selftests/bpf/bpf_experimental.h +++ b/tools/testing/selftests/bpf/bpf_experimental.h @@ -351,6 +351,7 @@ l_true: \ l_continue:; \ }) #else +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define can_loop \ ({ __label__ l_break, l_continue; \ bool ret = true; \ @@ -376,6 +377,33 @@ l_true: \ l_break: break; \ l_continue:; \ }) +#else +#define can_loop \ + ({ __label__ l_break, l_continue; \ + bool ret = true; \ + asm volatile goto("1:.byte 0xe5; \ + .byte 0; \ + .long (((%l[l_break] - 1b - 8) / 8) & 0xffff) << 16; \ + .short 0" \ + :::: l_break); \ + goto l_continue; \ + l_break: ret = false; \ + l_continue:; \ + ret; \ + }) + +#define cond_break \ + ({ __label__ l_break, l_continue; \ + asm volatile goto("1:.byte 0xe5; \ + .byte 0; \ + .long (((%l[l_break] - 1b - 8) / 8) & 0xffff) << 16; \ + .short 0" \ + :::: l_break); \ + goto l_continue; \ + l_break: break; \ + l_continue:; \ + }) +#endif #endif #ifndef bpf_nop_mov |