Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Wdf* APIs required by ebpf-for-windows #76

Merged
merged 4 commits into from
Aug 7, 2023
Merged

Add Wdf* APIs required by ebpf-for-windows #76

merged 4 commits into from
Aug 7, 2023

Conversation

dthaler
Copy link
Contributor

@dthaler dthaler commented Aug 4, 2023

  • Add Wdf* APIs required by ebpf-for-windows (fixes Etw* API support #70)
  • Fix bug in ke.cpp where wrong function was used to free memory allocated by C++ allocator
  • Add cache-aligned allocations (fixes Add cache-aligned allocation #31)
  • Add stub for IofCompleteRequest (addresses part of IofCompleteRequest support #69)
  • Add error check for freeing unallocated memory in leak_detector.cpp
  • Move usersim_allocate functions from platform_user.cpp to ex.cpp where the other allocation functions are
  • Make Ndis* and usersim_fwp_* functions callable from C code
  • Fix bug in dll skeleton where DRIVER_OBJECT was freed during driver entry because it was on the stack. It needs to survive until unload.

Add cache-aligned allocations (fixes #31)

Signed-off-by: Dave Thaler <[email protected]>
inc/usersim/ex.h Outdated
* @param[in] initialize False to return "uninitialized" memory.
* @returns Pointer to memory block allocated, or null on failure.
*/
__drv_allocatesMem(Mem) _Must_inspect_result_ _Ret_writes_maybenull_(size) void* usersim_allocate_with_tag(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what is the difference between usersim_allocate_with_tag() with PoolType NonPagedPoolNxCacheAligned and usersim_allocate_cache_aligned()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't done cleanup, but usersim_allocate_cache_aligned doesn't do anything with the tag, so I think it should be removed. usersim_allocate_cache_aligned_with_tag and usersim_allocate_with_tag() with PoolType NonPagedPoolNxCacheAligned are similar, but usersim_allocate_with_tag should really detect any cache-aligned pool type (it doesn't yet). I suspect in the DLL form, nothing calls usersim_allocate_cache_aligned or usersim_allocate_cache_aligned_with_tag, but will check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will clean this up in a separate PR as part of the work for microsoft/ebpf-for-windows#2677. In the meantime, I have added some TODO comments in the code.

Also make more kernel functions callable from C code

Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
@dthaler dthaler marked this pull request as ready for review August 6, 2023 21:46
@@ -204,9 +201,9 @@ usersim_platform_initiate()
try {
_usersim_platform_maximum_group_count = GetMaximumProcessorGroupCount();
_usersim_platform_maximum_processor_count = GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS);
auto fault_injection_stack_depth =
bool fault_injection_stack_depth =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is size_t, not bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks

Signed-off-by: Dave Thaler <[email protected]>
@dthaler dthaler merged commit 8e6fdef into main Aug 7, 2023
5 checks passed
@dthaler dthaler deleted the wdf branch August 7, 2023 18:09
@dthaler dthaler mentioned this pull request Aug 7, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Etw* API support Add cache-aligned allocation
4 participants