From 308a30fbcd81b9bd374f7b7fed758f72a5136939 Mon Sep 17 00:00:00 2001 From: "Yang You (UU)" Date: Thu, 11 Dec 2025 17:39:25 -0800 Subject: Add affinity mask asserts, remove sln.old Added assertions to EnlpAffinitizeThread to verify BitScanReverse succeeds. Updated EnlRingDoorBell to properly acquire and release the spinlock around the Armed state check for thread safety. Removed obsolete netvadapterlibrary.sln.old solution file. --- .../netadaptercx/netvadapterlibrary/code/enl.cpp | 7 ++-- .../netvadapterlibrary/netvadapterlibrary.sln.old | 41 ---------------------- 2 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 network/netadaptercx/netvadapterlibrary/netvadapterlibrary.sln.old diff --git a/network/netadaptercx/netvadapterlibrary/code/enl.cpp b/network/netadaptercx/netvadapterlibrary/code/enl.cpp index a02fd43f..709c5a1e 100644 --- a/network/netadaptercx/netvadapterlibrary/code/enl.cpp +++ b/network/netadaptercx/netvadapterlibrary/code/enl.cpp @@ -84,10 +84,10 @@ EnlpAffinitizeThread( // next highest numbered proc for 1002, ... ULONG index; #ifdef _WIN64 - BitScanReverse64(&index, (ULONG64)affinity.Mask); + NT_FRE_ASSERTMSG("Failed to find bit", TRUE == BitScanReverse64(&index, (ULONG64)affinity.Mask)); affinity.Mask = (KAFFINITY)((ULONG64)1 << (index - (ProcIndex - 1001))); #else - BitScanReverse(&index, (ULONG)affinity.Mask); + NT_FRE_ASSERTMSG("Failed to find bit", TRUE == BitScanReverse(&index, (ULONG)affinity.Mask)); affinity.Mask = (KAFFINITY)((ULONG)1 << (index - (ProcIndex - 1001))); #endif } @@ -588,7 +588,9 @@ EnlRingDoorBell( ) { InterlockedExchange((volatile LONG *)&Queue->QueueEnd, (LONG)EndIndex); + WdfSpinLockAcquire(Queue->Spinlock); + if (Queue->Armed) { NT_ASSERT(Queue->ArmWaitEvent != NULL); @@ -597,6 +599,7 @@ EnlRingDoorBell( Queue->ArmWaitEvent->Set(); return; } + WdfSpinLockRelease(Queue->Spinlock); } diff --git a/network/netadaptercx/netvadapterlibrary/netvadapterlibrary.sln.old b/network/netadaptercx/netvadapterlibrary/netvadapterlibrary.sln.old deleted file mode 100644 index c39e8929..00000000 --- a/network/netadaptercx/netvadapterlibrary/netvadapterlibrary.sln.old +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.36717.8 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "netvadapterlibrarykm", "km\netvadapterlibrarykm.vcxproj", "{E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "netvadapterlibraryum", "um\netvadapterlibraryum.vcxproj", "{612F33AD-430C-4FE7-8000-35E15A5EB757}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Debug|x64.ActiveCfg = Debug|x64 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Debug|x64.Build.0 = Debug|x64 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Debug|x86.ActiveCfg = Debug|Win32 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Debug|x86.Build.0 = Debug|Win32 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Release|x64.ActiveCfg = Release|x64 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Release|x64.Build.0 = Release|x64 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Release|x86.ActiveCfg = Release|Win32 - {E2A65EFD-25CC-4AF0-B180-0CD56EE277A9}.Release|x86.Build.0 = Release|Win32 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Debug|x64.ActiveCfg = Debug|x64 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Debug|x64.Build.0 = Debug|x64 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Debug|x86.ActiveCfg = Debug|Win32 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Debug|x86.Build.0 = Debug|Win32 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Release|x64.ActiveCfg = Release|x64 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Release|x64.Build.0 = Release|x64 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Release|x86.ActiveCfg = Release|Win32 - {612F33AD-430C-4FE7-8000-35E15A5EB757}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {6D884183-BDDB-43F8-A3F9-410276822289} - EndGlobalSection -EndGlobal -- cgit v1.3.1