Totally agree to drop Win8 support, that would make it a lot more 
straightforward.

_NT_TARGET_VERSION is indeed optional, but prevents that the SDK has to be 
selected explicitly for Win10 in the future, as it will target lowest SDK 
features automatically, at least in theory.


Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
________________________________
From: Alin Serdean <alinserd...@gmail.com>
Sent: Saturday, March 8, 2025 11:58:45 AM
To: Frank Wagner <frank.wag...@dbosoft.eu>
Cc: d...@openvswitch.org <d...@openvswitch.org>
Subject: Re: [ovs-dev] [PATCH 1/2] windows: Fix Win10 build with VS2022.

Thank you for bringing this up and working on it!

I had a similar patch posted on the ML but did not follow-up on it since I 
wanted to make more changes.

I would propose the following:
- drop targets for 8/8.1 since support for them has ben EOL for quite some time.
- lets drop the function OvsAllocateAlignedMemory altogether since its not used

Will propose a patch which encloses the above.

Not sure if we need:
_NT_TARGET_VERSION and to set the target version for Windows10

On Sat, Mar 1, 2025 at 1:39 PM Frank Wagner 
<frank.wag...@dbosoft.eu<mailto:frank.wag...@dbosoft.eu>> wrote:
This patch fixes some issues when building for Windows
on Visual Studio 2022 (only supports target version 10)
and current driver SDKs.
The build is currently failing due to missing variables in
msbuild properties and fails in driver verification.

Tested with VS 2022 and --with-vstudiotargetver=win10 and tested
if it still works for VS2019 / Win8/8.1/10 using the ci build scripts.
Tested for VS 2019 with same SDKs/WDKs installed in appveyor 2019 VM,
as documented here: https://www.appveyor.com/docs/windows-images-software/

Remarks: It is getting more and more difficult to build for Win8 these
days - so dropping support for Win8 in the near future is something
that should be considered. Currently, installing an SDK above the
Windows 11 SDK/WDK (build 10.0.22000.1) will break the Win8 build
regardless of whether it is installed for VS 2022 or VS 2019.


datapath-windows/automake / build script
-----------------------------------------------
VS2022 requires Version to be passed to StampInf, added version
to Windows10 make datapath_*.
Splitted datapath_windows_analyze for win8 and win10,
so this is now datapath_windows_analyze_win10 and
datapath_windows_analyze_win8, both are called from build script.
The ci build script will continue to work only with VS 2019 as it
requires to build Win8 for install.

msbuild configuration for Win10
-----------------------------------
- Fixed missing TargetVersion Windows10 which works currently
  for but building but is inconsistent set between build and package.
  In package it fails without TargetVersion as inf stamping requires
  a valid target version and target platform.
- Set DriverTargetPlatform to Universal, which is recommended here
  
https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/get-started-developing-windows-drivers
  if supported (see inf file updates).
- Set _NT_TARGET_VERSION=0x0A00 to target minimal Win 10/
  Server 2016 version, see also 
https://techcommunity.microsoft.com/blog/windowsdriverdev/building-drivers-for-previous-os-releases-using-the-latest-windows-driver-kit-wd/4374910

datapath-windows/ovsext/Util.c
-----------------------------------
ExAllocatePoolWithTagPriority is deprecated and fails
in Win10 driver verification.
Replaced ExAllocatePoolWithTagPriority with ExAllocatePoolPriorityUninitialized.
The function OvsAllocateAlignedMemory seems to be unused,
so a alternative may be to remove entire function.


datapath-windows/ovsext/ovsext.inf
----------------------------------------
The inf file was minimally fixed in this patch for driver verification.
In second patch - as it is optional - I will add an updated
inf file that supports running from driver store on supporting OS versions.


Signed-off-by: Frank Wagner 
<frank.wag...@dbosoft.eu<mailto:frank.wag...@dbosoft.eu>>

---
 .ci/windows-build.sh                     |  3 ++-
 datapath-windows/Package/package.VcxProj | 15 ++++++++-------
 datapath-windows/automake.mk<http://automake.mk>             | 11 +++++++----
 datapath-windows/ovsext/Util.c           |  8 ++++----
 datapath-windows/ovsext/ovsext.inf       |  1 +
 datapath-windows/ovsext/ovsext.vcxproj   | 17 +++++++++--------
 6 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/.ci/windows-build.sh b/.ci/windows-build.sh
index e54fbacf4..26701000d 100644
--- a/.ci/windows-build.sh
+++ b/.ci/windows-build.sh
@@ -12,6 +12,7 @@ CONFIGURATION=$1
     --with-vstudiotarget="${CONFIGURATION}" || (cat config.log && exit 1)

 make -j4
-make datapath_windows_analyze
+make datapath_windows_analyze_win10
+make datapath_windows_analyze_win8
 make install
 make windows_installer
diff --git a/datapath-windows/Package/package.VcxProj 
b/datapath-windows/Package/package.VcxProj
index 994c34dc2..f41bc0b14 100644
--- a/datapath-windows/Package/package.VcxProj
+++ b/datapath-windows/Package/package.VcxProj
@@ -68,19 +68,20 @@
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10 Debug|x64'" 
Label="Configuration">
-    <TargetVersion>
-    </TargetVersion>
+    <TargetVersion>Windows10</TargetVersion>
     <UseDebugLibraries>true</UseDebugLibraries>
     <PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == 
''">10.0</PlatformToolsetVer>
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
-    <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>
+    <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION>
   </PropertyGroup>
   <PropertyGroup 
Condition="'$(Configuration)|$(Platform)'=='Win10Analyze|x64'" 
Label="Configuration">
-    <TargetVersion />
+    <TargetVersion>Windows10</TargetVersion>
     <UseDebugLibraries>true</UseDebugLibraries>
     <PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == 
''">10.0</PlatformToolsetVer>
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
-    <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>
+    <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'" 
Label="Configuration">
     <TargetVersion>Windows8</TargetVersion>
@@ -95,12 +96,12 @@
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10 
Release|x64'" Label="Configuration">
-    <TargetVersion>
-    </TargetVersion>
+    <TargetVersion>Windows10</TargetVersion>
     <UseDebugLibraries>false</UseDebugLibraries>
     <PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == 
''">10.0</PlatformToolsetVer>
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
     <DriverTargetPlatform>Universal</DriverTargetPlatform>
+    <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION>
   </PropertyGroup>
   <PropertyGroup Label="Configuration" 
Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|x64'">
     <TargetVersion>WindowsV6.3</TargetVersion>
diff --git a/datapath-windows/automake.mk<http://automake.mk> 
b/datapath-windows/automake.mk<http://automake.mk>
index ea320e732..3c7d34b16 100644
--- a/datapath-windows/automake.mk<http://automake.mk>
+++ b/datapath-windows/automake.mk<http://automake.mk>
@@ -90,11 +90,14 @@ EXTRA_DIST += \
        datapath-windows/ovsext/precompsrc.c \
        datapath-windows/ovsext/resource.h

-datapath_windows_analyze: all
-       MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win10Analyze"
+datapath_windows_analyze_win10: all
+       MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win10Analyze" 
/property:Version="$(PACKAGE_VERSION)"
+
+datapath_windows_analyze_win8: all
        MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win8.1Analyze"
        MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win8Analyze"

+
 datapath_windows: all
-       MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win10Debug"
-       MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win10Release"
+       MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win10Debug" 
/property:Version="$(PACKAGE_VERSION)"
+       MSBuild.exe //nologo //maxcpucount datapath-windows/ovsext.sln 
/target:Build /property:Configuration="Win10Release" 
/property:Version="$(PACKAGE_VERSION)"
diff --git a/datapath-windows/ovsext/Util.c b/datapath-windows/ovsext/Util.c
index d703b2468..0e70993f0 100644
--- a/datapath-windows/ovsext/Util.c
+++ b/datapath-windows/ovsext/Util.c
@@ -59,9 +59,9 @@ OvsAllocateAlignedMemory(size_t size, UINT16 align)
          * XXX: NdisAllocateMemory*() functions don't talk anything about
          * alignment. Hence using ExAllocatePool*();
          */
-        return (VOID *)ExAllocatePoolWithTagPriority(NonPagedPoolNx, size,
-                                                     OVS_MEMORY_TAG,
-                                                     NormalPoolPriority);
+        return (VOID *)ExAllocatePoolPriorityUninitialized(NonPagedPoolNx, 
size,
+            OVS_MEMORY_TAG,
+            NormalPoolPriority);
     }

     /* Invalid user input. */
@@ -179,4 +179,4 @@ OvsIpv6AddressToString(struct in6_addr ipv6Addr, char* 
ip6String)

     returnedIpv6Str = RtlIpv6AddressToStringA((&ipv6Addr), ip6String);
     return returnedIpv6Str;
-}
\ No newline at end of file
+}
diff --git a/datapath-windows/ovsext/ovsext.inf 
b/datapath-windows/ovsext/ovsext.inf
index e68b94a36..59ae5304b 100644
--- a/datapath-windows/ovsext/ovsext.inf
+++ b/datapath-windows/ovsext/ovsext.inf
@@ -9,6 +9,7 @@ ClassGUID   = {4D36E974-E325-11CE-BFC1-08002BE10318}
 Provider    = %OVS%
 CatalogFile = ovsext.cat<http://ovsext.cat>
 DriverVer   = 10/10/2013,1.0
+PnpLockdown = 1

 [Manufacturer]
 %OVS%=OVS,NTx86,NTia64,NTamd64
diff --git a/datapath-windows/ovsext/ovsext.vcxproj 
b/datapath-windows/ovsext/ovsext.vcxproj
index 8ee56aa00..a3fc5e7b1 100644
--- a/datapath-windows/ovsext/ovsext.vcxproj
+++ b/datapath-windows/ovsext/ovsext.vcxproj
@@ -68,19 +68,20 @@
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10 Debug|x64'" 
Label="Configuration">
-    <TargetVersion>
-    </TargetVersion>
+    <TargetVersion>Windows10</TargetVersion>
     <UseDebugLibraries>True</UseDebugLibraries>
     <PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == 
''">10.0</PlatformToolsetVer>
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
-    <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>
+    <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION>
   </PropertyGroup>
   <PropertyGroup 
Condition="'$(Configuration)|$(Platform)'=='Win10Analyze|x64'" 
Label="Configuration">
-    <TargetVersion />
+    <TargetVersion>Windows10</TargetVersion>
     <UseDebugLibraries>True</UseDebugLibraries>
     <PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == 
''">10.0</PlatformToolsetVer>
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
-    <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>
+    <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION>
   </PropertyGroup>
   <PropertyGroup Label="Configuration" 
Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">
     <TargetVersion>Windows8</TargetVersion>
@@ -101,12 +102,12 @@
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win10 
Release|x64'" Label="Configuration">
-    <TargetVersion>
-    </TargetVersion>
+    <TargetVersion>Windows10</TargetVersion>
     <UseDebugLibraries>False</UseDebugLibraries>
     <PlatformToolsetVer Condition="'$(PlatformToolsetVer)' == 
''">10.0</PlatformToolsetVer>
     
<PlatformToolset>WindowsKernelModeDriver$(PlatformToolsetVer)</PlatformToolset>
-    <DriverTargetPlatform>Desktop</DriverTargetPlatform>
+    <DriverTargetPlatform>Universal</DriverTargetPlatform>
+    <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION>
   </PropertyGroup>
   <PropertyGroup Label="Configuration" 
Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">
     <TargetVersion>Windows8</TargetVersion>
--
2.48.1

_______________________________________________
dev mailing list
d...@openvswitch.org<mailto:d...@openvswitch.org>
https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to