[dpdk-dev] [PATCH 1/1] virt2phys: virtual to physical address translator for Windows
Ranjit Menon
ranjit.menon at intel.com
Fri Apr 10 03:45:35 CEST 2020
On 3/29/2020 9:10 PM, Dmitry Kozlyuk wrote:
> This patch is for dpdk-kmods tree.
>
> This driver supports Windows EAL memory management by translating
> current process virtual addresses to physical addresses (IOVA).
> Standalone virt2phys allows using DPDK without PMD and provides a
> reference implementation. UIO drivers might also implement virt2phys
> interface, thus rendering this separate driver unneeded.
>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
> ---
<Snip!>
> +
> +_Use_decl_annotations_
> +VOID
> +virt2phys_device_EvtIoInCallerContext(
> + IN WDFDEVICE device, IN WDFREQUEST request)
> +{
> + WDF_REQUEST_PARAMETERS params;
> + ULONG code;
> + PVOID *virt;
Should this be PVOID virt; (instead of PVOID *virt)?
If so, changes will be required to parameters passed in to
WdfRequestRetrieveInputBuffer() call.
> + PHYSICAL_ADDRESS *phys;
> + size_t size;
> + NTSTATUS status;
> +
> + UNREFERENCED_PARAMETER(device);
> +
> + PAGED_CODE();
> +
> + WDF_REQUEST_PARAMETERS_INIT(¶ms);
> + WdfRequestGetParameters(request, ¶ms);
> +
> + if (params.Type != WdfRequestTypeDeviceControl) {
> + KdPrint(("bogus request type=%u\n", params.Type));
> + WdfRequestComplete(request, STATUS_NOT_SUPPORTED);
> + return;
> + }
> +
> + code = params.Parameters.DeviceIoControl.IoControlCode;
> + if (code != IOCTL_VIRT2PHYS_TRANSLATE) {
> + KdPrint(("bogus IO control code=%lu\n", code));
> + WdfRequestComplete(request, STATUS_NOT_SUPPORTED);
> + return;
> + }
> +
> + status = WdfRequestRetrieveInputBuffer(
> + request, sizeof(*virt), (PVOID *)&virt, &size);
> + if (!NT_SUCCESS(status)) {
> + KdPrint(("WdfRequestRetrieveInputBuffer() failed, "
> + "status=%08x\n", status));
> + WdfRequestComplete(request, status);
> + return;
> + }
> +
> + status = WdfRequestRetrieveOutputBuffer(
> + request, sizeof(*phys), &phys, &size);
Better to put a (PVOID *)typecast for &phys here:
status = WdfRequestRetrieveOutputBuffer(
request, sizeof(*phys), (PVOID *)&phys, &size);
> + if (!NT_SUCCESS(status)) {
> + KdPrint(("WdfRequestRetrieveOutputBuffer() failed, "
> + "status=%08x\n", status));
> + WdfRequestComplete(request, status);
> + return;
> + }
> +
> + *phys = MmGetPhysicalAddress(*virt);
> +
> + WdfRequestCompleteWithInformation(
> + request, STATUS_SUCCESS, sizeof(*phys));
> +}
<Snip!>
Co-installers are no longer required (and discouraged) as per Microsoft.
So you can remove the lines indicated below from the .inf file.
> diff --git a/windows/virt2phys/virt2phys.inf b/windows/virt2phys/virt2phys.inf
> new file mode 100755
> index 0000000..e8adaac
> --- /dev/null
> +++ b/windows/virt2phys/virt2phys.inf
> @@ -0,0 +1,85 @@
> +; SPDX-License-Identifier: BSD-3-Clause
> +; Copyright (c) 2020 Dmitry Kozlyuk
> +
> +[Version]
> +Signature = "$WINDOWS NT$"
> +Class = %ClassName%
> +ClassGuid = {78A1C341-4539-11d3-B88D-00C04FAD5171}
> +Provider = %ManufacturerName%
> +CatalogFile = virt2phys.cat
> +DriverVer =
> +
> +[DestinationDirs]
> +DefaultDestDir = 12
> +virt2phys_Device_CoInstaller_CopyFiles = 11
Remove this line
> +
> +; ================= Class section =====================
> +
> +[ClassInstall32]
> +Addreg = virt2phys_ClassReg
> +
> +[virt2phys_ClassReg]
> +HKR,,,0,%ClassName%
> +HKR,,Icon,,-5
> +
> +[SourceDisksNames]
> +1 = %DiskName%,,,""
> +
> +[SourceDisksFiles]
> +virt2phys.sys = 1,,
> +WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll = 1
Remove this line
> +
> +;*****************************************
> +; Install Section
> +;*****************************************
> +
> +[Manufacturer]
> +%ManufacturerName%=Standard,NT$ARCH$
> +
> +[Standard.NT$ARCH$]
> +%virt2phys.DeviceDesc%=virt2phys_Device, Root\virt2phys
> +
> +[virt2phys_Device.NT]
> +CopyFiles = Drivers_Dir
> +
> +[Drivers_Dir]
> +virt2phys.sys
> +
> +;-------------- Service installation
> +[virt2phys_Device.NT.Services]
> +AddService = virt2phys,%SPSVCINST_ASSOCSERVICE%, virt2phys_Service_Inst
> +
> +; -------------- virt2phys driver install sections
> +[virt2phys_Service_Inst]
> +DisplayName = %virt2phys.SVCDESC%
> +ServiceType = 1 ; SERVICE_KERNEL_DRIVER
> +StartType = 3 ; SERVICE_DEMAND_START
> +ErrorControl = 1 ; SERVICE_ERROR_NORMAL
> +ServiceBinary = %12%\virt2phys.sys
> +
Remove entire co-installer section below
> +;
> +;--- virt2phys_Device Coinstaller installation ------
> +;
> +
> +[virt2phys_Device.NT.CoInstallers]
> +AddReg = virt2phys_Device_CoInstaller_AddReg
> +CopyFiles = virt2phys_Device_CoInstaller_CopyFiles
> +
> +[virt2phys_Device_CoInstaller_AddReg]
> +HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"
> +
> +[virt2phys_Device_CoInstaller_CopyFiles]
> +WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll
> +
Remove up to here
> +[virt2phys_Device.NT.Wdf]
> +KmdfService = virt2phys, virt2phys_wdfsect
> +[virt2phys_wdfsect]
> +KmdfLibraryVersion = $KMDFVERSION$
> +
> +[Strings]
> +SPSVCINST_ASSOCSERVICE = 0x00000002
> +ManufacturerName = "Dmitry Kozlyuk"
> +ClassName = "Kernel bypass"
> +DiskName = "virt2phys Installation Disk"
> +virt2phys.DeviceDesc = "Virtual to physical address translator"
> +virt2phys.SVCDESC = "virt2phys Service"
<Snip!>
ranjit m.
More information about the dev
mailing list