Skip to content

Commit

Permalink
Update verifier to latest (#3329)
Browse files Browse the repository at this point in the history
* Update verifier to latest

Signed-off-by: Dave Thaler <[email protected]>

* Update tests

Signed-off-by: Dave Thaler <[email protected]>

* Update bpf_conformance to latest release

Signed-off-by: Dave Thaler <[email protected]>

---------

Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler authored Apr 2, 2024
1 parent f75fffc commit 21e1276
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd-release-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.5/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe
pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.6/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe
test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --exclude_regex local --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include"
name: bpf2c_conformance
build_artifact: Build-x64
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.5/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe
pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.6/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe
test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --exclude_regex local --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include"
name: bpf2c_conformance
build_artifact: Build-x64
Expand Down Expand Up @@ -637,4 +637,4 @@ jobs:
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
43 changes: 22 additions & 21 deletions docs/isa-support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ opcode src imm off description
0x7e any 0x00 any if (s32)dst s>= (s32)src goto +offset Y Y Y jsge32-reg
0x7f any 0x00 0 dst >>= src Y Y Y rsh-reg
0x84 0x0 0x00 0 dst = (u32)-dst Y Y Y neg
0x85 0x0 any 0 call helper function by address Y Y Y call_unwind_fail
0x85 0x0 any 0 call helper function by legacy ID Y Y Y call_unwind_fail
0x85 0x1 any 0 call PC += imm no no no call_local
0x85 0x2 any 0 call helper function by BTF ID no no no ???
0x87 0x0 0x00 0 dst = -dst Y Y Y neg64
0x8d 0x0 0x00 0 call helper function by legacy ID in register Y Y Y callx
0x94 0x0 any 0 dst = (u32)((imm != 0) ? ((u32)dst % (u32)imm) : dst) Y Y Y mod
0x94 0x0 any 1 dst = (u32)((imm != 0) ? ((s32)dst s% imm) : dst) Y no Y smod32-neg-by-neg-imm
0x95 0x0 0x00 0 return Y Y Y exit
Expand Down Expand Up @@ -135,16 +136,16 @@ opcode src imm off description
0xbf any 0x00 8 dst = (s64) (s8) src Y no Y movsx864-reg
0xbf any 0x00 16 dst = (s64) (s16) src Y no Y movsx1664-reg
0xbf any 0x00 32 dst = (s64) (s32) src Y no Y movsx3264-reg
0xc3 any 0x00 any lock \*(u32 \*)(dst + offset) += src no no Y lock_add32
0xc3 any 0x01 any src = atomic_fetch_add_32((u32 \*)(dst + offset), src) no no Y lock_fetch_add32
0xc3 any 0x40 any lock \*(u32 \*)(dst + offset) \|= src no no Y lock_or32
0xc3 any 0x41 any src = atomic_fetch_or_32((u32 \*)(dst + offset), src) no no Y lock_fetch_or32
0xc3 any 0x50 any lock \*(u32 \*)(dst + offset) &= src no no Y lock_and32
0xc3 any 0x51 any src = atomic_fetch_and_32((u32 \*)(dst + offset), src) no no Y lock_fetch_and32
0xc3 any 0xa0 any lock \*(u32 \*)(dst + offset) ^= src no no Y lock_xor32
0xc3 any 0xa1 any src = atomic_fetch_xor_32((u32 \*)(dst + offset), src) no no Y lock_fetch_xor32
0xc3 any 0xe1 any src = xchg_32((u32 \*)(dst + offset), src) no no Y lock_xchg32
0xc3 any 0xf1 any r0 = cmpxchg_32((u32 \*)(dst + offset), r0, src) no no Y lock_cmpxchg32
0xc3 any 0x00 any lock \*(u32 \*)(dst + offset) += src Y no Y lock_add32
0xc3 any 0x01 any src = atomic_fetch_add_32((u32 \*)(dst + offset), src) Y no Y lock_fetch_add32
0xc3 any 0x40 any lock \*(u32 \*)(dst + offset) \|= src Y no Y lock_or32
0xc3 any 0x41 any src = atomic_fetch_or_32((u32 \*)(dst + offset), src) Y no Y lock_fetch_or32
0xc3 any 0x50 any lock \*(u32 \*)(dst + offset) &= src Y no Y lock_and32
0xc3 any 0x51 any src = atomic_fetch_and_32((u32 \*)(dst + offset), src) Y no Y lock_fetch_and32
0xc3 any 0xa0 any lock \*(u32 \*)(dst + offset) ^= src Y no Y lock_xor32
0xc3 any 0xa1 any src = atomic_fetch_xor_32((u32 \*)(dst + offset), src) Y no Y lock_fetch_xor32
0xc3 any 0xe1 any src = xchg_32((u32 \*)(dst + offset), src) Y no Y lock_xchg32
0xc3 any 0xf1 any r0 = cmpxchg_32((u32 \*)(dst + offset), r0, src) Y no Y lock_cmpxchg32
0xc4 0x0 any 0 dst = (u32)(dst s>> imm) Y Y Y arsh
0xc5 0x0 any any if dst s< imm goto +offset Y Y Y jslt-imm
0xc6 0x0 any any if (s32)dst s< (s32)imm goto +offset Y Y Y jslt32-imm
Expand All @@ -161,16 +162,16 @@ opcode src imm off description
0xd7 0x0 0x10 0 dst = bswap16(dst) Y no Y swap16
0xd7 0x0 0x20 0 dst = bswap32(dst) Y no Y swap32
0xd7 0x0 0x40 0 dst = bswap64(dst) Y no Y swap64
0xdb any 0x00 any lock \*(u64 \*)(dst + offset) += src no no Y lock_add
0xdb any 0x01 any src = atomic_fetch_add_64((u64 \*)(dst + offset), src) no no Y lock_fetch_add
0xdb any 0x40 any lock \*(u64 \*)(dst + offset) \|= src no no Y lock_or
0xdb any 0x41 any src = atomic_fetch_or_64((u64 \*)(dst + offset), src) no no Y lock_fetch_or
0xdb any 0x50 any lock \*(u64 \*)(dst + offset) &= src no no Y lock_and
0xdb any 0x51 any src = atomic_fetch_and_64((u64 \*)(dst + offset), src) no no Y lock_fetch_and
0xdb any 0xa0 any lock \*(u64 \*)(dst + offset) ^= src no no Y lock_xor
0xdb any 0xa1 any src = atomic_fetch_xor_64((u64 \*)(dst + offset), src) no no Y lock_fetch_xor
0xdb any 0xe1 any src = xchg_64((u64 \*)(dst + offset), src) no no Y lock_xchg
0xdb any 0xf1 any r0 = cmpxchg_64((u64 \*)(dst + offset), r0, src) no no Y lock_cmpxchg
0xdb any 0x00 any lock \*(u64 \*)(dst + offset) += src Y no Y lock_add
0xdb any 0x01 any src = atomic_fetch_add_64((u64 \*)(dst + offset), src) Y no Y lock_fetch_add
0xdb any 0x40 any lock \*(u64 \*)(dst + offset) \|= src Y no Y lock_or
0xdb any 0x41 any src = atomic_fetch_or_64((u64 \*)(dst + offset), src) Y no Y lock_fetch_or
0xdb any 0x50 any lock \*(u64 \*)(dst + offset) &= src Y no Y lock_and
0xdb any 0x51 any src = atomic_fetch_and_64((u64 \*)(dst + offset), src) Y no Y lock_fetch_and
0xdb any 0xa0 any lock \*(u64 \*)(dst + offset) ^= src Y no Y lock_xor
0xdb any 0xa1 any src = atomic_fetch_xor_64((u64 \*)(dst + offset), src) Y no Y lock_fetch_xor
0xdb any 0xe1 any src = xchg_64((u64 \*)(dst + offset), src) Y no Y lock_xchg
0xdb any 0xf1 any r0 = cmpxchg_64((u64 \*)(dst + offset), r0, src) Y no Y lock_cmpxchg
0xdc 0x0 0x10 0 dst = htobe16(dst) Y Y Y be16
0xdc 0x0 0x20 0 dst = htobe32(dst) Y Y Y be32
0xdc 0x0 0x40 0 dst = htobe64(dst) Y Y Y be64
Expand Down
14 changes: 7 additions & 7 deletions tests/end_to_end/netsh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,35 +398,35 @@ TEST_CASE("show verification xdp_datasize_unsafe.o", "[netsh][verification]")
"\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:32\n"
"; if (next_header + sizeof(ETHERNET_HEADER) > (char*)ctx->data_end) {\n"
"4: (r3.type in {number, ctx, stack, packet, shared})\n"
"4: Invalid type (r3.type in {number, ctx, stack, packet, shared})\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:32\n"
"; if (next_header + sizeof(ETHERNET_HEADER) > (char*)ctx->data_end) {\n"
"5: Invalid type (valid_access(r3.offset) for comparison/subtraction)\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:32\n"
"; if (next_header + sizeof(ETHERNET_HEADER) > (char*)ctx->data_end) {\n"
"5: (r3.type == non_map_fd)\n"
"5: Invalid type (r3.type == non_map_fd)\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:32\n"
"; if (next_header + sizeof(ETHERNET_HEADER) > (char*)ctx->data_end) {\n"
"5: Cannot subtract pointers to different regions (r3.type == r1.type in {ctx, stack, packet})\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:38\n"
"; if (ethernet_header->Type != ntohs(ETHERNET_TYPE_IPV4) && ethernet_header->Type != "
"ntohs(ETHERNET_TYPE_IPV6)) {\n"
"6: (r2.type in {ctx, stack, packet, shared})\n"
"6: Invalid type (r2.type in {ctx, stack, packet, shared})\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:38\n"
"; if (ethernet_header->Type != ntohs(ETHERNET_TYPE_IPV4) && ethernet_header->Type != "
"ntohs(ETHERNET_TYPE_IPV6)) {\n"
"6: Invalid type (valid_access(r2.offset+12, width=2) for read)\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:38\n"
"; if (ethernet_header->Type != ntohs(ETHERNET_TYPE_IPV4) && ethernet_header->Type != "
"ntohs(ETHERNET_TYPE_IPV6)) {\n"
"7: (r1.type == number)\n"
"7: Invalid type (r1.type == number)\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:38\n"
"; if (ethernet_header->Type != ntohs(ETHERNET_TYPE_IPV4) && ethernet_header->Type != "
"ntohs(ETHERNET_TYPE_IPV6)) {\n"
"8: (r1.type == number)\n"
"8: Invalid type (r1.type == number)\n"
"; ./tests/sample/unsafe/xdp_datasize_unsafe.c:43\n"
"; return rc;\n"
"10: (r0.type == number)\n"
"10: Invalid type (r0.type == number)\n"
"\n"
"9 errors\n"
"\n");
Expand All @@ -449,7 +449,7 @@ TEST_CASE("show verification printk_unsafe.o", "[netsh][verification]")
"\n"
"; ./tests/sample/unsafe/printk_unsafe.c:22\n"
"; bpf_printk(\"ctx: %u\", (uint64_t)ctx);\n"
"7: (r3.type == number)\n"
"7: Invalid type (r3.type == number)\n"
"\n"
"1 errors\n"
"\n");
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/libbpf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ TEST_CASE("invalid bpf_load_program", "[libbpf][deprecated]")
REQUIRE(program_fd < 0);
#if !defined(CONFIG_BPF_JIT_DISABLED)
REQUIRE(errno == EACCES);
REQUIRE(strcmp(log_buffer, "\n0: (r0.type == number)\n\n") == 0);
REQUIRE(strcmp(log_buffer, "\n0: Invalid type (r0.type == number)\n\n") == 0);
#else
REQUIRE(errno == ENOTSUP);
#endif
Expand All @@ -244,7 +244,7 @@ TEST_CASE("invalid bpf_prog_load", "[libbpf]")
REQUIRE(program_fd < 0);
#if !defined(CONFIG_BPF_JIT_DISABLED)
REQUIRE(errno == EACCES);
REQUIRE(strcmp(log_buffer, "\n0: (r0.type == number)\n\n") == 0);
REQUIRE(strcmp(log_buffer, "\n0: Invalid type (r0.type == number)\n\n") == 0);
#else
REQUIRE(errno == ENOTSUP);
#endif
Expand Down Expand Up @@ -407,9 +407,9 @@ TEST_CASE("valid bpf_load_program_xattr", "[libbpf][deprecated]")
{ \
INST_OP_CALL, 0, 0, 0, (imm) \
}
#define BPF_STX_MEM(sz, dst, src, off) \
{ \
INST_CLS_STX | (INST_MEM << 5) | (sz), (dst), (src), (off), 0 \
#define BPF_STX_MEM(sz, dst, src, off) \
{ \
INST_CLS_STX | INST_MODE_MEM | (sz), (dst), (src), (off), 0 \
}
#define BPF_W INST_SIZE_W
#define BPF_REG_1 R1_ARG
Expand Down

0 comments on commit 21e1276

Please sign in to comment.