Skip to content

Commit b2ac67d

Browse files
Merge branch 'main' into origin/remove-extra-catch2
2 parents b58bef7 + e71e7f7 commit b2ac67d

File tree

181 files changed

+2790
-1310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+2790
-1310
lines changed

.github/workflows/cicd-release-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
uses: ./.github/workflows/reusable-test.yml
119119
with:
120120
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
121-
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"
121+
test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include"
122122
name: bpf2c_conformance
123123
build_artifact: Build-x64
124124
environment: windows-2022

.github/workflows/cicd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ jobs:
186186
uses: ./.github/workflows/reusable-test.yml
187187
with:
188188
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
189-
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"
189+
test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include"
190190
name: bpf2c_conformance
191191
build_artifact: Build-x64
192192
environment: windows-2022

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
egress-policy: audit
2626

2727
- name: 'Checkout Repository'
28-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2929
- name: 'Dependency Review'
30-
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4
30+
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0

.github/workflows/nuget_update.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ jobs:
3737
with:
3838
egress-policy: audit
3939

40-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
40+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4141
with:
4242
# Only check out main repo, not submodules.
4343
ref: ${{ github.event.workflow_run.head_branch }}
4444

4545

4646
- name: Cache nuget packages
47-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8
47+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
4848
env:
4949
cache-name: cache-nuget-modules
5050
with:

.github/workflows/ossar-scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
paths_ignore: '["**.md", "**/docs/**"]'
4848

4949
# Checking out the branch is needed to correctly log security alerts.
50-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
50+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
5151
if: steps.skip_check.outputs.should_skip != 'true'
5252
with:
5353
# Only check out main repo, not submodules.
@@ -81,6 +81,6 @@ jobs:
8181

8282
- name: Upload results to Security tab
8383
if: steps.skip_check.outputs.should_skip != 'true'
84-
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b
84+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd
8585
with:
8686
sarif_file: ${{ steps.ossar.outputs.sarifFile }}

.github/workflows/reusable-build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
powershell.exe "echo 'ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE=true' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
118118
powershell.exe "echo 'VCINSTALLDIR=%VCINSTALLDIR%' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
119119
120-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
120+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
121121
if: steps.skip_check.outputs.should_skip != 'true'
122122
with:
123123
repository: ${{inputs.repository}}
@@ -135,7 +135,7 @@ jobs:
135135
136136
- name: Initialize CodeQL
137137
if: inputs.build_codeql == true && steps.skip_check.outputs.should_skip != 'true'
138-
uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b
138+
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd
139139
with:
140140
languages: 'cpp'
141141

@@ -154,7 +154,7 @@ jobs:
154154

155155
- name: Cache nuget packages
156156
if: steps.skip_check.outputs.should_skip != 'true'
157-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8
157+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
158158
env:
159159
cache-name: cache-nuget-modules
160160
with:
@@ -164,7 +164,7 @@ jobs:
164164
- name: Cache verifier project
165165
# The hash is based on the HEAD of the ebpf-verifier submodule, the Directory.Build.props file, and the build variant.
166166
if: steps.skip_check.outputs.should_skip != 'true'
167-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8
167+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
168168
env:
169169
cache-name: cache-verifier-project
170170
with:
@@ -294,4 +294,4 @@ jobs:
294294

295295
- name: Perform CodeQL Analysis
296296
if: inputs.build_codeql == true && steps.skip_check.outputs.should_skip != 'true'
297-
uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b
297+
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd

.github/workflows/reusable-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ jobs:
100100
paths_ignore: '["**.md", "**/docs/**"]'
101101

102102
# Checking out the branch is needed to gather correct code coverage data.
103-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
103+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
104104
# Only check out source code if code coverage is being gathered.
105105
if: (inputs.code_coverage == true) && (steps.skip_check.outputs.should_skip != 'true')
106106
with:
107107
submodules: 'recursive'
108108
ref: ${{ github.event.workflow_run.head_branch }}
109109

110110
# Perform shallow checkout for self-hosted runner.
111-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
111+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
112112
if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true')
113113
with:
114114
ref: ${{ github.event.workflow_run.head_branch }}
@@ -123,7 +123,7 @@ jobs:
123123
files: .github/workflows/reusable-test.yml
124124

125125
# Check out just this file if code hasn't been checked out yet.
126-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
126+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
127127
if: (steps.check_reusable_test_locally.outputs.files_exists != 'true') && (steps.skip_check.outputs.should_skip != 'true')
128128
with:
129129
sparse-checkout: |
@@ -142,7 +142,7 @@ jobs:
142142
# Add cache entry for any choco packages that are installed.
143143
# The cache key is based on the hash of this file so if any choco packages are added or removed, the cache will be invalidated.
144144
if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true')
145-
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8
145+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
146146
env:
147147
cache-name: cache-choco-packages
148148
with:

.github/workflows/scorecards-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
4646
- name: "Checkout code"
4747
if: github.ref_name == 'main'
48-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4949
with:
5050
persist-credentials: false
5151

@@ -76,6 +76,6 @@ jobs:
7676
# Upload the results to GitHub's code scanning dashboard.
7777
- name: "Upload to code-scanning"
7878
if: github.ref_name == 'main'
79-
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b
79+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd
8080
with:
8181
sarif_file: results.sarif

.github/workflows/update-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: |
4242
sudo apt install doxygen
4343
44-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
44+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4545

4646
- name: Clone docs
4747
run: |

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "external/ebpf-verifier"]
22
path = external/ebpf-verifier
3-
url = https://github.com/vbpf/ebpf-verifier.git
3+
url = https://github.com/dthaler/ebpf-verifier.git
44
[submodule "external/ubpf"]
55
path = external/ubpf
66
url = https://github.com/iovisor/ubpf.git

docs/BpfSyscallCompatibility.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# `bpf()` syscall compatibility with Linux ABI
2+
3+
There is a desire to have first-class eBPF support for Windows for the Go ecosystem.
4+
The Go community prefers for libraries that can be easily cross-compiled and distributed.
5+
However, calling into libbpf via Go's foreign function interface (CGo) goes against this spirit, as it requires distributing C headers, a C toolchain, and other dependencies.
6+
7+
To address this, one of the most popular ways to interact with eBPF on Linux is through the [ebpf-go library], which intentionally avoids CGo.
8+
Given these considerations, this proposal explores what is necessary to port the ebpf-go library to the eBPF for Windows runtime.
9+
Such a port would provide a solution that aligns with Go's cross-platform philosophy while offering robust eBPF support for Windows.
10+
11+
## ebpf-go architecture
12+
13+
ebpf-go uses BTF from a Linux kernel image to generate syscall bindings.
14+
This happens at development time, and the bindings are checked in.
15+
These are used from the rest of the library to provide an "idiomatic" public API.
16+
17+
```mermaid
18+
flowchart LR
19+
public[public API] --> sys[syscall bindings]
20+
sys --> bpf["syscall(SYS_BPF)"]
21+
subgraph auto[auto-generated from BTF]
22+
sys
23+
end
24+
```
25+
26+
The library follows the same ELF conventions as libbpf so you are able to load the same ELF files.
27+
The API however is [completely distinct][architecture] and doesn't follow libbpf semantics.
28+
29+
## ebpf-go on Windows
30+
31+
The goal of porting ebpf-go is to end up with a library that facilitates porting programs written for Linux to Windows.
32+
In the best case the public API stays the same regardless of operating system.
33+
34+
A natural point to start a port is to replace the auto-generated syscall bindings with a Windows-specific wrapper.
35+
[An attempt][stable ioctl] was made to directly issue `DeviceIoControl` from ebpf-go.
36+
This approach was discarded because the exact format of the request and response buffers is currently an implementation detail, which is a good thing considering that the current approach [has performance implications][ioctl allocs].
37+
It also forces us to reimplement the scheme used to load signed native images, which might also still change.
38+
39+
Instead of replacing the auto-generated syscall bindings we can replace the `bpf()` syscall on Windows with an existing [wrapper][bpf wrapper].
40+
This has a number of benefits:
41+
42+
- The necessary changes are much smaller since we don't need to write new code to generate bindings for Windows.
43+
- We don't need to add a new stable API to the Windows runtime and instead can reuse the existing `bpf()` emulation.
44+
45+
For this to work we need the `bpf()` emulation to be binary compatible with the Linux syscall.
46+
Otherwise the auto generated bindings in ebpf-go won't work, negating one of the key benefits of this approach.
47+
This is problematic since so far eBPF for Windows has only targeted source-level compatibility, not binary compatibility.
48+
49+
### Differing `bpf_cmd_id` values
50+
51+
The values of `bpf_cmd_id` do not match Linux, which leads to ebpf-go performing the wrong syscalls.
52+
53+
### Differing field size
54+
55+
On Windows the length of an object's name is restricted to 64 characters, while Linux only allows 16.
56+
Unfortunately this constant is used to size an array embedded in key structures like `bpf_map_info` and `bpf_prog_info`:
57+
58+
```C
59+
struct bpf_map_info
60+
{
61+
// ...
62+
char name[BPF_OBJ_NAME_LEN]; ///< Null-terminated map name.
63+
// ...
64+
```
65+
66+
The result is that fields after `name` have a different offset.
67+
68+
### Differing field order / presence
69+
70+
Sometimes the field order doesn't match. For example, `id` and `type` are swapped in `bpf_map_info`.
71+
72+
```C
73+
struct bpf_map_info
74+
{
75+
// Cross-platform fields.
76+
ebpf_id_t id; ///< Map ID.
77+
ebpf_map_type_t type; ///< Type of map.
78+
// ...
79+
```
80+
81+
Some unsupported fields are missing completely:
82+
83+
```C
84+
struct bpf_prog_info
85+
{
86+
ebpf_id_t id; ///< Program ID.
87+
enum bpf_prog_type type; ///< Program type, if a cross-platform type.
88+
// 8 missing fields
89+
uint32_t nr_map_ids; ///< Number of maps associated with this program.
90+
```
91+
92+
### Additional fields
93+
94+
Some structures contain Windows-specific fields:
95+
96+
```C
97+
struct bpf_map_info
98+
{
99+
// Cross-platform fields.
100+
ebpf_id_t id; ///< Map ID.
101+
// ...
102+
103+
// Windows-specific fields.
104+
ebpf_id_t inner_map_id; ///< ID of inner map template.
105+
uint32_t pinned_path_count; ///< Number of pinned paths.
106+
};
107+
```
108+
109+
This is problematic because Linux exposes many more fields in `bpf_map_info`, aliasing with the Windows-specific fields.
110+
Adding a new cross-platform field before the Windows-specific fields will break compatibility in several ways.
111+
112+
## Resolve ABI incompatibilities in the `bpf()` syscall emulation
113+
114+
Changing the problematic types globally is possible but undesirable, since it will cause problems for existing users of the C API.
115+
Instead we will restrict the necessary changes to the `bpf()` syscall emulation.
116+
A separate header will contain type definitions compatible with the Linux ABI.
117+
The syscall emulation layer is then responsible for translating between the Linux
118+
and native types.
119+
This localises breakage to users of `bpf()` and allows the C API to evolve on its own.
120+
121+
[ebpf-go library]: https://ebpf-go.dev
122+
[architecture]: https://ebpf-go.dev/contributing/architecture/
123+
[stable ioctl]: https://github.com/microsoft/ebpf-for-windows/issues/3700
124+
[ioctl allocs]: https://github.com/microsoft/ebpf-for-windows/issues/3726
125+
[bpf wrapper]: https://github.com/microsoft/ebpf-for-windows/blob/main/libs/api/bpf_syscall.cpp
126+
[api tests]: https://github.com/microsoft/ebpf-for-windows/issues/3729#issuecomment-2259330472

docs/GettingStarted.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Alternative install steps (for *basic* Visual Studio Community edition):
5353
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
5454
```
5555

56-
1. Run the following command to automatically setup the dev environment:
56+
1. Run the following command to automatically set up the dev environment:
5757

5858
```ps
5959
Invoke-WebRequest 'https://raw.githubusercontent.com/microsoft/ebpf-for-windows/main/scripts/Setup-DevEnv.ps1' -OutFile $env:TEMP\Setup-DeveEnv.ps1
@@ -596,4 +596,4 @@ development cycle. See the [Windows Hardware Developer documentation](https://l
596596
Extensions that integrate with eBPF for Windows:
597597
- XDP extension: [xdp-for-windows](https://github.com/microsoft/xdp-for-windows)
598598
- ntosebpfext extension: [ntosebpfext](https://github.com/microsoft/ntosebpfext)
599-
- Network event extension: [neteventebpfext](https://github.com/microsoft/ntosebpfext/blob/main/docs/neteventebpfext.md)
599+
- Network event extension: [neteventebpfext](https://github.com/microsoft/ntosebpfext/blob/main/docs/neteventebpfext.md)

docs/isa-support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ opcode src_reg offset imm description
103103
0x7f any 0 0x00 dst >>= src Y Y Y rsh-reg
104104
0x84 0x0 0 0x00 dst = (u32)-dst Y Y Y neg
105105
0x85 0x0 0 any call helper function by static ID Y Y Y call_unwind_fail
106-
0x85 0x1 0 any call PC += imm no no no call_local
106+
0x85 0x1 0 any call PC += imm Y part Y call_local
107107
0x85 0x2 0 any call helper function by BTF ID no no no ???
108108
0x87 0x0 0 0x00 dst = -dst Y Y Y neg64
109109
0x8d 0x0 0 0x00 call helper function by static ID in register Y Y no callx

ebpfcore/usersim/EbpfCore_Usersim.vcxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@
207207
<FilesToPackage Include="$(TargetPath)" />
208208
</ItemGroup>
209209
<ItemGroup>
210-
<ProjectReference Include="..\..\external\usersim\cxplat\src\cxplat_winkernel\cxplat_winkernel.vcxproj">
211-
<Project>{1ebe3966-7dc4-49b4-b840-3d33d63415ec}</Project>
210+
<ProjectReference Include="..\..\external\usersim\cxplat\src\cxplat_winuser\cxplat_winuser.vcxproj">
211+
<Project>{f2ca70ab-af9a-47d1-9da9-94d5ab573ac2}</Project>
212212
</ProjectReference>
213213
<ProjectReference Include="..\..\external\usersim\src\usersim.vcxproj">
214214
<Project>{030a7ac6-14dc-45cf-af34-891057ab1402}</Project>
@@ -236,4 +236,4 @@
236236
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
237237
<ImportGroup Label="ExtensionTargets">
238238
</ImportGroup>
239-
</Project>
239+
</Project>

ebpfcore/usersim/EbpfCore_Usersim.vcxproj.filters

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@
3535
<Filter>Header Files</Filter>
3636
</ClInclude>
3737
</ItemGroup>
38-
</Project>
38+
<ItemGroup>
39+
<ResourceCompile Include="$(SolutionDir)resource\ebpf_resource.rc">
40+
<Filter>Resource Files</Filter>
41+
</ResourceCompile>
42+
</ItemGroup>
43+
</Project>

external/ebpf-verifier

Submodule ebpf-verifier updated 57 files

0 commit comments

Comments
 (0)