From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: bpf@vger.kernel.org
Cc: daniel@iogearbox.net, andrii@kernel.org, martin.lau@kernel.org,
memxor@gmail.com, eddyz87@gmail.com, kernel-team@fb.com
Subject: [PATCH bpf-next 3/4] bpf: Support can_loop/cond_break on big endian
Date: Fri, 7 Jun 2024 17:44:45 -0700 [thread overview]
Message-ID: <20240608004446.54199-4-alexei.starovoitov@gmail.com> (raw)
In-Reply-To: <20240608004446.54199-1-alexei.starovoitov@gmail.com>
From: Alexei Starovoitov <ast@kernel.org>
Add big endian support for can_loop/cond_break macros.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
.../testing/selftests/bpf/bpf_experimental.h | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
index 3d9e4b8c6b81..82b73c37b50b 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
--
2.43.0
next prev parent reply other threads:[~2024-06-08 0:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-08 0:44 [PATCH bpf-next 0/4] bpf: Track delta between "linked" registers Alexei Starovoitov
2024-06-08 0:44 ` [PATCH bpf-next 1/4] bpf: Relax tuple len requirement for sk helpers Alexei Starovoitov
2024-06-08 0:44 ` [PATCH bpf-next 2/4] bpf: Track delta between "linked" registers Alexei Starovoitov
2024-06-10 18:32 ` Eduard Zingerman
2024-06-10 18:56 ` Eduard Zingerman
2024-06-10 20:31 ` Alexei Starovoitov
2024-06-10 21:51 ` Eduard Zingerman
2024-06-10 20:27 ` Alexei Starovoitov
2024-06-10 21:25 ` Alexei Starovoitov
2024-06-08 0:44 ` Alexei Starovoitov [this message]
2024-06-10 5:44 ` [PATCH bpf-next 3/4] bpf: Support can_loop/cond_break on big endian Yonghong Song
2024-06-08 0:44 ` [PATCH bpf-next 4/4] selftests/bpf: Add tests for add_const Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240608004446.54199-4-alexei.starovoitov@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox