From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 22743A0599; Fri, 10 Apr 2020 03:45:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C5B9B1D441; Fri, 10 Apr 2020 03:45:39 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 8FF941D440 for ; Fri, 10 Apr 2020 03:45:37 +0200 (CEST) IronPort-SDR: y8tZwg44Ww+shE6ULHSzLc5FFgkF/aVOIW4+ZH8V8hLw0f05przmC8EHCWrUGKs1y7vTG9Iqb+ dMV78FIdsO+A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2020 18:45:36 -0700 IronPort-SDR: AGMzY/ES36AQwt5d6D/HluQRVHrkJyoshnHJ9fYHJtll2rkFtO0Hjo/pGMJsvoQtAlbWhwxZjA RWVTzcChZHdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,364,1580803200"; d="scan'208";a="398786142" Received: from rmenon-mobl.amr.corp.intel.com (HELO [10.212.6.185]) ([10.212.6.185]) by orsmga004.jf.intel.com with ESMTP; 09 Apr 2020 18:45:35 -0700 To: Dmitry Kozlyuk , dev@dpdk.org Cc: "Dmitry Malloy (MESHCHANINOV)" References: <20200330041026.784624-1-dmitry.kozliuk@gmail.com> <20200330041026.784624-2-dmitry.kozliuk@gmail.com> From: Ranjit Menon Message-ID: Date: Thu, 9 Apr 2020 18:45:35 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200330041026.784624-2-dmitry.kozliuk@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 1/1] virt2phys: virtual to physical address translator for Windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 > --- > + > +_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)); > +} 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" ranjit m.