Skip to content

Commit

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

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

* Remove yaml-cpp project

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

* Handle SDIV/SMOD operations that do -INT_MIN

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

---------

Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler authored Nov 1, 2024
1 parent e71e7f7 commit 35e3911
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "external/ebpf-verifier"]
path = external/ebpf-verifier
url = https://github.com/dthaler/ebpf-verifier.git
url = https://github.com/vbpf/ebpf-verifier.git
[submodule "external/ubpf"]
path = external/ubpf
url = https://github.com/iovisor/ubpf.git
Expand Down
109 changes: 30 additions & 79 deletions ebpf-for-windows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ebpfverifier", "external\ebpf-verifier\build\ebpfverifier.vcxproj", "{7D5B4E68-C0FA-3F86-9405-F6400219B440}"
ProjectSection(ProjectDependencies) = postProject
{231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403}
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A} = {98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{B02E60AE-1254-459C-8824-AC6CDB6AE52E}"
Expand Down Expand Up @@ -180,11 +179,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bpftool", "tools\bpftool\bp
{231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yaml-cpp", "external\ebpf-verifier\build\yaml-cpp.vcxproj", "{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}"
ProjectSection(ProjectDependencies) = postProject
{231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bpf2c", "tools\bpf2c\bpf2c.vcxproj", "{69B97E52-18DC-434E-A6E4-4C0F3E88C44A}"
ProjectSection(ProjectDependencies) = postProject
{231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403}
Expand Down Expand Up @@ -330,7 +324,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "usersim", "external\usersim
{231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbtf", "external\ebpf-verifier\build\external\libbtf\libbtf\libbtf.vcxproj", "{9FD0723C-6979-3D32-8D17-6CECA34B7026}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbtf", "external\ebpf-verifier\build\external\libbtf\libbtf\libbtf.vcxproj", "{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}"
ProjectSection(ProjectDependencies) = postProject
{231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403}
EndProjectSection
Expand Down Expand Up @@ -663,8 +657,6 @@ Global
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyDebug|x86.ActiveCfg = Debug|Win32
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyDebug|x86.Build.0 = Debug|Win32
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyRelease|ARM64.ActiveCfg = Debug|x64
{21236F4F-341C-454F-B55B-C653897AB3E8}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{21236F4F-341C-454F-B55B-C653897AB3E8}.Release|ARM64.ActiveCfg = Release|ARM64
Expand Down Expand Up @@ -1263,34 +1255,6 @@ Global
{CA179B38-EBF5-4371-B830-73486E35250B}.RelWithDebInfo|ARM64.Build.0 = Release|ARM64
{CA179B38-EBF5-4371-B830-73486E35250B}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{CA179B38-EBF5-4371-B830-73486E35250B}.RelWithDebInfo|x64.Build.0 = Release|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Debug|ARM64.ActiveCfg = Debug|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Debug|ARM64.Build.0 = Debug|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Debug|x64.ActiveCfg = Debug|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Debug|x64.Build.0 = Debug|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.FuzzerDebug|ARM64.ActiveCfg = Debug|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.FuzzerDebug|ARM64.Build.0 = Debug|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.FuzzerDebug|x64.ActiveCfg = Debug|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.FuzzerDebug|x64.Build.0 = Debug|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.MinSizeRel|ARM64.ActiveCfg = MinSizeRel|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.MinSizeRel|ARM64.Build.0 = MinSizeRel|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyDebug|x64.Build.0 = Debug|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyRelease|ARM64.ActiveCfg = Release|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyRelease|ARM64.Build.0 = Release|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.NativeOnlyRelease|x64.Build.0 = Release|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Release|ARM64.ActiveCfg = Release|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Release|ARM64.Build.0 = Release|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Release|x64.ActiveCfg = Release|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.Release|x64.Build.0 = Release|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{69B97E52-18DC-434E-A6E4-4C0F3E88C44A}.Debug|ARM64.ActiveCfg = Debug|ARM64
{69B97E52-18DC-434E-A6E4-4C0F3E88C44A}.Debug|ARM64.Build.0 = Debug|ARM64
{69B97E52-18DC-434E-A6E4-4C0F3E88C44A}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -1466,13 +1430,9 @@ Global
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyDebug|x86.ActiveCfg = Debug|Win32
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyDebug|x86.Build.0 = Debug|Win32
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyRelease|ARM64.ActiveCfg = Release|x64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyRelease|ARM64.Build.0 = Release|x64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyRelease|x86.ActiveCfg = Debug|Win32
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.NativeOnlyRelease|x86.Build.0 = Debug|Win32
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.Release|ARM64.ActiveCfg = Release|x64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.Release|ARM64.Build.0 = Release|x64
{8DD6577A-CBBE-43FE-9FC3-E42CB013CC60}.Release|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -1708,13 +1668,9 @@ Global
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyDebug|x86.ActiveCfg = Debug|Win32
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyDebug|x86.Build.0 = Debug|Win32
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyRelease|ARM64.ActiveCfg = Release|x64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyRelease|ARM64.Build.0 = Release|x64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyRelease|x86.ActiveCfg = Debug|Win32
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.NativeOnlyRelease|x86.Build.0 = Debug|Win32
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.Release|ARM64.ActiveCfg = Release|x64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.Release|ARM64.Build.0 = Release|x64
{F106D38A-AC35-4B5A-AEEE-7235E4915A72}.Release|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -1764,13 +1720,9 @@ Global
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyDebug|x86.ActiveCfg = Debug|Win32
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyDebug|x86.Build.0 = Debug|Win32
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyRelease|ARM64.ActiveCfg = Release|x64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyRelease|ARM64.Build.0 = Release|x64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyRelease|x86.ActiveCfg = Debug|Win32
{E619B985-44B3-4292-A585-5CD0C4315ED3}.NativeOnlyRelease|x86.Build.0 = Debug|Win32
{E619B985-44B3-4292-A585-5CD0C4315ED3}.Release|ARM64.ActiveCfg = Release|x64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.Release|ARM64.Build.0 = Release|x64
{E619B985-44B3-4292-A585-5CD0C4315ED3}.Release|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -1971,34 +1923,34 @@ Global
{030A7AC6-14DC-45CF-AF34-891057AB1402}.RelWithDebInfo|ARM64.Build.0 = Release|ARM64
{030A7AC6-14DC-45CF-AF34-891057AB1402}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{030A7AC6-14DC-45CF-AF34-891057AB1402}.RelWithDebInfo|x64.Build.0 = Release|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Debug|ARM64.ActiveCfg = Debug|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Debug|ARM64.Build.0 = Debug|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Debug|x64.ActiveCfg = Debug|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Debug|x64.Build.0 = Debug|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.FuzzerDebug|ARM64.ActiveCfg = FuzzerDebug|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.FuzzerDebug|ARM64.Build.0 = FuzzerDebug|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.FuzzerDebug|x64.ActiveCfg = FuzzerDebug|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.FuzzerDebug|x64.Build.0 = FuzzerDebug|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.MinSizeRel|ARM64.ActiveCfg = MinSizeRel|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.MinSizeRel|ARM64.Build.0 = MinSizeRel|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyDebug|x64.Build.0 = Debug|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyRelease|ARM64.ActiveCfg = Release|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyRelease|ARM64.Build.0 = Release|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.NativeOnlyRelease|x64.Build.0 = Release|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Release|ARM64.ActiveCfg = Release|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Release|ARM64.Build.0 = Release|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Release|x64.ActiveCfg = Release|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.Release|x64.Build.0 = Release|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{9FD0723C-6979-3D32-8D17-6CECA34B7026}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Debug|ARM64.ActiveCfg = Debug|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Debug|ARM64.Build.0 = Debug|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Debug|x64.ActiveCfg = Debug|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Debug|x64.Build.0 = Debug|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.FuzzerDebug|ARM64.ActiveCfg = FuzzerDebug|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.FuzzerDebug|ARM64.Build.0 = FuzzerDebug|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.FuzzerDebug|x64.ActiveCfg = FuzzerDebug|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.FuzzerDebug|x64.Build.0 = FuzzerDebug|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.MinSizeRel|ARM64.ActiveCfg = MinSizeRel|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.MinSizeRel|ARM64.Build.0 = MinSizeRel|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyDebug|ARM64.ActiveCfg = Debug|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyDebug|ARM64.Build.0 = Debug|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyDebug|x64.ActiveCfg = Debug|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyDebug|x64.Build.0 = Debug|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyRelease|ARM64.ActiveCfg = Release|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyRelease|ARM64.Build.0 = Release|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyRelease|x64.ActiveCfg = Release|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.NativeOnlyRelease|x64.Build.0 = Release|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Release|ARM64.ActiveCfg = Release|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Release|ARM64.Build.0 = Release|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Release|x64.ActiveCfg = Release|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.Release|x64.Build.0 = Release|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{1937DB41-F3EB-4955-A636-6386DCB394F6}.Debug|ARM64.ActiveCfg = Debug|ARM64
{1937DB41-F3EB-4955-A636-6386DCB394F6}.Debug|ARM64.Build.0 = Debug|ARM64
{1937DB41-F3EB-4955-A636-6386DCB394F6}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -2342,7 +2294,6 @@ Global
{724EB55A-CCFC-4662-92E3-B664CDA365E7} = {492C9B22-9237-4996-9E33-CA14D3533616}
{07DC6181-84A2-4A14-A806-5E9AF6C929C2} = {492C9B22-9237-4996-9E33-CA14D3533616}
{CA179B38-EBF5-4371-B830-73486E35250B} = {B09749EC-3D14-414B-BA9B-CD20E218DC84}
{98D56B8A-D8EB-3D98-B8EE-C83696B4D58A} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
{69B97E52-18DC-434E-A6E4-4C0F3E88C44A} = {B09749EC-3D14-414B-BA9B-CD20E218DC84}
{61DF9973-81B9-4006-9148-52F58259BBCF} = {492C9B22-9237-4996-9E33-CA14D3533616}
{8BD3552A-2CFB-4A59-AB15-2031B97ADA1E} = {492C9B22-9237-4996-9E33-CA14D3533616}
Expand Down Expand Up @@ -2370,7 +2321,7 @@ Global
{4F082524-9496-44FA-8CBA-4BC0BDC62568} = {492C9B22-9237-4996-9E33-CA14D3533616}
{AA933B9F-B5D8-4AA8-AC18-98FE1A161E8A} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
{030A7AC6-14DC-45CF-AF34-891057AB1402} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
{9FD0723C-6979-3D32-8D17-6CECA34B7026} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
{249E3FBC-0098-3E3E-80AE-C8F8EF6AB0E5} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
{1937DB41-F3EB-4955-A636-6386DCB394F6} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
{1FDAD2FD-EBD8-462A-B285-ED5174E55079} = {97D3096A-20FB-4ACB-A038-88E652FE61E3}
{9388DD45-7941-45D7-B4FF-BC00F550AF17} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B}
Expand Down
56 changes: 43 additions & 13 deletions tools/bpf2c/bpf_code_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ bpf_code_generator::bpf_code_generator_program::encode_instructions(
source = "IMMEDIATE(" + std::to_string(inst.imm) + ")";
}
bool is64bit = (inst.opcode & INST_CLS_MASK) == INST_CLS_ALU64;
int bits = is64bit ? 64 : 32;
AluOperations operation = static_cast<AluOperations>(inst.opcode >> 4);
std::string swap_function;
std::string type;
Expand All @@ -993,14 +994,30 @@ bpf_code_generator::bpf_code_generator_program::encode_instructions(
output.lines.push_back(std::format("{} *= {};", destination, source));
break;
case AluOperations::Div:
if (is64bit) {
type = (inst.offset == 1) ? "(int64_t)" : "";
type = (is64bit) ? "" : "(uint32_t)";
if (inst.offset == 1) {
// Signed division.
output.lines.push_back(std::format(
"if (!((int{}_t){} == INT{}_MIN && (int{}_t){} == -1)) {{",
bits,
destination,
bits,
bits,
source));
output.lines.push_back(std::format(
"{} = {} ? ({}{} / {}{}) : 0;", destination, source, type, destination, type, source));
INDENT "{} = {}{} ? ((int{}_t){} / (int{}_t){}) : 0;",
destination,
type,
source,
bits,
destination,
bits,
source));
output.lines.push_back("}");
} else {
type = (inst.offset == 1) ? "(int32_t)" : "(uint32_t)";
// Unsigned division.
output.lines.push_back(std::format(
"{} = (uint32_t){} ? {}{} / {}{} : 0;", destination, source, type, destination, type, source));
"{} = {}{} ? ({}{} / {}{}) : 0;", destination, type, source, type, destination, type, source));
}
break;
case AluOperations::Or:
Expand Down Expand Up @@ -1052,23 +1069,36 @@ bpf_code_generator::bpf_code_generator_program::encode_instructions(
output.lines.push_back(std::format("{} = -(int64_t){};", destination, destination));
break;
case AluOperations::Mod:
if (is64bit) {
type = (inst.offset == 1) ? "(int64_t)" : "";
type = (is64bit) ? "" : "(uint32_t)";
if (inst.offset == 1) {
// Signed modulo.
output.lines.push_back(std::format(
"{} = {} ? ({}{} % {}{}) : {}{};",
"if ((int{}_t){} == INT{}_MIN && (int{}_t){} == -1) {{",
bits,
destination,
source,
type,
bits,
bits,
source));
output.lines.push_back(std::format(INDENT "{} = 0;", destination));
output.lines.push_back("} else {");
output.lines.push_back(std::format(
INDENT "{} = {}{} ? ((int{}_t){} % (int{}_t){}) : (int{}_t){};",
destination,
type,
source,
type,
bits,
destination,
bits,
source,
bits,
destination));
output.lines.push_back("}");
} else {
type = (inst.offset == 1) ? "(int32_t)" : "(uint32_t)";
// Unsigned modulo.
output.lines.push_back(std::format(
"{} = (uint32_t){} ? ({}{} % {}{}) : {}{};",
"{} = {}{} ? ({}{} % {}{}) : {}{};",
destination,
type,
source,
type,
destination,
Expand Down

0 comments on commit 35e3911

Please sign in to comment.