Граф коммитов

221 Коммитов

Автор SHA1 Сообщение Дата
Alan Jowett 811c060983
Add support for building ARM64 native only eBPF for Windows. (#3921)
* Add support for building ARM64 native only eBPF for Windows.

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-10-10 22:49:07 +00:00
Alan Jowett 5068110219
Centralize eBPF version to Directory.Build.props (#3893)
* Centralize eBPF version to Directory.Build.props

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Remove unused and failing builds

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-10-04 15:12:31 +00:00
Alan Jowett 735ec5277f
Refactor common platform and config into Directory.Build.props (#3891)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-10-02 19:14:14 +00:00
Alan Jowett f5195ecf63
Allow platform specific eBPF nuget packages to be created (#3892)
* Allow platform specific eBPF nuget packages to be created

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Specify version in output

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-10-02 18:56:45 +00:00
D. Michael Agun a41953dc62
remove --no-verify option from bpf2c and tests using it (#3673)
* remove --no-verify option from bpf2c and tests using it

Closes #3571

* remove builds for unsafe programs in sample.vcxproj

* remove unsafe test cases from netsh_test.cpp

* remove new noverify references

* Revert deletion of netsh tests.

* Add back compilation of unsafe programs (but not bpf2c call)

* remove invalid program tests which used noverify

* remove end_to_end tests using noverify

---------

Co-authored-by: Michael Agun <danielagun@microsoft.com>
2024-09-14 00:45:03 +00:00
Shankar Seal 6e8f47a7c0
update onebranch scripts. (#3824) 2024-09-09 19:40:42 +00:00
Alan Jowett 8c838d1ab5
Stamp all tools with version information. (#3792)
* Stamp all tools with version information.

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Add commit id to nuget package

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Move versioning to Directory.Build.props

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Set correct project type in sample.vcxproj

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Add version info to fuzz tests

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update tests/socket/resource.h

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* Revert editor change

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-08-27 16:30:12 +00:00
Alan Jowett 3738c826c7
Switch to using Visual Studio's version of LLVM and Clang (#3754)
* Add VS Clang to path

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix tests

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Reformat using clang 17.0.3

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Account for git_commit_id.h dependency

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Revert https://github.com/microsoft/ebpf-for-windows/pull/3756 from this branch

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Make LLVM path dependent on cl.exe path

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Use VCINSTALLDIR as root of LLVM path

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update hash and set path to use environment variable

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-08-07 16:43:47 +00:00
Shankar Seal c7efd73451
Remove undocked solution. (#3739)
* fix undocked solution.

* update.

* PR feedback.
2024-08-05 15:24:23 +00:00
Anurag Saxena ffb3638259
Implement `implicit_context` for helper functions. (#3656)
* backup

* backup

* fix build issues

* fix build

* fix analysis failures, fix tests

* seperate out sample for implicit context

* backup

* add ctx as last argument

* fix hash

* block implicit context for jit and interpret

* stabilize tests

* tail call fast path

* add check to reject change in context_header support

* enable implicit context for jit and interpret

* fix

* fix build

* fix analysis build

* update version, update expected files

* fix test failures

* fix test failures

* fix tests

* cleanup

* cleanup

* more cleanup

* enable performance tests

* enable performance tests

* remove tail_call changes

* remove tail_call changes

* remove tail_call changes

* remove tail_call changes

* fix analysis error

* update documentation

* code cleanup

* fix bad merge

* fix test case

* cr comments

* update expected files

* cr comments
2024-07-19 17:12:08 +00:00
Anurag Saxena 79c2b56574
update redist nuspec (#3711) 2024-07-17 20:36:48 +00:00
D. Michael Agun 2efce152dc
Set empty program name to hash of instructions (#3493)
* Move C++ hashing lib from tests/libs/util/ to libs/shared/

This puts hash.cpp/hash.h in a more central location for use by other project files.

* Set empty program name to hash of instructions

ebpf_program_load_bytes now hashes the instructions and uses that for the name
instead of generating a random number.

Closes #3443

* fix signed/unsigned warning (and ensure windows helper id >= 0)

* add bcrypt.dll dependency for ebpfapi.dll

* WIP new test case for ebpf_program_load_bytes with nullptr program name

* WIP ebpf_program_load_bytes testing

* truncate SHA256 hash to 63 bytes to stay under BPF_OBJ_NAME_LEN

* remove bcrypt from release dependencies and suppress analyze warning

* PR feedback - fix comment and bpf2c include paths

---------

Co-authored-by: Michael Agun <danielagun@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2024-07-02 14:47:03 +00:00
Alan Jowett b0bfaa6090
Fix bpf conformance failure (#3666)
* Fix bpf conformance failure

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update expected output

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-06-26 16:31:14 +00:00
Alan Jowett 95060af117
Enable building and signing eBPF for Windows (#3651)
* Enable building and signing eBPF for Windows

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-06-19 22:01:26 +00:00
Dave Thaler 840269a9ec
Add support for multiple programs per section (#3557)
* Allow multiple programs per section

Temporarily use a fork of ebpf-verifier until
https://github.com/vbpf/ebpf-verifier/pull/642 is merged.

Per https://stackoverflow.com/questions/13147170/attribute-always-inline-failing
the __attribute__((always_inline)) doesn't do anything unless you also
have the "inline" keyword.

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Update verifier to latest

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Address comment from Alan

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Address API compat comment from Anurag

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-29 15:30:20 +00:00
Alan Jowett b2f2acff4f
Fix for breaking change P2905R2 in STL (#3589)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-05-29 02:11:16 +00:00
Anurag Saxena f7ec168340
Add `total_size` to extension header. (#3573)
* change ebpf_extension_header_t to ebpf_version_header_t

* revert to ebpf_version_header_t

* revert to ebpf_version_header_t

* update header

* update doc

* update doc

* use total_size to get the actual struct size

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-24 01:05:36 +00:00
Alan Jowett aed27b488b
Add option to control the level of verbosity emitted by verifier. (#3570)
* Add option to control the level of verbosity emitted by verifier.

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Re-order enums to make normal < informational < verbose

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Workaround for verifier failure #643

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Revert change in ebpf-service verification path

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-23 14:02:34 +00:00
Dave Thaler fffe6848d5
Fix bpf2c output format (#3532)
* Fix bpf2c output format

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Update expected output

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-08 22:56:37 +00:00
Dave Thaler d096b21ac5
Update copyright to be eBPF for Windows contributors (#3508)
* Update copyright to be eBPF for Windows contributors

Fixes #3507

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Undo gratuitous formatting changes in expected files

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-05-04 19:55:56 +00:00
Shankar Seal 73647f801b
Reallocate packet (#3344)
* reallocate_packet.

* PR Feedback.
2024-04-04 00:49:27 +00:00
Shankar Seal fc973542c9
extension_header (#3326)
* extension_header

* fix logic error.

* Re-purposing the size field to act as the "minor version". Additional validation checks are added.

* PR Feedback.

* fix break due to bad merge with PR #3372
2024-03-30 17:27:09 +00:00
Anurag Saxena 43b0373652
Clean up stale nuget packages in build step (#3392)
* fix

* fix
2024-03-27 21:14:21 +00:00
Anurag Saxena 5011c712f2
Fix the IOCTL numbers so that ebpfapi.dll for x64 and x64-NativeOnly are cross-compatible. (#3305)
* backup

* fix

* update tests

* fix cicd

* fix cicd

* copy usersim.dll from regular build

* fix tests

* fix

* cleanup

* cr comments

* cr comments

* cleanup

* fix

* cr comments
2024-03-05 06:26:48 +00:00
Shankar Seal 66087c57c8
Revert "Helper reallocate packet (#3110)" (#3263)
This reverts commit 13eed744fe.
2024-02-15 02:06:29 +00:00
Shankar Seal b2ee88b2ff
fix check for static initialization of hash-of-maps key length. (#3260)
* fix check for static initialization of hash-of-maps key length.

* Delete tests/bpf2c_tests/expected/xdp_adjust_head_unsafe_dll.c

* Delete tests/bpf2c_tests/expected/xdp_adjust_head_unsafe_raw.c

* Delete tests/bpf2c_tests/expected/xdp_adjust_head_unsafe_sys.c

* fix build failure

---------

Co-authored-by: Anurag Saxena <anusa@microsoft.com>
2024-02-14 03:54:24 +00:00
Alan Jowett bf2a7c3eb5
Add support for statically initializing BPF_MAP_TYPE_HASH_OF_MAPS (#3211)
* Add support for statically initializing BPF_MAP_TYPE_HASH_OF_MAPS

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update installer and add code gen tests

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Add files to expected install list

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-01-31 00:18:28 +00:00
Alan Jowett 0eaf909028
Enable interlocked tests in bpf2c conformance (#3195)
* Enable interlocked tests

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Remove left-over diagnostics.

* PR feedback

Keep cicd and cicd-release-validation in synch.

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-01-26 16:49:14 +00:00
Alan Jowett ba4b6339c1
Fix array out of bounds access during fuzzing (#3194)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-01-25 00:06:19 +00:00
Dave Thaler 46ad4cc27c
Add bpf2c support for cpu=v4 instructions (#3185)
* Remove movsx imm instructions

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Switch most bpf2c uses to use verifier defines not uBPF defines

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Add bpf2c support for ja32 instruction

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Add bpf2c support for swap* instructions

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Add bpf support for movsx instructions

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Update CI/CD command

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-01-24 23:52:21 +00:00
Alan Jowett efb6656b4c
Add support for handling anonymous inner maps (#3169)
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-01-19 16:33:51 +00:00
Dave Thaler d0c6a084e4
Add sdiv and smod instruction support to bpf2c (#3165)
* Add sdiv instruction support to bpf2c

Manually tested with latest bpf_conformance test

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Add signed modulo instructions

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Add sdiv conformance tests to isa-support table

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

* Fix ja32 documentation

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>

---------

Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-01-18 19:43:59 +00:00
Alan Jowett 3f5aa42732
Enable optimization on bpf2c generated code (#3146)
* Enable optimization on bpf2c generated code

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix optimization conflict with /rtc1

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix expected output for debug vs release

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2024-01-03 01:19:45 +00:00
Dave Thaler 64e670602f
Update verifier to latest (#3144)
Signed-off-by: Dave Thaler <dthaler1968@gmail.com>
2024-01-02 17:33:23 +00:00
Anurag Saxena f6a478842a
Remove store km lib and code (#3109)
* remove store km lib and code

* fix

* more cleanup

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>

---------

Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
2023-12-12 13:53:04 +00:00
Shankar Seal 13eed744fe
Helper reallocate packet (#3110)
* add reallocate_packet flag to helper prototype struct.

* PR Feedback.

* fix.

* export reallocate_packet flag.
2023-12-11 17:54:34 +00:00
Anurag Saxena 3f5e0ba1ba
Separate out undocked components. (#3055)
* remove not-needed includes

* fix

* fix

* update sample extension

* change include path

* export store APIs from ebpfapi.dll

* fix analyze build

* update dependencies

* add undocked projects

* undock sample_ext driver

* fix build

* more undocking

* fix build

* remove undocked projects from fuzzerdebug

* fix nuget

* remove usersim from export_program_info

* fix configuration manager

* fix tests

* skip building undocked samples for FuzzerDebug builds

* fix build

* try cicd changes

* fix cicd yml

* update export_program_info to not clean up all entries

* code cleanup

* delete global helpers from the store

* code cleanup

* export *delete* store APIs from ebpfapi

* code cleanup

* CR comments

* cr comments

* remove ansi APIs

* CR comments

* cr comments

* fix CI failure

* fix rebase build issues

* change default custom type to bind

* some more fixes

* fix tests

* fix tests

* update expected files

* fix bpf2c tests

* run export_program_info

* fix headers

* CR comments
2023-12-07 21:10:19 +00:00
Alan Jowett 041d402eeb
Fix build break from VS 2022 17.8.2 (#3104)
* Fix build break from VS 2022 17.8.2

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix conflicting C++ versions

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* New depenedency on kernel32.dll

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Pickup latests usersim

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2023-12-07 00:58:33 +00:00
Matthew Ige 2000dafc4e
Remove XDP hook support from netebpfext.sys (#3040)
* replace XDP guids with XDP_TEST guids

* updated missde instance

* update bpf2c

* leave xdp_hook as is

* remove extra files

* update with new XDP_TEST guid, update other tests to use sample_ext

* update some tests, update test_helper

* update fuzzer

* temporarily remove bpftool tests

* update execution context test

* replace XDP guids with XDP_TEST guids

* updated missde instance

* update bpf2c

* leave xdp_hook as is

* remove extra files

* update with new XDP_TEST guid, update other tests to use sample_ext

* update some tests, update test_helper

* update fuzzer

* temporarily remove bpftool tests

* update execution context test

* build failures

* update sample ext with context_allocate and destroy

* update vm script to use xdp_test

* switch api tests to use sample program

* rename to xdp_Test

* update sample ext

* update incorrect SAL, update netsh tests

* update sample, update tests to use sample where applicable

* update tests

* fix up tests

* fix libbpf tets

* revert unnecessary changes

* remove extra prints

* add back in bpftool tests

* update to use xdp instead of xdp_test for bpftool test

* update atomic_instructions_others.o

* extra debug logs

* updated expected, update bpftool tests

* correct bpftool tests

* more debug logs

* add reg debug

* clear program info

* Attempt fix of buffer overrun

* remove debug logs, minor cleanup, set XDP guids back to their original names

* update docs with xdp_test

* fix guid usage

* CR: remove program, update comments, fix commented out tests, update bpf_program__attach_xdp

* revert changes in libbpf, as they need to use the actual XDP guids

* update comment

* update some XDP tests to use sample ext, comment out some expected failing tests

* update bpftool tests

* fix up bpf prog test run expected output, move to #if instead of comments

* fix up return code issue

* fix bpftool testes

* add some failed xdp tests, set some params to null for sample tests

* update comment

* tmp commit - move to xdp mock

* update unit tests to use mock XDP where possible

* made some samples back to XDP type

* netebpfext unit tests should use xdp_test

* CR
2023-12-06 17:12:17 +00:00
Michael Friesen 99744a1515
fix ebpf library linkage when using props file (#3107) 2023-12-06 17:10:36 +00:00
Anurag Saxena ffeb90bac5
Fix #line 0 issue for bpf2c (#2920)
* fix 0 line numbers for bpf2c

* cr comments
2023-09-29 21:30:11 +00:00
Alan Jowett 66588bdc27
Remove check that prevents fuzzing below minimum size (#2849)
* Remove check that prevents fuzzing below minimum size

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* WIP

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Cleanup handling of request lengths in _ebpf_core_protocol_program_test_run

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update libs/execution_context/ebpf_core.c

Co-authored-by: Dave Thaler <dthaler@microsoft.com>

* Fix break

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Enable warning 4062

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Remove overactive assert

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-09-20 19:31:54 +00:00
Anurag Saxena 88b6f67e79
Fix program info hash algorithm (#2829)
* backup

* backup2

* fix

* fix

* fix

* fix

* fix

* code cleanup

* revert expected files

* remove regression test

* code cleanup

* remove dead code

* cr comments

* Apply suggestions from code review

Co-authored-by: Dave Thaler <dthaler@microsoft.com>

* cr comments

* fix build

---------

Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-09-11 22:23:02 +00:00
Dave Thaler c947ca63b9
Make runtime binaries not depend on usersim (#2783)
* build ebpfcore under usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Work around analysis warnings

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix installer project

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Temporarily use ubpf branch with memory fix

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Create project for files shared between ebpfapi and the ebpf runtime

Move existing files from libs/platform either to:
* libs/shared, if meant to be common between user-mode and ebpf runtime
* libs/runtime, if meant to be used by the ebpf runtime only (whether in
  user or kernel mode)

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Move ebpf_tracelog.c to shared

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Create shared_user and shared_kernel projects

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* WIP

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Remove usersim from ebpfsvc

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to cxplat branch of usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Use cxplat_utf8_string

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Cleanup

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix build errors

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix ebpf_allocate_with_tag

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fixes

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Bug fixes

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix use of ebpf_reallocate to not pass a null pointer

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix printf tests

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix memory leaks

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Temporary change to help debug double-free in test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix analysis warnings

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update to latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update usersim to latest

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Change native module to use latest usersim

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update nuget package

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Only call cxplat_cleanup if cxplat_initialize succeeds

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Revert setup_build.vcxproj change

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Update usersim to latest

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2023-09-05 17:57:21 +00:00
Dave Thaler b7f82b66c5
Remove cmake build (#2764)
Other projects can now consume ebpf-for-windows in binary form,
using either nuget or MSI install.  We no longer need to build
ebpf-for-windows both ways, so removing the cmake build to free
up build resources and reduce the development cost of maintaining
both msbuild and cmake builds.

Fixes #2743

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-08-18 00:48:10 +00:00
Alan Jowett e57858ffc2
Implement bpf_get_prandom_u32 using linear congruential generator (#2761)
* Implment bpf_get_prandom_u32 using linear congruential generator

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Add chi-squared test for randomness

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix test failure

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
2023-08-17 18:20:50 +00:00
Alan Jowett 3f3b834c2f
Add static initializer support to bpf2c - part 1 (#2728)
* Add static initializer support to bpf2c

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix tail call failure

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix test failures

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix test failures

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix parsing error

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Fix formatting for tail_call_sequential*.c

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Harden BTF data parsing

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback and map init for native

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Update tools/bpf2c/bpf_code_generator.cpp

Co-authored-by: Dave Thaler <dthaler@microsoft.com>

* Fix fault injection

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

---------

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
Co-authored-by: Dave Thaler <dthaler@microsoft.com>
2023-08-09 21:23:26 +00:00
Gianni Trevisiol 4cb79e547d
Isolate eBPF store APIs into atomic km & um libraries. (#2690)
* draft

* wip

* wip

* wip

* wip

* wip - km & um compile

* fix

* fix include order

* wip

* wip

* wip

* wip - api_common

* wip - updated projects

* wip

* wip

* fix merge issues

* wip

* fix C28196/C6387

* wip

* wip

* fix SAL

* cleanup

* fix SAL bugs

* wip - cmake

* add cmake files

* wip

* wip

* update msi artifacts

* wip

* cleanup

* collapse null-checks

* clean-up headers

* refactor return types to ebpf_result_t

* replace ebpf_registry_result_t with ebpf_result_t

* update header

* remove cpp wrapper, misc cleanup.

* rename um/km registry helpers

* cleanup

* cleanup

* update

* nit

* fix

* Added KERNEL_MODE var, so to default to USER_MODE.

* fix cmake

* align result var names with ebpf_result_t

* pr feedback

* add project refs

* Add NativeOnly* cfgs to ebpf_store_helper_km

* Update docs, API reordering in source.

* pr feedback

* Rename types to abstract use of registry

* Normalize all registry API names.

* rename

* merge sln

* fix var typo

* refactor store root keys

* feedback

* doc/comments

* remove KERNEL_MODE

* Force ignore format on all preprocessor code paths.
2023-08-07 19:53:24 +00:00
Nick Banks a5616628c5
Add OneBranch Build Property Flags to Build Template (#2725)
* Add OneBranch Build Property Flags to Build Template

* Remove internal, because external builds may trigger
2023-08-05 18:11:55 +00:00
Dave Thaler a29064a1fe
Convert usersim to a DLL (#2683)
* Use usersim as DLL

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Convert usersim to a DLL

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Make cmake build clear program info state like VS build does

PR #1192 updated the vcxproj file but not the corresponding CMakeLists.txt file
for export_program_info

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Pick up latest usersim fix

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix deadlock in epoch_test_stale_items test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Don't throw exceptions in unit tests

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix single instance hook initialization in test cases

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Fix deadlock in performance test

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

* Add usersim.dll to installer files

Signed-off-by: Dave Thaler <dthaler@microsoft.com>

---------

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
2023-07-27 18:36:05 +00:00