diff options
author | yonghong-song <yhs@fb.com> | 2024-03-15 07:24:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-15 07:24:28 -0700 |
commit | 0e0bfacff71859d1f9212205f8f873d47029d3fb (patch) | |
tree | 194cf9a8705a7fd0b8af745fa36a2778fe24441a /llvm/unittests/Support/VirtualFileSystemTest.cpp | |
parent | 65284be2992fc7c6feafc44dda7c0f00df7aacfb (diff) | |
download | llvm-0e0bfacff71859d1f9212205f8f873d47029d3fb.zip llvm-0e0bfacff71859d1f9212205f8f873d47029d3fb.tar.gz llvm-0e0bfacff71859d1f9212205f8f873d47029d3fb.tar.bz2 |
[BPF] Add support for may_goto insn (#85358)
Alexei added may_goto insn in [1]. The asm syntax for may_goto looks
like
may_goto <label>
The instruction represents a conditional branch but the condition is
implicit. Later in bpf kernel verifier, the 'may_goto <label>' insn will
be rewritten with an explicit condition. The encoding of 'may_goto' insn
is enforced in [2] and is also implemented in this patch.
In [3], 'may_goto' insn is encoded with raw bytes. I made the following
change
```
--- a/tools/testing/selftests/bpf/bpf_experimental.h
+++ b/tools/testing/selftests/bpf/bpf_experimental.h
@@ -328,10 +328,7 @@ l_true: \
#define cond_break \
({ __label__ l_break, l_continue; \
- asm volatile goto("1:.byte 0xe5; \
- .byte 0; \
- .long ((%l[l_break] - 1b - 8) / 8) & 0xffff; \
- .short 0" \
+ asm volatile goto("may_goto %l[l_break]" \
:::: l_break); \
goto l_continue; \
l_break: break;
```
and ran the selftest with the latest llvm with this patch. All tests are
passed.
[1]
https://lore.kernel.org/bpf/20240306031929.42666-1-alexei.starovoitov@gmail.com/
[2]
https://lore.kernel.org/bpf/20240306031929.42666-2-alexei.starovoitov@gmail.com/
[3]
https://lore.kernel.org/bpf/20240306031929.42666-4-alexei.starovoitov@gmail.com/
Diffstat (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp')
0 files changed, 0 insertions, 0 deletions