From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503490984521122.32650942398084; Wed, 23 Aug 2017 05:23:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 27B6221D2E635; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0072.outbound.protection.outlook.com [104.47.40.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 34B322095B9F4 for ; Wed, 23 Aug 2017 05:20:26 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:22:57 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hNGJ6k8AuDBdQUdf5kCf3O0bpuUDliXnHJD8XN0HcXk=; b=AxIAlpFmwkPUrt+HnIRQGkfqfn+7v4ih0kM1R5MDLzqrtNb0CxhFykO2dZJMu5YmmoLgrzH2rpk7yz36mR/SZJ3Q+xbFSZE5TXbQSGtnEpWswyHYLuM2un8DWdlkgzjMgKDgIF/d92NnL07ELKKdRNivzyKxPhH+Q5yWSyJD7Sc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:25 -0400 Message-Id: <1503490967-5559-2-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ae28d85-381e-4f66-9adf-08d4ea21b070 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:Gw/TMh9gUIwn5wIdEP7b9O3pzCpEqEGQf5+cCjMd93AEyzHbXi2xxuVOMfIFlGDt6VNEcvR/HARa4AhOcdmDRrdIxJ1Vm7dcI0uCCwTi8z+Ay6R8PZYvOdEuv3zSgupuLjcgd3oVpfqybORu4SqmzOBe9/gPD5tn9m7lYn5ycT7ZrcU6z/gC/GFAK/X64VDlzmOsPFx3RP17os9xy9jyWfk1idbYpmN++irFQhA0UHPm9PObHnppi2IdYIHc4Jvf; 25:QQK4PcCJNSD49adiFsmigZrb6AbjRdpAcWZEvbM2nihpH2H+ZOIkALIFLfXxUHhNRrvn+SOj4LwE4GvH5qv26Aq0ol1JusEbVZwdAv+H6CcRO5nYV+/j9IHEZ5nkaJE3eV2Wl3tN1WL3ptEIYgIKQRLQNR0PoUKziuyqhTjy11W2Px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n21tdM/4m9fffOix0rckDMupm5dnmw8A6kyE3zJ5WXi5Ny2KZqumel3grz1OK+29avJKhEwxg/mmz9Or2kk1gUaFhXQGhSWvAj8kpz8bUUCGW5LzxSquf9aLLbohSiOY3jwz07pnA/bmzrbsPT473AUI+zfVhtgCj7c2jre6kfeKynV4/sqhPhDMRbTC6g8tj141lB7JKeXyyXqRF+y2Lz/D5U6JfufTqlstd/pwoQ/29ZNWZLsxpcYFyYeg== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(966005)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(6306002)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:QGp2y/cPARf8u0QoiKrXcaOyyNPxjA0JsJ1CA7a5q?= =?us-ascii?Q?+HjuKUOClV4i01rClL3Urd63wsCLe6bfg2w1LZhZJMJ+j1EhjI2J6Q5ePdeZ?= =?us-ascii?Q?7y24Mq29K/Gc4EZaEcvvUqVh/dkx7N04H6+jM0bY93C80v6Sv2ZmNvEslIIS?= =?us-ascii?Q?WkGgtY1Pqf1/ekVvsJuSzZHvxk/kfBBeKGNDXPbLSMWvzdEFtXpTYYRcGqi0?= =?us-ascii?Q?Pv2WsTr10l3nLiYJYtvesoLIZUwCAzeHKjEuItQo5Ih+Jk4ZZgiI4e9bevoE?= =?us-ascii?Q?e5Kk39Da1Z9RfwXTjTNoB5fagDk+4kwgouSjLHXZoy4r4bwl1luujrQevSA7?= =?us-ascii?Q?qiQITYYIOKMeZ99yiqWiOCWWfkJ6tN+SYBx1ApuzhFXc4IwhQZJriHwdsqAi?= =?us-ascii?Q?fJHJmKO4VUJ1hXuAU4cBRcOAZS3SjsnBzLUvADQ3GIJvqH0Rg0vNPY0b4Q7n?= =?us-ascii?Q?B0uMw+zGbzZtNQ5a6GMa0pp54/oPlQIO4FQxnOVT2S66gDn+OuAYf1lOoBAj?= =?us-ascii?Q?nq4EZxqAVmvDy7wL6Vkdx0FuGAS0u2+6VwLbwRQPTZPl/S63qCuFlo3Pnxul?= =?us-ascii?Q?thX3C+tdmP5HNUqP5Sjcgo7DeyHqL6dKbKFrXWMyp/FnN3ydAYFMdnEL86rn?= =?us-ascii?Q?vwl+hJEc9/xMyJt5QT6YphPC72+tqN7yCW/OPpoev+huBNXxW+gM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/4vovQCRytXCfZgGeO4s/LAh+C/62RWs6mI8hljKx6F7EZftVb06QW770DYAgS2oYwGi3lEUDonCeCwN6eyL7RCGYlA==; 24:Yx52R5gz5wntL3mtYuituA2YHK5vCObBXtCqy8yiVrQnAmjiPfbCOLygy0DPFsIKi1v15MHRLuDs3wGcWrTiRPxjKrj1h18f9aM3yrv3NFg=; 7:/yXUqc4yblI8PoAkn3tUUkhIGyAFhjmo5C82C5CDq75gq6uJiUIpQ7DDWPlydf/uDsOhKCsllg9gQfPClUP0NbgYcIaJJXqiyA9XS34QzzrHFmYtdVG2cN20/d4clJigHbpGExMTFfbacmjSoqQdsco6Wdbf4zrgHdgtb9NZUNSPKLnQ0zKwvmtpy+sGpaMzWA+2XTTR/bdiWrxjl63nRZNNep5Bf8LrqIsOOVsPvok= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:KRE0xWvJiMNsakoxWuoFY3mpAAHQ5T4Cjv7s5XEbHEkXwVWXr6nxK308CWcURG7XDV0KByg5Pv3FO9Ld8vg5LhZizcxfZsInIDzjsXYMSjVicLkten4U2ClzEVGwIbue/pEYVgSskuRb4BpPc35gYJw2fEBk7LEt98pjUsLPdiD1CjciFtoHpCJtol9f44FWXlqbU2MEg1op6+BEwmSwCebpoIa0cBAe3fwidHpMkaYmZsZMNCNy7lW+6h2QG25v X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:22:57.9041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 01/23] OvmfPkg: introduce IOMMU-like member functions to VIRTIO_DEVICE_PROTOCOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch extends VIRTIO_DEVICE_PROTOCOL to provide the following new member functions: - AllocateSharedPages : allocate a memory region suitable for sharing between guest and hypervisor (e.g ring buffer). - FreeSharedPages: free the memory allocated using AllocateSharedPages (). - MapSharedBuffer: map a host address to device address suitable to share with device for bus master operations. - UnmapSharedBuffer: unmap the device address obtained through the MapSharedBuffer(). We're free to extend the protocol structure without changing the protocol GUID, or bumping any protocol version fields (of which we currently have none), because VIRTIO_DEVICE_PROTOCOL is internal to edk2 by design -- see the disclaimers in "VirtioDevice.h". The patch implements Laszlo's recommendation [1]. [1] http://mid.mail-archive.com/841bec5f-6f6e-8b1f-25ba-0fd37a915b72@redhat= .com Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Protocol/VirtioDevice.h | 143 ++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/OvmfPkg/Include/Protocol/VirtioDevice.h b/OvmfPkg/Include/Prot= ocol/VirtioDevice.h index fc166bd1a2b4..9a01932958a2 100644 --- a/OvmfPkg/Include/Protocol/VirtioDevice.h +++ b/OvmfPkg/Include/Protocol/VirtioDevice.h @@ -5,6 +5,7 @@ and should not be used outside of the EDK II tree. =20 Copyright (c) 2013, ARM Ltd. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -33,6 +34,25 @@ =20 typedef struct _VIRTIO_DEVICE_PROTOCOL VIRTIO_DEVICE_PROTOCOL; =20 +// +// VIRTIO Operation for VIRTIO_MAP_SHARED +// +typedef enum { + // + // A read operation from system memory by a bus master + // + VirtioOperationBusMasterRead, + // + // A write operation to system memory by a bus master + // + VirtioOperationBusMasterWrite, + // + // Provides both read and write access to system memory by both the + // processor and a bus master + // + VirtioOperationBusMasterCommonBuffer, +} VIRTIO_MAP_OPERATION; + /** =20 Read a word from the device-specific I/O region of the Virtio Header. @@ -321,6 +341,121 @@ EFI_STATUS IN UINT8 DeviceStatus ); =20 +/** + + Allocates pages that are suitable for an VirtioOperationBusMasterCommonB= uffer + mapping. This means that the buffer allocated by this function supports + simultaneous access by both the processor and the bus master. The device + address that the bus master uses to access the buffer must be retrieved = with + a call to VIRTIO_MAP_SHARED. + + @param[in] This The protocol instance pointer. + + @param[in] Pages The number of pages to allocate. + + @param[in,out] HostAddress A pointer to store the system memory b= ase + address of the allocated range. + + @retval EFI_SUCCESS The requested memory pages were alloca= ted. + @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocate= d. + +**/ +typedef +EFI_STATUS +(EFIAPI *VIRTIO_ALLOCATE_SHARED)( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN Pages, + IN OUT VOID **HostAddress + ); + +/** + Frees memory that was allocated with VIRTIO_ALLOCATE_SHARED. + + @param[in] This The protocol instance pointer. + + @param[in] Pages The number of pages to free. + + @param[in] HostAddress The system memory base address of the allocat= ed + range. + +**/ +typedef +VOID +(EFIAPI *VIRTIO_FREE_SHARED)( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress + ); + +/** + Provides the virtio device address required to access system memory from= a + DMA bus master. + + The interface follows the same usage pattern as defined in UEFI spec 2.6 + (Section 13.2 PCI Root Bridge I/O Protocol) + + @param[in] This The protocol instance pointer. + + @param[in] Operation Indicates if the bus master is going to + read or write to system memory. + + @param[in] HostAddress The system memory address to map to shar= ed + buffer address. + + @param[in,out] NumberOfBytes On input the number of bytes to map. + On output the number of bytes that were + mapped. + + @param[out] DeviceAddress The resulting shared map address for the + bus master to access the hosts HostAddre= ss. + + @param[out] Mapping A resulting token to pass to + VIRTIO_UNMAP_SHARED. + + @retval EFI_SUCCESS The range was mapped for the returned + NumberOfBytes. + @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a + common buffer. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to + a lack of resources. + @retval EFI_DEVICE_ERROR The system hardware could not map the + requested address. +**/ + +typedef +EFI_STATUS +(EFIAPI *VIRTIO_MAP_SHARED) ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +/** + Completes the VIRTIO_MAP_SHARED operation and releases any corresponding + resources. + + @param[in] This The protocol instance pointer. + + @param[in] Mapping The mapping token returned from + VIRTIO_MAP_SHARED. + + @retval EFI_SUCCESS The range was unmapped. + @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned = by + VIRTIO_MAP_SHARED. Passing an invalid Map= ping + token can cause undefined behavior. + @retval EFI_DEVICE_ERROR The data was not committed to the target + system memory. +**/ +typedef +EFI_STATUS +(EFIAPI *VIRTIO_UNMAP_SHARED)( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ); =20 /// /// This protocol provides an abstraction over the VirtIo transport layer @@ -361,6 +496,14 @@ struct _VIRTIO_DEVICE_PROTOCOL { // VIRTIO_DEVICE_WRITE WriteDevice; VIRTIO_DEVICE_READ ReadDevice; + + // + // Functions to allocate, free, map and unmap shared buffer + // + VIRTIO_ALLOCATE_SHARED AllocateSharedPages; + VIRTIO_FREE_SHARED FreeSharedPages; + VIRTIO_MAP_SHARED MapSharedBuffer; + VIRTIO_UNMAP_SHARED UnmapSharedBuffer; }; =20 extern EFI_GUID gVirtioDeviceProtocolGuid; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503490989732107.8097467257985; Wed, 23 Aug 2017 05:23:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A7F8821D2E646; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0072.outbound.protection.outlook.com [104.47.40.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7D37F2095B9F4 for ; Wed, 23 Aug 2017 05:20:26 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:22:58 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jXyNXcTomLuFaOFpl2SIr8bcH3JRcPUc5li8DCu6M0Y=; b=KoSPpdVs6rx4ayHs4mzGznU54d9G0kiV55Obkl/zaitIBZYLvK8Gabmf6f3bijz6er5HjmFkC1GbdRWBAR17po7XEkLvhVDuy7TjTRBgExM90ciEcYwmO0hE3D9fjHTz2OwSBHBIGYtcdYydOLt1qgEKmzZAN0MwlgednnkrgA8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:26 -0400 Message-Id: <1503490967-5559-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d56a2b0-3774-418e-bef7-08d4ea21b0b5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:CXJwAGj31fiN1+FTYQmOgUB+ZSnEbELB6qDmCshnZlAcKWXwDcAR5GnFE75x41IanVBldc9w4lyDNIvSTpcRRuswg1jLBWxKnzEmdYS29kZbvpAMuu42edZpxrpYRn484WJq9ibMc5hm/q2sZ33hXjEqxqvDrA0luWjEdJz3/OzCWI8GR1Dy/yfiQ05qzp2jB0HQTJXW1YGdo7HKgtR9WZUb1oK6HGADsqA/EDrN37JcgWfeYUVKJp/k3DPiwnMd; 25:Okv0wFjtNSYx8VrQRno9cknbBsF462pcoDQBN9h5hZhgWJN2lQLM4J5ksm9d1pnihbAX0D5KtLbYNGDnw5+ouAgkdonCxy0dHUqExZT6wJw6Vzle27o6PV3BDZNP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m5zVDHSUMjYEP8x8WeDZMPyIS0RXZrg8J2Rars4U7vLTGZSuWEmWiUcjsTKZWVwFO7f71VTC4aSdSxzZ0BLUY/1q6h9eQ38scVFTUerq/Phgpxu07/0RqQCAeueS4XuUftt/WDoRXaJKqjAIxmcJ1O4vDV5TmiOw1J9XTH2n0oL2csEYJrSov7iyuxe1w9lI1Mk9HSXAKiO7qYTyJev1EycE9a6ryyHyMokICIHc/7yXLv93LF0qtlGt2dcawNWbpUA5Ge5NIyZ48AdyTvnj0USdVjnnDpmj8zJd4klhQzoWbQYBpQlkD/w== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:axrQ57j4sdhuDTn1vC+VTgDACY+ilJiyNbQ5jHPez?= =?us-ascii?Q?GWlLjxVyTM57DoAfe/435JF/npw9HAk7lj1CBZnV+f9ZvmOpfMAL+1FHOjFy?= =?us-ascii?Q?O+jTQ/sD834ZzpAxsIbCxhVIsgR/eLgfO4P5xeCALYddx8wz6iGrjPxRwKqs?= =?us-ascii?Q?xhiuVbaqIIcEUFmV5h+K1EcRpgBzHDQaS8uQnX0WiZ9G/zoySQgtwYz2kg2X?= =?us-ascii?Q?FVK8Icw5dZXony+8FmuoDzSrLe9rM+gFJtlmcaTvWAhCAI4rJir2GsN/mF4h?= =?us-ascii?Q?6SE/ifPINfIvqLv10NFFLKIz5lYGCmSyfZhJB2ouesu3uHYMD9ouecHn1meo?= =?us-ascii?Q?sYkajQDROsG1zp3xnA2MXJ9nAOis4CvxdnXMtwbRFbGr1r+dKzwY+PyiGSou?= =?us-ascii?Q?yJnL/g6JQCBX7zMxJSwjt0D7CUcaYyFT+JltWMBdWrj4/QwxmwAuV2WDN6NR?= =?us-ascii?Q?BMR+7eK1u3L+kD34CzYOe/nhvHV+FjTkOrhWJ2VOkXlo4hIkdPYmZweVVams?= =?us-ascii?Q?HZ+BFulLHEXorKZnaWLMrdmIikiPDU6cgkQiFoD9vVry7972YyLD8xS+Gfh9?= =?us-ascii?Q?Byk+oAljev06y7dp/uc4nCat0u7GORP+9MtN8O17IRoE58J4yhecIFb61gNS?= =?us-ascii?Q?R8fKRabd3IEUkyHxltJ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qpLPo1frTEX/yM28BY0qE+jIGFozPLqus2pDiuqz/ISk8TT2hQra7qwA8nm7ep/aiHE05FMumzKpJ/tWQXuVgv7RGFH5EWImMfCs5j6RF3SqEhuaAbPPm3kzg==; 24:qZa3Z15RUH9y20VOjjATGquoeAq46PSbj9uoVIjD2n6LE3tdNffoK+Dca8E5SoEVX5/+m88u9H0fCrxaW/kQweBmVP3XpSxIAL0v8V1cZOU=; 7:AS2854Q6wNb9K0QIp6G7W7dkCP0CaY5/jcyU00m5z4NXWhMZRmadDPjXNmBFPvaMaqlYne++GbBb9Dt+9QOR/hw+GL9zYGcruoO2Ho2iWx3X6uQe1YiwmGA0wRwQtubaLmZB2JjWB0WgxuVWag2dMQO1tIoCBZZsw3IsRuBb5+yxTgXqiu9sKXRgc7b62biJrCTsu6EK/faeFwMz+J6QV7kLnnjj0x+BLwgF8sO+a4A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:NdgXPlt5YSWemN/K/iCN/IudPVVakhekBYLZl9aMv7lTPYwaPM9MbQnnS1FWBqGA9/JCVlTi0lDIx4l1nJuUV2neXOXnJ/3ioo5+7zq82cIhHEnrGZByoJVrkozeSC41pzehD5u/38yBqboHgC2eu3nXMRVsE7DsTx2O7KlUPe53zUIDZoaiP6MbVJ13PtdTPbmDxteHiT7fihWPFu3lWd2qL/DEXf+VwVM1VaUphNUe7J5e9r8aJAP4DSwe0fMc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:22:58.3885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 02/23] OvmfPkg/Virtio10Dxe: implement IOMMU-like member functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch implements the newly added IOMMU-like member functions by respectively delegating the job to: - VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages() -> EFI_PCI_IO_PROTOCOL.AllocateBuffer() - VIRTIO_DEVICE_PROTOCOL.FreeSharedPages() -> EFI_PCI_IO_PROTOCOL.FreeBuffer() - VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() -> EFI_PCI_IO_PROTOCOL.Map() - VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer() -> EFI_PCI_IO_PROTOCOL.Unmap() Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Virtio10Dxe/Virtio10.c | 122 +++++++++++++++++++- 1 file changed, 120 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c index d7ea4432bcb6..89ccac8c1c04 100644 --- a/OvmfPkg/Virtio10Dxe/Virtio10.c +++ b/OvmfPkg/Virtio10Dxe/Virtio10.c @@ -2,6 +2,7 @@ A non-transitional driver for VirtIo 1.0 PCI devices. =20 Copyright (C) 2016, Red Hat, Inc. + Copyright (C) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -15,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -772,6 +774,117 @@ Virtio10ReadDevice ( return Status; } =20 +STATIC +EFI_STATUS +EFIAPI +Virtio10AllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN Pages, + IN OUT VOID **HostAddress + ) +{ + VIRTIO_1_0_DEV *Dev; + EFI_STATUS Status; + + Dev =3D VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); + + Status =3D Dev->PciIo->AllocateBuffer ( + Dev->PciIo, + AllocateAnyPages, + EfiBootServicesData, + Pages, + HostAddress, + EFI_PCI_ATTRIBUTE_MEMORY_CACHED + ); + return Status; +} + +STATIC +VOID +EFIAPI +Virtio10FreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress + ) +{ + VIRTIO_1_0_DEV *Dev; + + Dev =3D VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); + + Dev->PciIo->FreeBuffer ( + Dev->PciIo, + Pages, + HostAddress + ); +} + +STATIC +EFI_STATUS +EFIAPI +Virtio10MapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + EFI_STATUS Status; + VIRTIO_1_0_DEV *Dev; + EFI_PCI_IO_PROTOCOL_OPERATION PciIoOperation; + + Dev =3D VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); + + // + // Map VIRTIO_MAP_OPERATION to EFI_PCI_IO_PROTOCOL_OPERATION + // + switch (Operation) { + case VirtioOperationBusMasterRead: + PciIoOperation =3D EfiPciIoOperationBusMasterRead; + break; + case VirtioOperationBusMasterWrite: + PciIoOperation =3D EfiPciIoOperationBusMasterWrite; + break; + case VirtioOperationBusMasterCommonBuffer: + PciIoOperation =3D EfiPciIoOperationBusMasterCommonBuffer; + break; + default: + return EFI_INVALID_PARAMETER; + } + + Status =3D Dev->PciIo->Map ( + Dev->PciIo, + PciIoOperation, + HostAddress, + NumberOfBytes, + DeviceAddress, + Mapping + ); + return Status; +} + +STATIC +EFI_STATUS +EFIAPI +Virtio10UnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ) +{ + EFI_STATUS Status; + VIRTIO_1_0_DEV *Dev; + + Dev =3D VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); + + Status =3D Dev->PciIo->Unmap ( + Dev->PciIo, + Mapping + ); + + return Status; +} =20 STATIC CONST VIRTIO_DEVICE_PROTOCOL mVirtIoTemplate =3D { VIRTIO_SPEC_REVISION (1, 0, 0), @@ -788,7 +901,11 @@ STATIC CONST VIRTIO_DEVICE_PROTOCOL mVirtIoTemplate = =3D { Virtio10GetDeviceStatus, Virtio10SetDeviceStatus, Virtio10WriteDevice, - Virtio10ReadDevice + Virtio10ReadDevice, + Virtio10AllocateSharedPages, + Virtio10FreeSharedPages, + Virtio10MapSharedBuffer, + Virtio10UnmapSharedBuffer }; =20 =20 @@ -906,7 +1023,8 @@ Virtio10BindingStart ( goto ClosePciIo; } =20 - SetAttributes =3D EFI_PCI_IO_ATTRIBUTE_BUS_MASTER; + SetAttributes =3D (EFI_PCI_IO_ATTRIBUTE_BUS_MASTER | + EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE); UpdateAttributes (&Device->CommonConfig, &SetAttributes); UpdateAttributes (&Device->NotifyConfig, &SetAttributes); UpdateAttributes (&Device->SpecificConfig, &SetAttributes); --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150349099377047.81857227860155; Wed, 23 Aug 2017 05:23:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E7C3621E14542; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0072.outbound.protection.outlook.com [104.47.40.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A1EB721D2E628 for ; Wed, 23 Aug 2017 05:20:26 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:22:58 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9sNU4EArdpOZZEoCie5hREbdTLwYI41Xs5mivMP4D7Q=; b=smmTymWtyoUBImC1tEuFQvRFpL+8PQIrIub/nzsmjkh73R6m0aDq8hao7/HSNELdW/E58mR6qF591VfYEkomNTxPsjGLDy+unD0YSNjVAc7zVNTaUxbS0KgY1caZWh12dPsobAr/qnWA2uiTxgX12rYzXd+HDgA+DGevGf8cEBg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:27 -0400 Message-Id: <1503490967-5559-4-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: caf8664e-33f2-4f1f-0a18-08d4ea21b102 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:iXvAx5bsXvFHr6aezxKXWO3QclhXnKG4mdm7MORKG11+QSKHiClcbWPPbIUfjTLnACzu5NouzwJzSfFStV3ZbypTgkT3YJ4/X5KC10qAyK6apNzfj4tGe6PYZCHXlwDy3dnB5Gi3D21Hrww5npu9kNV+mI7pUiX5bifBfdlMmE5yGdD1LfJouWG8dMg5UtESINhCQ6I2w9l1TvEFH+kP87vyCQi5s/Lb2eDw5yeWxFUD42YB+UGk2B2HBpkL5Xxh; 25:nhIHA86V7pT9RQOVV+yXbvDKrGRja7CX3PawHrjjDoY+rvKsuZnkoetOd1IDgB7VzNmYPMDlbiQu/QLVTKRRMz9OQO3J65c8jDDeTuUaSkFPcAkueWLKjU+71GBQIEoPD4jlaYJoEREoyKbJCFacpEjYck1l4Vcm4DN0tJsRav1Pp/VE8Gd5fG6IhkTXzacOd1BusjeTGc29yf6kg9lYwK65PxIqga10Yv/6jNDCZ+IW4FP1QCN9uEZe00314RIuoCs/6NrCi+992+4yCkct1gC9T+sDGHI1xX66Hc8BncRIDOalh/d+Lt/SyRYIXrH/KjXfu9/sa2u+65ccgGLTLw==; 31:K8TrxvmseTLJ/w/xhXe8FevDXVH5vmSbedkx18gtV4MZR30cglc7TnqBSBNYM67md2GjVMJ1HR2J7Cc0PBh41rajUJSotaudXF4n3gjhLlOGve6b0/3/SUnBHV/ID0TOuQzYZtmON09Eb3BLR9vn4Gzq/8zzjn7z7rT463audn9Hbu8BwWOBRwK0GgaWLkUeUN7nLABMYnqNseszD8x08ALU/aoJSjslmp6taxZMmoc= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:/EG7q+1NcL3iKqzxMyGlqH5d6xLqMHhnGzAqqFqBSSmiE/2A5/+cGJPAc8jP9k1HJQ997jPLMtrjS4amqGxtrSN2NeC8ESH/mSAtuYA75zb+WA2yGlqY8Zp4vpZHAgMmjhl+FwWnlswZzRtqoEoW6CT0AujFloSuXoOEBQ7CXij0FbfIxhqaN0ok1b54wyeWjV8t3X7c3TB4aBIEhFYhHK6Zxy8A9H+OZdgaw5I4TNyEYI5TVXSc+VYK29KL4hHUHzPXwG6mTu1LNPxL+VjSGeX6QSSlu9SM51eNORFtU5dUpgVptcOeh4bho34Djd50DvNNVuvanoA1nbiyVHEXbL3/IZKnq5endfCQoWRjIBkPvyVmWf0V/IVuJ7PhGgKW7BskMB+GrgpSucHPYxZQwcHnmgrPi2gteZRroauPSlMCNbkOz/raHC4laA89CXHx4EVg/VKm5fI6G4ykHXd6Rfs67MB8csFuE1ocNQMYQ8oQl8HVULNfvjf745twZOFV; 4:2GVAYu0A3iH9RDhQHQMOMNaaL3T6M+dUIzPl2FRrQILk17ha4jSZHzZXsdjL2ZL4XWtWNSks1xxWTvRf2hFkKZiwmYh8I97QrxbbotfAcjMoALt11wBFQVhrKTym4lvHXE6HwtgbLH4/Hcvhxjai+0uzbLUAF1INnuT1uY/FVORCrq/r90FyN/2YrjrYHZ7APWBESAFbqo4prA8Iddyo/yCMrecPj3oaZh/0B/E8B0T+6n0cDhJGF0PQRSJfQuMhvNc2x/kefqYcwr4Gz34EsoLuMLBOAAu807d3RLiwLVbaPP6jHjvEka1StNu3kEormcUOoNyB+AquYEFFucrAtQ== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:KTl/gyIX4qhLkeZKlDTkQkocypOXQvqldDwH3qreV?= =?us-ascii?Q?uGUCXwfEMctE7C5Cx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NstkBEC4a2p4V3DbWjknjMU3pE6fC26/aj4Loc+rr8eLHn8hdcNeybcQJ/92qYeP68hwHWEKmmEl/TqhIiqnwjRAa2xUuBlZmWBkoebEw659r0ihd5DZVsjzUm/AM1ztNn/FloAJuCWZ5S5yJYM4cA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:88Hy7eYpZgrmY1out1e2jTDbtkkLJN/mA9Fxe2x0tkR2cWUIrgWk2TBnk8HpdPyexm2NKRhM/n8x15BsO9NnUTf6b41yoajAW0p/CKoU5cef8fNZfxyzp3IAAtiMDsks3088Bm0sNlRyK+85Uiz1pGQdGtSu/ldNOrnzhoyLVK8SEd47gjygkoz81nn1GpGNkWLuFAE8wHBtA624A3SrgH+OLYDkWagmHM+hQJrNQEdr+vcG8CjPOBGU/1ILmhct X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:22:58.8885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 03/23] OvmfPkg/VirtioPciDeviceDxe: implement IOMMU-like member functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch implements the newly added IOMMU-like member functions by respectively delegating the job to: - VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () -> MemoryAllocationLib.AllocatePages() - VIRTIO_DEVICE_PROTOCOL.FreeSharedPages () -> MemoryAllocationLib.FreePages () - VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer () -> no-op - VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer () -> no-op Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h | 34 ++++++++++++ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c | 7 ++- OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c | 58 ++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioP= ciDeviceDxe/VirtioPciDevice.h index 6f51f816ef0f..41df5a98e560 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h @@ -3,6 +3,7 @@ Internal definitions for the VirtIo PCI Device driver =20 Copyright (C) 2013, ARM Ltd + Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -156,4 +157,37 @@ VirtioPciSetDeviceStatus ( IN UINT8 DeviceStatus ); =20 +EFI_STATUS +EFIAPI +VirtioPciAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + OUT VOID **HostAddress + ); + +VOID +EFIAPI +VirtioPciFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + IN VOID *HostAddress + ); + +EFI_STATUS +EFIAPI +VirtioPciMapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +EFI_STATUS +EFIAPI +VirtioPciUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ); #endif // _VIRTIO_PCI_DEVICE_DXE_H_ diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c b/OvmfPkg/VirtioP= ciDeviceDxe/VirtioPciDevice.c index 8aae58e8b482..d4b4ec21c34d 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c @@ -5,6 +5,7 @@ Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
Copyright (C) 2013, ARM Ltd. + Copyright (C) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -40,7 +41,11 @@ STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate = =3D { VirtioPciGetDeviceStatus, // GetDeviceStatus VirtioPciSetDeviceStatus, // SetDeviceStatus VirtioPciDeviceWrite, // WriteDevice - VirtioPciDeviceRead // ReadDevice + VirtioPciDeviceRead, // ReadDevice + VirtioPciAllocateSharedPages, // AllocateSharedPages + VirtioPciFreeSharedPages, // FreeSharedPages + VirtioPciMapSharedBuffer, // MapSharedBuffer + VirtioPciUnmapSharedBuffer, // UnmapSharedBuffer }; =20 /** diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c b/OvmfPkg/Virt= ioPciDeviceDxe/VirtioPciFunctions.c index 5f86914265ea..bd912cca9b29 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c @@ -5,6 +5,7 @@ Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012, Intel Corporation. All rights reserved.
Copyright (C) 2013, ARM Ltd. + Copyright (C) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -271,3 +272,60 @@ VirtioPciSetDeviceStatus ( return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS, sizeof (UINT8), DeviceStatus); } + +EFI_STATUS +EFIAPI +VirtioPciAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + OUT VOID **HostAddress + ) +{ + VOID *Buffer; + + Buffer =3D AllocatePages (NumPages); + if (Buffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *HostAddress =3D Buffer; + return EFI_SUCCESS; +} + +VOID +EFIAPI +VirtioPciFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + IN VOID *HostAddress + ) +{ + FreePages (HostAddress, NumPages); +} + +EFI_STATUS +EFIAPI +VirtioPciMapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + *DeviceAddress =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; + *Mapping =3D NULL; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtioPciUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ) +{ + return EFI_SUCCESS; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503490997675253.7808827611667; Wed, 23 Aug 2017 05:23:17 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 27EBF21E2DA61; Wed, 23 Aug 2017 05:20:29 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0072.outbound.protection.outlook.com [104.47.40.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C683D2095B9F4 for ; Wed, 23 Aug 2017 05:20:26 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:22:59 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jYsfQGp2XaMBi3D71uCWntoP87Md6Po6hVCn3UCViJw=; b=h1Hy+8dM4MqpXjfcJW5KuoZxzWFIfl5GSK0c3sFwZgsYO/CN1b2Kj0+9G4qB2vEj6GYRADoiPE1TEkxSD16C/x81InqCI5Ew2GD+eZBa8yD0QF+TgoC+vQ+OsMERXc85MvuYa0EXMt9IbvhoiFclvEjXD6AByg5sIhnxQqjW2EE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:28 -0400 Message-Id: <1503490967-5559-5-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 954d4f7e-9af2-4580-908c-08d4ea21b149 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:isKUImTWk4a7lzx3nX41IDq3Ig7DkZgyhz7lfqffZlwk5nnS+0xJYSeVbTK665IlncY8OkESHBVLnPOCYM/GWjfZX7E3mQxym59XRQQxH+XwTD4q6rGRXGE2XqwqkDX2TjwdvYO47oJqWFi9gJZNSBDS6jNLd1RL1SbWYTZv+hVlh8buTXyB6UGI/AGe779FeZgnfAyqM5u3V46mRMm9KHJrHMzOa07+M1xzvi0G+IH/1SF5+gZfOJc3IJm/oGYb; 25:PcMpelKNyQQ/4chYKNhEWu+T/eoz8LuoHNTAH9jvhLTUv9UstN7VrDiXt2Tk73WARGFE+lu7mZTmlY64hUes/LBavXJTHZfV81W86uD8aK4xyEnNz/HgWKsxKjGJ4CFPJwoPz5alem+0Xb1VTeww67jRr3zSP3OW+swFrds3A3pzkML0gUQpeiaBvoehk3dn8urMxM9QSueNyprc/srrC40rMhhl7+X+AdQs6OZrf8kFWEzv2gZVWnafmPAvSBLsvqmNrhyx7VRpXehfH0WPR4W8lwfON1AG8pYwm0+P3Cfk8bQDidUgGNQj2vsWiMXFQeSjbmw9bKSa8fkX+wT9Uw==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xDfc8L+3Rx3LTSm6O/bedW3fjfNoSB8lnndF5pxucW6qKSXYhEsxuzRqf5rr7hR2R7+yodSy3A5JGthNyHm0xXC8xUcUnVrRdc8OT9I9DPir+eRmQUiH/BCk7A== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:pNykiIGhUvKR1BrzH4PWudmEijHcCqIHeqzS5yMmm?= =?us-ascii?Q?J++NSwOquXmwbQZE4Tne6XM9I57+XQs4ncZ7U0W7TEnh6lBYxxj45QXhm6Zt?= =?us-ascii?Q?CjhdnElO61nJcP9ziW1nWP1FKpbU6x+SvGQdrmcc3Wxp8eXZLPVoNYeNc7qQ?= =?us-ascii?Q?7CB4jPz6IqXlAo0qi41HEqTjwj9NdRwVKXHyo1jXqCmoPEMJkK9LNQ3tguDV?= =?us-ascii?Q?4exNc3ViIc/1RBxisvqXCWSIXW2FXKkumMMh2FQ8dRZr2pfR+xI2Om6uVTUv?= =?us-ascii?Q?J883lhzeWHO2EJUpawFr6OOnVl2ArEGgS/zck57rHS/FimIcoAS0gndQOnmu?= =?us-ascii?Q?oe+x4JRdyxfcyFd9LdWAMaMhoIXcz9W6yDgYeuaAo5WHULwSNy8jHLrmx8eR?= =?us-ascii?Q?ljwW8Zf0sEJ87o2kTCPiKpWaRDax/TgRemPD/A/oMnTrdbjyva+z9SomvvrA?= =?us-ascii?Q?3P6H0TNZfyR1npZH05tL4SOZJEehYmMzQF8RrjBjAsA8sr5oZFa7eJkupwXy?= =?us-ascii?Q?4vRHPz3f0LI8m9TLTVN0gDWdNgc3/PB0NNd7Zay4NBlPVaPOa3qqsoLXEeOg?= =?us-ascii?Q?G6UAQ6qEiOEgyd3QY4GYhAWaztpvwHb2BYowvJmGh7bJFpjkzpYBBZZc2Qbj?= =?us-ascii?Q?3aieQXAAHVy78kovPpqIUkChBc1I/EKxfiJEMz/fJTbXxlgN8Rc4B3oj6SqE?= =?us-ascii?Q?wpAY7RtRGEpEzCK72gxXS7ixP81wl8IF4FJNMWP3dR0bu/TKVICpwOmR6AFE?= =?us-ascii?Q?KvaqlX85XsgGy1r6PrOpzVH2kTD+9gTjeZ8DpHIYc5cZeLvC0tT3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dNmVFgkz0WZM6vZg6VLM0rze9m7VYfb+FV4PfI5aeW14Wx5z+atKk/5RNrr7pnZe8OsBLzsEm76T/AgyZ1B5Yt44d8QhASlQMmNsSdaDj2791/UraCDbZK14hvycSKUW6HMALLcCIgkJWFBBQ6pv6XWcy/NVweFrFfJvPrsvTDcvqdOxanxZ5FfDQq3TmcBx8BokmkcZSEjl1OHqL2yVsdCcPtL5aWRBUx+P5MRzw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:U7rb3j5bCOL7Nn9f0jYjgHLfGDvO/377SYS8mI+Xn5QaT0v5Q0ExrT6y/Bgn8jL2eYtJ/QNF5FYiHzTL2acNNuXRAxqk1SE2MDtqk4tQd4PPtBYGQn65Xa2oawVJeh47L62x0SwzuwN7dHiikdbPrDkZxjVFJAct9l/p6Mvg61CkEo+3zFEOX3Aetg8Yuqs7gHA7MW54U9qDgQh0VDEOcdQhuOIw+yVWqZLE4NGCKkazKWurAKe1ORbvse/1RAv9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:22:59.3416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 04/23] OvmfPkg/VirtioMmioDeviceLib: implement IOMMU-like member functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch implements the newly added IOMMU-like member functions by respectively delegating the job to: - VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () -> MemoryAllocationLib.AllocatePages() - VIRTIO_DEVICE_PROTOCOL.FreeSharedPages () -> MemoryAllocationLib.FreePages () - VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer () -> no-op - VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer () -> no-op Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h | 36 +++++= ++++++++ OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c | 8 ++- OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c | 57 +++++= +++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfP= kg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h index bedd635e1a86..e5881d537f09 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h @@ -3,6 +3,7 @@ Internal definitions for the VirtIo MMIO Device driver =20 Copyright (C) 2013, ARM Ltd + Copyright (C) 2017, AMD Inc. All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -25,6 +26,7 @@ #include #include #include +#include =20 #define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O') =20 @@ -137,4 +139,38 @@ VirtioMmioSetGuestFeatures ( IN UINT64 Features ); =20 +EFI_STATUS +EFIAPI +VirtioMmioAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + OUT VOID **HostAddress + ); + +VOID +EFIAPI +VirtioMmioFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + IN VOID *HostAddress + ); + +EFI_STATUS +EFIAPI +VirtioMmioMapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +EFI_STATUS +EFIAPI +VirtioMmioUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ); + #endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_ diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfP= kg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c index b1d443ea7007..fce934e1e953 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c @@ -3,6 +3,7 @@ This driver produces Virtio Device Protocol instances for Virtio Mmio de= vices. =20 Copyright (C) 2013, ARM Ltd. + Copyright (C) 2017, AMD Inc. All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -15,7 +16,6 @@ **/ =20 #include -#include #include =20 #include "VirtioMmioDevice.h" @@ -35,7 +35,11 @@ static VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplat= e =3D { VirtioMmioGetDeviceStatus, // GetDeviceStatus VirtioMmioSetDeviceStatus, // SetDeviceStatus VirtioMmioDeviceWrite, // WriteDevice - VirtioMmioDeviceRead // ReadDevice + VirtioMmioDeviceRead, // ReadDevice + VirtioMmioAllocateSharedPages, // AllocateSharedPages + VirtioMmioFreeSharedPages, // FreeSharedPages + VirtioMmioMapSharedBuffer, // MapSharedBuffer + VirtioMmioUnmapSharedBuffer // UnmapSharedBuffer }; =20 /** diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.= c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c index 9142d4a162c0..644ec65e1788 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c @@ -293,3 +293,60 @@ VirtioMmioDeviceRead ( =20 return EFI_SUCCESS; } + +EFI_STATUS +EFIAPI +VirtioMmioAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + OUT VOID **HostAddress + ) +{ + VOID *Buffer; + + Buffer =3D AllocatePages (NumPages); + if (Buffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *HostAddress =3D Buffer; + return EFI_SUCCESS; +} + +VOID +EFIAPI +VirtioMmioFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN NumPages, + IN VOID *HostAddress + ) +{ + FreePages (HostAddress, NumPages); +} + +EFI_STATUS +EFIAPI +VirtioMmioMapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + *DeviceAddress =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; + *Mapping =3D NULL; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtioMmioUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN VOID *Mapping + ) +{ + return EFI_SUCCESS; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491002261952.3872606382515; Wed, 23 Aug 2017 05:23:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6476521E49BA5; Wed, 23 Aug 2017 05:20:33 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0071.outbound.protection.outlook.com [104.47.40.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 14C4021D2E633 for ; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:22:59 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CvA43yYOr0PgDKMJ7uYbn386lOh1+JVZEX/McJOaGTk=; b=mojRUYst95x8A+4T2L81DAVInVlpJola1NTvlZ0FToR5E5aXqneOG1Hf3HOo4LVrX+a8jvYWvolTwsz1PBvRcJvuJw4g90JSHUQuOEOpFgjDhAYushtyKAjrF56GtXBOiE65Tt5BO2w2jJzfM34BUYcxbor/89x5he8HPY2C2Yw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:29 -0400 Message-Id: <1503490967-5559-6-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16a60458-2883-4312-dba7-08d4ea21b195 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:wwpTuem/qwtyj1ZuXFF4U+A04SVmK3PC8KVJrWAzNhxwSCeGs/sc+w01roHYqcVgI3NzE/2tF0ziNVG8n2i2eQnuY+9kX2DT2Rtc9mJSXDtE7tTHW/+ASjUKqvS1vv3FVHZwpUSBnCWc/tmALHJksFutkEl7WnOVj6r9ZjP7SN+eQggxQsRjH/iZYyC3o5l1s+bsP5qNo/il0bxVifnJ2JsiutIrlr60VK5hhjHVsS3GlvbLNz5ZuykjwOlRCLGb; 25:yi9Uo4v0KqUsS5rUPOqx1WOorFZKhCH5bPn9ISK+ppcR+y6gSHwEcbJ2zB8IyJjMDeX2V9kmCL2hbgXWzgfhP3WBpQ9LTyR7t2CeM9WwOoy7d9BEzW00BJMrds+VHzEgQOvYpIXi/gFHhxEceXf3f8A9B6gwSlRTX0UUwPaVSV6xNKLlP7+tpNpQX03JNyJwBqHCyrWsqKfw/l89ZC+MMjO+3cJXC07t8DeaRg7nwuWkvY9o2NYYa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Prr/9PgRmp/MJsuFOQJ5oPZkimT4WaMdTy3DEspkETNuKy9v/0zSMbFxTRwLaeu7RYZ+wUJgLupqsbr4qGbju29hQhi+9/GPPt2EVqGp6nHO7ruQbmRvFsYGtuY4Wfv6450/WyK3RVW0pX9ofM35iV7rcROC/WyMYwzBpLSmjMjLFIVeip1dpU3ktuiTw== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(6029001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:84l4bnszt6gRIUX/rtwfAtFKjK65lIu//3HbSx39x?= =?us-ascii?Q?sP//4vyu0GgOZy0QZat7hhMJkN7ewpGb3IUBTriOhss9unfn43AOxJmkcO2w?= =?us-ascii?Q?Bt8532ymZprSAtpgUyxr8GaBceTn6ChtPHTMAsftPvf8hPKLgUi3Hh6DOFLx?= =?us-ascii?Q?lMkAHBYyteRnxX/1T2MykEHlxNRKjLAw6IvYLVKHfhary+KXsqDpbpDUxxqI?= =?us-ascii?Q?xIvWMdHqG6lqMBPsqwm56Zfcx4zlD6EAY6eaWd+T7/VtACHbDkcHM4Mx8FhR?= =?us-ascii?Q?HrPsK6jLXOcVwYuFV0VsMq0DU23J49Y6cgOkW9oJ1Jf43CRwzfVqMXhxPOD2?= =?us-ascii?Q?mVq30hJFvVRPw6YYaycX1re42/GQtqcKIjhMy1u1T/j+Ff0l48kYnx+sFb1N?= =?us-ascii?Q?qxucSh10UUYkszaE5ZY7FgUnemk9+qOHZUBf0zRkvbX5kyVzXk9O9lw8EAnb?= =?us-ascii?Q?qZ2dKbdpzAZJUfLf8fxZg2BsSF4I6ki+k+Wkkj8Tuna9G3aFzAiUhcAWSaqm?= =?us-ascii?Q?J4JUm4gXqDy5pRcKih9fHwOjuInNAmjr2qhSQ2tfRY2HG7idaLb6fT43spGG?= =?us-ascii?Q?Xfku+qQr2HjS1hsRHsCHjO83FhiLvu10fOl2vXHxxAc1PqzntRagxoZS6zAL?= =?us-ascii?Q?+w6nkrQ4CIYsiZKWb8zCeoy/XKdcEkQhWIIlqrcAolmUjum3p+CxqEA/Krtf?= =?us-ascii?Q?xXwslyH1HeSeD4OCZh1JVdV8IlA0tK4AVhHZ6pg84EILje9ODZmz3ghH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vyRanelJCwTNBCI1g==; 24:X+kOLT5vH1E2tAadWM8OP95IbfyKYcwwwuoZqLY8ijlWNgfRrw2cuW9uGh0l8PX2Hbp8VZKkZIvko19qaHBsnCY8UfyB4m8gF+8KnE7Tiyc=; 7:/8/oMeS45iexcbu9QXBp7MTRs/eqDumpmRXoPGZOlN7U+IEK3+22gbCQPTfywxk76RtM0n8MOt5o4vU/sMup920IzDqZ+mfHVlbJbcc2eR42/bgRmyz5b5h+TrstbxX6p8QKwRcjxnJWvvha/A9JOTQo9c7VTmC30yrY3BfaN7ddqYgnAGOgIXfTxtTmqLA2mK7uwaOap2OEF8qZ076Vk0gGFxvGPL3e0SsJYL5AVAM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:ewway70kjKUXJDWvvxk679pX5K7X9OdCw0CdNizK3nP1+nrTgyhOm4AXA87cBCPFxrHtSXceT8Q/gIxFNCYwdqZxDFyfhfZN5IjuPOHoLB+KLTK7/maW2FnGgB4k0S51U57uydvABHiho+jRgvitf+3S32jBNbxehoZEH3PgW+1WnndXJCUoM7L+i/HB6eVcvF+gXO+r+MBeYMcBVSfHVZbC0D2YnX9sFCHBSOSvJHgUtEq9QZsERzr4JV52zjIH X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:22:59.8572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 05/23] OvmfPkg/VirtioLib: add VirtioMapAllBytesInSharedBuffer() helper function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function can be used for mapping the system physical address to virtio device address using VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer (). The function helps with centralizing error handling, and it allows the caller to pass in constant or other evaluated expressions for NumberOfBytes. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Library/VirtioLib.h | 52 ++++++++++++ OvmfPkg/Library/VirtioLib/VirtioLib.c | 85 ++++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 5badfb32917f..9ec9b91b59bb 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -3,6 +3,7 @@ Declarations of utility functions used by virtio device drivers. =20 Copyright (C) 2012-2016, Red Hat, Inc. + Copyright (C) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -235,4 +236,55 @@ Virtio10WriteFeatures ( IN OUT UINT8 *DeviceStatus ); =20 +/** + Provides the virtio device address required to access system memory from= a + DMA bus master. + + The interface follows the same usage pattern as defined in UEFI spec 2.6 + (Section 13.2 PCI Root Bridge I/O Protocol) + + The VirtioMapAllBytesInSharedBuffer() is similar to VIRTIO_MAP_SHARED + with exception that NumberOfBytes is IN-only parameter. The function + maps all the bytes specified in NumberOfBytes param in one consecutive + range. + + @param[in] This The virtio device for which the mapping = is + requested. + + @param[in] Operation Indicates if the bus master is going to + read or write to system memory. + + @param[in] HostAddress The system memory address to map to shar= ed + buffer address. + + @param[in] NumberOfBytes Number of bytes to map. + + @param[out] DeviceAddress The resulting shared map address for the + bus master to access the hosts HostAddre= ss. + + @param[out] Mapping A resulting token to pass to + VIRTIO_UNMAP_SHARED. + + + @retval EFI_SUCCESS The NumberOfBytes is succesfully mapped. + @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a + common buffer. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to + a lack of resources. This includes the c= ase + when NumberOfBytes bytes cannot be mapped + in one consecutive range. + @retval EFI_DEVICE_ERROR The system hardware could not map the + requested address. +**/ +EFI_STATUS +EFIAPI +VirtioMapAllBytesInSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); #endif // _VIRTIO_LIB_H_ diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 845f206369a3..c85cd8dba569 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -4,6 +4,7 @@ =20 Copyright (C) 2012-2016, Red Hat, Inc. Portion of Copyright (C) 2013, ARM Ltd. + Copyright (C) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -414,3 +415,87 @@ Virtio10WriteFeatures ( =20 return Status; } + +/** + Provides the virtio device address required to access system memory from= a + DMA bus master. + + The interface follows the same usage pattern as defined in UEFI spec 2.6 + (Section 13.2 PCI Root Bridge I/O Protocol) + + The VirtioMapAllBytesInSharedBuffer() is similar to VIRTIO_MAP_SHARED + with exception that NumberOfBytes is IN-only parameter. The function + maps all the bytes specified in NumberOfBytes param in one consecutive + range. + + @param[in] This The virtio device for which the mapping = is + requested. + + @param[in] Operation Indicates if the bus master is going to + read or write to system memory. + + @param[in] HostAddress The system memory address to map to shar= ed + buffer address. + + @param[in] NumberOfBytes Number of bytes to map. + + @param[out] DeviceAddress The resulting shared map address for the + bus master to access the hosts HostAddre= ss. + + @param[out] Mapping A resulting token to pass to + VIRTIO_UNMAP_SHARED. + + + @retval EFI_SUCCESS The NumberOfBytes is succesfully mapped. + @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a + common buffer. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to + a lack of resources. This includes the c= ase + when NumberOfBytes bytes cannot be mapped + in one consecutive range. + @retval EFI_DEVICE_ERROR The system hardware could not map the + requested address. +**/ +EFI_STATUS +EFIAPI +VirtioMapAllBytesInSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VIRTIO_MAP_OPERATION Operation, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + EFI_STATUS Status; + VOID *MapInfo; + UINTN Size; + EFI_PHYSICAL_ADDRESS PhysicalAddress; + + Size =3D NumberOfBytes; + Status =3D VirtIo->MapSharedBuffer ( + VirtIo, + Operation, + HostAddress, + &Size, + &PhysicalAddress, + &MapInfo + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (Size < NumberOfBytes) { + goto Failed; + } + + *Mapping =3D MapInfo; + *DeviceAddress =3D PhysicalAddress; + + return EFI_SUCCESS; + +Failed: + VirtIo->UnmapSharedBuffer (VirtIo, MapInfo); + return EFI_OUT_OF_RESOURCES; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491010639415.469507982844; Wed, 23 Aug 2017 05:23:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DF7EB21E49BB6; Wed, 23 Aug 2017 05:20:33 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0052.outbound.protection.outlook.com [104.47.40.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A950421D2E647 for ; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:00 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TxjUmg4+uiyrlDmnqlyc33F5KgaPizNNL74yafc6vuc=; b=gqLppyp/vYpRWQTxoFa6eHLBzX5TPFWXF+lvdH+zU1NAYsIL52wCVFRJyj/xvzsX6xbOzrtV7KbH235ft9mmqD/ANVDFoOSMQwYbsu3rtiuQXSO3rhlMiRDK5OtiYoHVqQMDfgvXi3U9RSknot175LLdrDTzVl9kFbJhc+kyeNs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:30 -0400 Message-Id: <1503490967-5559-7-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab813dde-89a8-46a8-c472-08d4ea21b1df X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:s3DH0gwK9aKb03Ait0FXAo63YC+I5xHxtQzwBeeaH/Snv+7VhLztBqWRcXcjIfsI9F8BA+h7iJF82kqcz6zi5HJScfW2h4w/e9u2w/g0GankUxZTNJ8DG5A82iszUr6dyng6tDckH6gQi+s3g24Mx8GuQYPhZGVOaa4+sAny+5I5ZbSsR6hzoVwc2Bjr9Q8VhJRSQ98e6+ue8OK97qQ1XKiO+9WJj39U321Ek7hmvWLANSg6i6hbQqCbrVqXYw7u; 25:QlSvUaJo2KRTjO5CVTbZxhwHmyd8M53P8DIOs57WfW7/QZcJCWyITD6joI0Euk0ZbUKqG7hMqecCVbPxnCZ7P9jOo36x9K6cPchHm8h7kxs97jH6tmNLKk2G3+0KM8HzsflXvcufDwDW1vffDz8bl+gYyqVHEY6reShcoA3DJgBXF2OU6gYV6b9EC7CjGdTEDKMHQ9Wi+PqXSJZuEoevHvf66GmXmplyS2jKgd6+pmpV13y3VDkBkHmXIyxZGgx94SnNZYdikJXASrIg7OmEZPzcpuV4Njomn63gRKa3OG+BXXihReM/j7frDZEOWCJ4C0kSGpw12rQ4nptk1nGC5Q==; 31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ndaw2gM8arTPPzOng3RlGG1QEpwmSEBEtgFYC/srr0BWBht3VQqKH8Fpawf4conPnHsPtYnw/tXA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(51234002)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-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GN+z7GmpLTDZ/Fo+GrS+tOBKlWZE6E=; 7:2wEs1UxYbu3DuYJyStxpnH+mwWngkh83Zf0YLqX6pWHmV46NxoccKy/6zEQs0rLD0ibzjtKAxSZrKKg4x0iVszhjd1nGnwgAL0r2T7/Jc5vvP0FXhVVhcei+BqiAX+Dx2ddJdV6c6RnrYQmvNI84RqSE0oaYGOBBcDIZsa50iEYGP/qDYt4ygPV0cho/zc5yADry7jhpZQ88Zu4C4oItQr6ngtlDFBj5fAePIRAlk0o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:eoSL7TQju81yftvkultMkErKdscCtktpgyRygTLcokbnaRjyx5T4Qmw9lrQgSwO8jEpgSSvn8tg3OsOXYNqfln2wMaUG3IsD61Np1bsbG+Q2I4hMLxfT5tgoX2Xqf+blGBg8blrSV4i9xjQHQbvLOIy8DYG2tcDLcI47mgz2m0Rr8utXDpwvYcWgNpK6jtc9/gPVKLBsaoOdvlVvo+mHS+d4cZ7rADxjOpuJGfn7YdFhszaJ0Dg+QI3xaftBV+lf X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:00.3416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 06/23] OvmfPkg/VirtioLib: take VirtIo instance in VirtioRingInit/VirtioRingUninit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Passing the VirtIo protocol instance will allow the vring to use VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () to allocate vring buffer. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Reviewed-by: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/Include/Library/VirtioLib.h | 14 ++++++++++---- OvmfPkg/Library/VirtioLib/VirtioLib.c | 14 ++++++++++---- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 7 ++++--- OvmfPkg/VirtioGpuDxe/Commands.c | 7 ++++--- OvmfPkg/VirtioNetDxe/SnpInitialize.c | 9 +++++---- OvmfPkg/VirtioNetDxe/SnpShutdown.c | 5 +++-- OvmfPkg/VirtioRngDxe/VirtioRng.c | 7 ++++--- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 7 ++++--- 8 files changed, 44 insertions(+), 26 deletions(-) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 9ec9b91b59bb..40c51a2b3305 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -35,6 +35,8 @@ - 1.1 Virtqueues, - 2.3 Virtqueue Configuration. =20 + @param[in] VirtIo The virtio device which will use the ring. + @param[in] The number of descriptors to allocate for = the virtio ring, as requested by the host. =20 @@ -52,8 +54,9 @@ EFI_STATUS EFIAPI VirtioRingInit ( - IN UINT16 QueueSize, - OUT VRING *Ring + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINT16 QueueSize, + OUT VRING *Ring ); =20 =20 @@ -65,13 +68,16 @@ VirtioRingInit ( invoking this function: the VSTAT_DRIVER_OK bit must be clear in VhdrDeviceStatus. =20 - @param[out] Ring The virtio ring to clean up. + @param[in] VirtIo The virtio device which was using the ring. + + @param[out] Ring The virtio ring to clean up. =20 **/ VOID EFIAPI VirtioRingUninit ( - IN OUT VRING *Ring + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN OUT VRING *Ring ); =20 =20 diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index c85cd8dba569..8bc5b9aea4fc 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -37,6 +37,8 @@ - 1.1 Virtqueues, - 2.3 Virtqueue Configuration. =20 + @param[in] VirtIo The virtio device which will use the ring. + @param[in] The number of descriptors to allocate for = the virtio ring, as requested by the host. =20 @@ -54,8 +56,9 @@ EFI_STATUS EFIAPI VirtioRingInit ( - IN UINT16 QueueSize, - OUT VRING *Ring + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINT16 QueueSize, + OUT VRING *Ring ) { UINTN RingSize; @@ -128,13 +131,16 @@ VirtioRingInit ( invoking this function: the VSTAT_DRIVER_OK bit must be clear in VhdrDeviceStatus. =20 - @param[out] Ring The virtio ring to clean up. + @param[in] VirtIo The virtio device which was using the ring. + + @param[out] Ring The virtio ring to clean up. =20 **/ VOID EFIAPI VirtioRingUninit ( - IN OUT VRING *Ring + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN OUT VRING *Ring ) { FreePages (Ring->Base, Ring->NumPages); diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index 3ce72281c204..61b9cab4ff02 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -12,6 +12,7 @@ =20 Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -722,7 +723,7 @@ VirtioBlkInit ( goto Failed; } =20 - Status =3D VirtioRingInit (QueueSize, &Dev->Ring); + Status =3D VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring); if (EFI_ERROR (Status)) { goto Failed; } @@ -811,7 +812,7 @@ VirtioBlkInit ( return EFI_SUCCESS; =20 ReleaseQueue: - VirtioRingUninit (&Dev->Ring); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 Failed: // @@ -848,7 +849,7 @@ VirtioBlkUninit ( // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 - VirtioRingUninit (&Dev->Ring); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00); SetMem (&Dev->BlockIoMedia, sizeof Dev->BlockIoMedia, 0x00); diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Command= s.c index 962087cfec97..c2e4d72feb67 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -3,6 +3,7 @@ VirtIo GPU initialization, and commands (primitives) for the GPU device. =20 Copyright (C) 2016, Red Hat, Inc. + Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -127,7 +128,7 @@ VirtioGpuInit ( // // [...] population of virtqueues [...] // - Status =3D VirtioRingInit (QueueSize, &VgpuDev->Ring); + Status =3D VirtioRingInit (VgpuDev->VirtIo, QueueSize, &VgpuDev->Ring); if (EFI_ERROR (Status)) { goto Failed; } @@ -148,7 +149,7 @@ VirtioGpuInit ( return EFI_SUCCESS; =20 ReleaseQueue: - VirtioRingUninit (&VgpuDev->Ring); + VirtioRingUninit (VgpuDev->VirtIo, &VgpuDev->Ring); =20 Failed: // @@ -183,7 +184,7 @@ VirtioGpuUninit ( // configuration. // VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, 0); - VirtioRingUninit (&VgpuDev->Ring); + VirtioRingUninit (VgpuDev->VirtIo, &VgpuDev->Ring); } =20 /** diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 430670a980f2..6d9b81a9f939 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -5,6 +5,7 @@ =20 Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -73,7 +74,7 @@ VirtioNetInitRing ( if (QueueSize < 2) { return EFI_UNSUPPORTED; } - Status =3D VirtioRingInit (QueueSize, Ring); + Status =3D VirtioRingInit (Dev->VirtIo, QueueSize, Ring); if (EFI_ERROR (Status)) { return Status; } @@ -103,7 +104,7 @@ VirtioNetInitRing ( return EFI_SUCCESS; =20 ReleaseQueue: - VirtioRingUninit (Ring); + VirtioRingUninit (Dev->VirtIo, Ring); =20 return Status; } @@ -509,10 +510,10 @@ AbortDevice: Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 ReleaseTxRing: - VirtioRingUninit (&Dev->TxRing); + VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); =20 ReleaseRxRing: - VirtioRingUninit (&Dev->RxRing); + VirtioRingUninit (Dev->VirtIo, &Dev->RxRing); =20 DeviceFailed: // diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpS= hutdown.c index 01409c0ce714..5e84191fbbdd 100644 --- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c +++ b/OvmfPkg/VirtioNetDxe/SnpShutdown.c @@ -4,6 +4,7 @@ =20 Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -66,8 +67,8 @@ VirtioNetShutdown ( Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); VirtioNetShutdownRx (Dev); VirtioNetShutdownTx (Dev); - VirtioRingUninit (&Dev->TxRing); - VirtioRingUninit (&Dev->RxRing); + VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); + VirtioRingUninit (Dev->VirtIo, &Dev->RxRing); =20 Dev->Snm.State =3D EfiSimpleNetworkStarted; Status =3D EFI_SUCCESS; diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/Virtio= Rng.c index 1a186d04082a..e20602ac7225 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -6,6 +6,7 @@ =20 Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This driver: =20 @@ -275,7 +276,7 @@ VirtioRngInit ( goto Failed; } =20 - Status =3D VirtioRingInit (QueueSize, &Dev->Ring); + Status =3D VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring); if (EFI_ERROR (Status)) { goto Failed; } @@ -331,7 +332,7 @@ VirtioRngInit ( return EFI_SUCCESS; =20 ReleaseQueue: - VirtioRingUninit (&Dev->Ring); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 Failed: // @@ -358,7 +359,7 @@ VirtioRngUninit ( // the old comms area. // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - VirtioRingUninit (&Dev->Ring); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); } =20 // diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index c080404330e5..c2f6f412ff40 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -27,6 +27,7 @@ =20 Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -832,7 +833,7 @@ VirtioScsiInit ( goto Failed; } =20 - Status =3D VirtioRingInit (QueueSize, &Dev->Ring); + Status =3D VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring); if (EFI_ERROR (Status)) { goto Failed; } @@ -926,7 +927,7 @@ VirtioScsiInit ( return EFI_SUCCESS; =20 ReleaseQueue: - VirtioRingUninit (&Dev->Ring); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 Failed: // @@ -964,7 +965,7 @@ VirtioScsiUninit ( Dev->MaxLun =3D 0; Dev->MaxSectors =3D 0; =20 - VirtioRingUninit (&Dev->Ring); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00); SetMem (&Dev->PassThruMode, sizeof Dev->PassThruMode, 0x00); --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491005424503.2917949030398; Wed, 23 Aug 2017 05:23:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9FEB621E49BB0; Wed, 23 Aug 2017 05:20:33 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0052.outbound.protection.outlook.com [104.47.40.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 81EC921D2E63C for ; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:00 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=3xVfYAsNQZXPwFsXP+QSkwK/DrAdHCxPMydDLhDKi9s=; b=poPTljZURRxFsPd4BPb/nCKyTJvLseZwRBfenUVxavjUUu5n4piRJLzQGtsnyE9Oa0Hi0puyXTzdDQ7B3R8H8o91d81Y43KlPMLenTcRUIGjo6Oz3yvyhpoIl2W84SmmZzhyd6hqWO/nHGFv5JmJNmzjjhE8NYAh45z28zDXHm4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:31 -0400 Message-Id: <1503490967-5559-8-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f103822-c6bc-4142-0f98-08d4ea21b22c X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:F3PPqLeKJzdhSKfyM3UDdIWvnSTk0Ai4e+X/OQl83V5O78XK3EzP3tIzvgIV/DCWGB6ItoMyJxomm7lC4cxwIrKV8zkvxauPLI44JX+X54yttr3XN1xkWNE0T22YnCerT7Uozqgv6QUvD3Ej7f0YyDaFmZrGwXQxM/NKQbYO9L5aTgWenP0IXC0cPeWzFdbEh9Yk0F3BNtadIc88uHaFl6lldam1otCwgPSctgqQR8MUatxHYRFn7+fjVU9p/wct; 25:+e89CijOpgiGMcFxPUoAAXzodYqh/Ju7+C0nJm8fxOtpHnETGcaq/QH/wflsPUizWpfuseNSeNsI9XfjZEQkjSTOnZoUXaJNMhws/o/NUITxi/XA+rfoaHzB2RgkkUOApST8nD8aftiwhGJwjDG/Sz5AIr+HVxmtKAGwXrk0vQN+A0oHs1Mp2zs3ihpr+jpHJ0X8b0sOSnEwVUrw+y+DQG+AUwm8Irg0cUyYsdM4TVxywRvmlhB2BNG2Vf/BXHDPPkfcxKtxnyBdmQ6lGLI1c5nBfJ65mQml2vhNZHZ2YZArUAL2GDPn7HwIrtNkDq0CdvFMsaSJ5oI9ZMrsm3ho/w==; 31:CHMRK3Nl8VThdNcJ0xXWp/lx9pLf/FP9xBk+cf8fAp4FrlbLhVs6oYIk6GZA6BG6Ov+0ykCUqGaCSLB1se0jL/T6gl6Q0xo8jA4ofhP7KW5qls5wX7NQLg012sOrhaEwXBT02C8C00JrOLyf94Jcq0h/Sl3+sNKlw3VoVpJD5r06H2c/XuE869UTO4bCkbrUpwkdj/2g1kBXVGbVUB+vr4kCEcvvcnplkrzS+zhjDY8= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:jiqSQXGJNmmI46AcTorUipLRXQtYp0E5D0RmpGi4Y4BOHxNB+91osWEXcVr1M/PG8djVsI8xC4kX+hbwWmyKE4FtWxZUDaUX+p0qBYb/ziOjIxEtcQ59tX07xOsfw3hgA3nYzhSd/DQqOws5QgfUmb2dO3dJ+/8Nme47DeDuwqERTp3XElX4F95w9uSDUfxPUCmneVb9Wp3fRkYA31CVScwMqi9nk14xilA0QhxOeovjH+dRbNxRnVyXxOT698outJu/AjuwmyOqUa4nO0V05v9P78JrAGsd6w2DNzzIhrUER4DaQVJXaqv1n5k6gGAgFD5CyCeoLT3Xhk1HlwuPsphzwTWetvENoYxw97YAK0Fj1jnpVRQpH4obEuG2G6rOQRxkYbz9+Z/AHTKWCMotvG9QsXNwulB/wHatHQCe1inFpz1MCsoTfWD6q/X8GvcHF5fdRN4/8CkYDsF83gtE5JGQPX5ZYs0Riyu2N30ayTmxnk+dtruZ0/h6cbydr+MR; 4:PATscXVJ0I0pvrNLNDy23rbAFQ8i1vDTG0yLaA2SX8O0DlpB82KYMJlkZOp8UH3wfMfAawT6NyNBBGrDyvc5ltqsv/VYctgjRVWimy6SeXiNvbqBJPX5JRch/F/daJ1zqujFHWsbKCh0M/Ukqr3kNufBgBHLDU8JuoXE/Hu/oyNy7NC3PBQ7VKqEj32fSdA5wStkdigJ0hixwMCuHsLt/yCHxPTdxGA2I2NPpsVMkpcm2zLJo9E69JN34zRoc7F9eNQqpH44vo49unwPyiHpTFW+cb/9O2ji88+CVhoT/V1sse2mvWgHni0gIMBt/gW6QsAG47yDWz8M/etQc9HpqA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(979002)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001)(19627235001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:QcMeC1Hfy+0SMvnEi/TX5eF2e3KCRdeixe0Dzf5MO?= =?us-ascii?Q?S/f9tz5LQ7Jm2kR8APKInemBJ42nEwEYhx8tw0aPd4oYFgMI0j21T0AxXonQ?= =?us-asc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cKc+ACBT4HSFq0w0qiqsB+0enhZB+xwKhuoaIfanDMaMHGRBJW+XRVug+gNeqK+DU06OFlxhZh3qGdMOPsdioPxEGyLPVp6zl2RfHVYtjKoiLF/6XQZkbfpqvrYpbgm2+OxVV6LqSUYgDGm7WRBkU2j80tJ9W9tqTPCPm/Lac4M9KJdMrYCZBsVdSlqry1ZNJUBqILooKw14yrkVpQif5JhykmFgX8DQEvRP6gF48g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:oZyg1vR6tq3W6Icu2SxNYdSKl+EChxXDhYa7ykp3f9vh8yFpvKzg21IMXzn/C/6+rbd+8IfOqi8zYaVwZE2TxxULiVt8zwPw/XYs6qNVXcWCwTQs9qBjDtDmweqwuNkr6Ocui2ULeHaY9VdteakxkET8Iz2b4Q93WdV6cYnFbpEzBk4Y7zLOmJ15kIZtDKkx7bht54hMP90WzslQeTNllH/jNKezf5lSivCfQ0NX/zuzcCak8XsSJ1tLOFLSC+rh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:00.8416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 07/23] OvmfPkg/Virtio: take RingBaseShift in SetQueueAddress() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For the case when an IOMMU is used for translating system physical addresses to DMA bus master addresses, the transport-independent virtio device drivers will be required to map their VRING areas to bus addresses with VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() calls. VirtioRingMap() maps the ring buffer system physical to a bus address. When an IOMMU is used for translating the address then bus address can start at a different offset from the system physical address. - MMIO and legacy virtio transport do not support IOMMU to translate the addresses hence RingBaseShift will always be set to zero. - modern virtio transport supports IOMMU to translate the address, in next patch we will update the Virtio10Dxe to use RingBaseShift offset. Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Protocol/VirtioDevice.h | 19 +++++= ++++++++++++-- OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h | 3 ++- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h | 3 ++- OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c | 5 ++++- OvmfPkg/Virtio10Dxe/Virtio10.c | 5 ++++- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 2 +- OvmfPkg/VirtioGpuDxe/Commands.c | 6 +++++- OvmfPkg/VirtioNetDxe/SnpInitialize.c | 2 +- OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c | 5 ++++- OvmfPkg/VirtioRngDxe/VirtioRng.c | 2 +- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 2 +- 11 files changed, 42 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/Include/Protocol/VirtioDevice.h b/OvmfPkg/Include/Prot= ocol/VirtioDevice.h index 9a01932958a2..2e3a6d6edf04 100644 --- a/OvmfPkg/Include/Protocol/VirtioDevice.h +++ b/OvmfPkg/Include/Protocol/VirtioDevice.h @@ -156,7 +156,21 @@ EFI_STATUS @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL =20 @param[in] Ring The initialized VRING object to take the - addresses from. + addresses from. The caller is responsible for + ensuring that on input, all Ring->NumPages p= ages, + starting at Ring->Base, have been successful= ly + mapped with a single call to + This->MapSharedBuffer() for CommonBuffer bus + master operation.. + + @param[in] RingBaseShift Adding this value using UINT64 arithmetic to= the + addresses found in Ring translates them from + system memory to bus addresses. The caller s= hall + calculate RingBaseShift as + (DeviceAddress - (UINT64)(UINTN)HostAddress), + where DeviceAddress and HostAddress (i.e., + Ring->Base) were output and input parameters= of + This->MapSharedBuffer(), respectively. =20 @retval EFI_SUCCESS The data was written successfully. @retval EFI_UNSUPPORTED The underlying IO device doesn't support the @@ -166,7 +180,8 @@ typedef EFI_STATUS (EFIAPI *VIRTIO_SET_QUEUE_ADDRESS) ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring + IN VRING *Ring, + IN UINT64 RingBaseShift ); =20 /** diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfP= kg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h index e5881d537f09..e6279159f8ba 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h @@ -115,7 +115,8 @@ VirtioMmioSetQueueSel ( EFI_STATUS VirtioMmioSetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring + IN VRING *Ring, + IN UINT64 RingBaseShift ); =20 EFI_STATUS diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioP= ciDeviceDxe/VirtioPciDevice.h index 41df5a98e560..1f0dc45d501e 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h @@ -126,7 +126,8 @@ EFI_STATUS EFIAPI VirtioPciSetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring + IN VRING *Ring, + IN UINT64 RingBaseShift ); =20 EFI_STATUS diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.= c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c index 644ec65e1788..67458e56231b 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c @@ -181,11 +181,14 @@ VirtioMmioSetQueueSel ( EFI_STATUS VirtioMmioSetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring + IN VRING *Ring, + IN UINT64 RingBaseShift ) { VIRTIO_MMIO_DEVICE *Device; =20 + ASSERT (RingBaseShift =3D=3D 0); + Device =3D VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); =20 VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN, diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c index 89ccac8c1c04..ef9a00710668 100644 --- a/OvmfPkg/Virtio10Dxe/Virtio10.c +++ b/OvmfPkg/Virtio10Dxe/Virtio10.c @@ -489,7 +489,8 @@ EFI_STATUS EFIAPI Virtio10SetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring + IN VRING *Ring, + IN UINT64 RingBaseShift ) { VIRTIO_1_0_DEV *Dev; @@ -497,6 +498,8 @@ Virtio10SetQueueAddress ( UINT64 Address; UINT16 Enable; =20 + ASSERT (RingBaseShift =3D=3D 0); + Dev =3D VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); =20 Address =3D (UINTN)Ring->Desc; diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index 61b9cab4ff02..bff15fe3add1 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -745,7 +745,7 @@ VirtioBlkInit ( // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring); + Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); if (EFI_ERROR (Status)) { goto ReleaseQueue; } diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Command= s.c index c2e4d72feb67..5cb003161207 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -132,7 +132,11 @@ VirtioGpuInit ( if (EFI_ERROR (Status)) { goto Failed; } - Status =3D VgpuDev->VirtIo->SetQueueAddress (VgpuDev->VirtIo, &VgpuDev->= Ring); + Status =3D VgpuDev->VirtIo->SetQueueAddress ( + VgpuDev->VirtIo, + &VgpuDev->Ring, + 0 + ); if (EFI_ERROR (Status)) { goto ReleaseQueue; } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 6d9b81a9f939..0ecfe044a977 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -96,7 +96,7 @@ VirtioNetInitRing ( // // step 4c -- report GPFN (guest-physical frame number) of queue // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, Ring); + Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, Ring, 0); if (EFI_ERROR (Status)) { goto ReleaseQueue; } diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c b/OvmfPkg/Virt= ioPciDeviceDxe/VirtioPciFunctions.c index bd912cca9b29..b52060d13d97 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c @@ -183,11 +183,14 @@ EFI_STATUS EFIAPI VirtioPciSetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring + IN VRING *Ring, + IN UINT64 RingBaseShift ) { VIRTIO_PCI_DEVICE *Dev; =20 + ASSERT (RingBaseShift =3D=3D 0); + Dev =3D VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); =20 return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (U= INT32), diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/Virtio= Rng.c index e20602ac7225..0abca488e6cd 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -298,7 +298,7 @@ VirtioRngInit ( // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring); + Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); if (EFI_ERROR (Status)) { goto ReleaseQueue; } diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index c2f6f412ff40..a983b3df7b9c 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -855,7 +855,7 @@ VirtioScsiInit ( // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring); + Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); if (EFI_ERROR (Status)) { goto ReleaseQueue; } --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491012272447.3469554963258; Wed, 23 Aug 2017 05:23:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 24FC221E49BBC; Wed, 23 Aug 2017 05:20:34 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0052.outbound.protection.outlook.com [104.47.40.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CD99921D2E652 for ; Wed, 23 Aug 2017 05:20:28 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:01 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=D40x+5qW6PXsjHQ/ZZW/gzpQ9FiCu8Bd/oNcktmA3fQ=; b=r6rPL9HUPH8k46/6ohjtrva0qx0ULDBVhPSZsARlo/ugXAea/5wjsZeBH5Ps2ygqQWxQpC5YJBJgF/XwnBilLnQeKZSXC0v51nam27KElw4XTuN8OWKkWjBp0/EOx6XrzS9trH0+Jt29DqGJQ08CO2N7gNwxtPfzWkSU3nUpRS0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:32 -0400 Message-Id: <1503490967-5559-9-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35610fa7-7aff-4666-bd09-08d4ea21b27a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:SIXJCJo1NF8c4Dgi2bgSPYSJ+A9rKvus57a2GGXl6xCp7cMvTo7id+/FCdbea+HA/Ynz+MDUwfjBS7LFaFhDlA2hOoSOvgMVX8C3r3QY8hce08R04W84FfrU/lXxLCGUgEk9EIBaBimQ5oLXpj9dGT4RjEOChBs5bCIjCD/+9jAXKTSfn2Db29rhZ5O9GcsSzjcak91MtN3e7YT0zHrS9Mc/ERa5sxNOI/tla0N/uX8s7M+V1+6XywFMLeZ2LiDH; 25:WXF5j9qHeHTtrpTXHrEoca7Xm1h484XWjKwZSPjUuI7uIkbU363SVQkaFE+MSfqzIbkBuT/qJa62xds6LrmVzqxO2vtZrD7C159iXa7Z7K2j+gfG8XBhBy0HddWVxZnmyNZcYuEcIjW4aIuUnxoc0AhqjVKRVehYH+phnLcWs9Bq7m7gwqmczjCCwIKHIzHwI2cjMXpVA47Ja2FapDqlTXOFQyD5bKXZd5MmZYrYBPlKWxESLFeG7JU4Dg82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9Zd/TY+xCZDzbuhm2MfTwZduRHehdcje8CXJVsoxZ0DrQWCku1bHiM2g72J/sPrLmVG1w5KdpPiRIwYDxDbtRJOOab00KtEnyCGUTqATK42tqdmvD9VVafxiQk/lGmM38EWvnTkF2VdtrlQqWAMZPK8q53UlZezw9nV2CVKWMpTrAoys0xFg== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:gE+Xo0NBYMm/F7Hb3ZLnQD5qbu+M13+Vpuy1sVCXN?= =?us-ascii?Q?PmXB5KXseeAQ3G3ClWJ+a0vIDd2VLTInaQdo/2a7XwG3ki/qAcdaC0l/zPmj?= =?us-ascii?Q?spZercfJ8pkhDJpItI+pxenkxv6l66KOEJHlOYRkVGbA/9Eofx9S8LOcZEf2?= =?us-ascii?Q?Lu3RkWZyjVlH4gesJR/ET1COmuP7arYb5fGNoaAvWwkZ7WIJrTeIbwn8hJtC?= =?us-ascii?Q?DpPgjp146pXE+gmxqVwtrCvEzghEiq0k+VnGLsPhjO6IuX4Jf26aiP7fVe90?= =?us-ascii?Q?znGQ8/bllYLcLyPV2GXbP0n6tNJpUGYfCX65zh3c5d30a2+75MCjsXEHagVv?= =?us-ascii?Q?StN9uFzHpwjm+45kQ/TCOLtwhpwN7SIJ7lDs6MPNM97D1DNjQkOv6ambCTeH?= =?us-ascii?Q?s0yxvKYY2GmTv6l+RxVZ+71DRZqs6F4vHfOiS4Jkmp4EbtbnVG9K/yLmwWVM?= =?us-ascii?Q?Ev+zNLYSQPX6FojQ/AsRWyl2YEGknWiu2BFAPI9Tuiq4/iiUsyhosE2BE9o8?= =?us-ascii?Q?M2KU8Be0UnVeHL5NKI/0RupNkZ1ldObvC286gR0XZuySnPYj0lJlo2yWtM+P?= =?us-ascii?Q?kQKLhoSitIp8CbLWZ7IawA4dLrDdVSHwd8NlGlUzs9+t0/59YrpluB21fQa4?= =?us-ascii?Q?Oz52vNflx1ulieyv8mn2mFFRcQK+a4nrfhP651gY9Kk2uuOcXiUc12Kya+K1?= =?us-ascii?Q?RvXvv1vGkvenIKAqeVfM00rLVCCKh5Iz/hC0mA9XnnkfDcZldGh5QGcnhfRl?= =?us-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:PNFF5xC6Ra2F4dlc9FLqWRB97qNsBbFeawBuibvNzbsi5+nvbFPEfb/6x84uWlUUuq1RWYdcXejSOCqtKWo2H1f4rnlGgrgLrGg5H3xqFjM=; 7:lCtwd+cFuXqhklBZGn817IZ4IOZls1Y62FusigVgimGiWHvMEz7FHZCo+K/HB1ZbNvrmSHlU9dhaAGEnFZhJkY9fGYapY8WnfZvqlVl5W8WlnvKQcepYzaJvmGAxwNYl7uXkZ6k2kfnA3h4F9oqDI1Y3LJIWK0ba99pccLttGutuyp92iprQOxmKpsUgK56tGgCveGtrzKTcCFSvcYOktKgd3qRjgy/KaHo5jy/E/Ao= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:ZLFheW3XyPmzCgkwvFTLy0QmZjH9UqJ4MPO9B3/0W7i24ZO0RhR8DazCPdBqqafgp7w4kWPWM7S/dpWg1z0W404yv0e8uLRUzzTlSfIn41tNDY81UE9HPlsC9+xCwveCzs7aEx+kXFPtqn8d26A+a7g3Oe6efYHWtK2/pe/Q91rpH/WWfWxMRsHxr2ivCvMc1KMlS2gwUH3BTmocAIFVmgIp5KgNW+MpJ3vNY9xYYbP7HiJSY7ovYDcLbPNgbIuW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:01.3572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 08/23] OvmfPkg/Virtio10Dxe: add the RingBaseShift offset X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" virtio drivers use VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() to map the ring buffer host address to a device address. If an IOMMU is present then RingBaseShift contains the offset from the host address. Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Virtio10Dxe/Virtio10.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c index ef9a00710668..e9b50b6e437b 100644 --- a/OvmfPkg/Virtio10Dxe/Virtio10.c +++ b/OvmfPkg/Virtio10Dxe/Virtio10.c @@ -498,11 +498,10 @@ Virtio10SetQueueAddress ( UINT64 Address; UINT16 Enable; =20 - ASSERT (RingBaseShift =3D=3D 0); - Dev =3D VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); =20 Address =3D (UINTN)Ring->Desc; + Address +=3D RingBaseShift; Status =3D Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueDesc), sizeof Address, &Address); @@ -511,6 +510,7 @@ Virtio10SetQueueAddress ( } =20 Address =3D (UINTN)Ring->Avail.Flags; + Address +=3D RingBaseShift; Status =3D Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueAvail), sizeof Address, &Address); @@ -519,6 +519,7 @@ Virtio10SetQueueAddress ( } =20 Address =3D (UINTN)Ring->Used.Flags; + Address +=3D RingBaseShift; Status =3D Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueUsed), sizeof Address, &Address); --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491016187927.9246344334318; Wed, 23 Aug 2017 05:23:36 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5E16B21E49BCC; Wed, 23 Aug 2017 05:20:34 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0052.outbound.protection.outlook.com [104.47.40.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 288F921E2DA79 for ; Wed, 23 Aug 2017 05:20:29 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:01 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lSAJzIDlPd7vYdeWubLSeHrNkbqvOpnB36BjzvfCtsk=; b=A/ed+dCQjjtMQnRaIGiTdF/PnAW0ZWT3IoSDTHR7WmL89QepQpc/heyogSiS9YjVmLCYK4jzzOoD2HfWxPclud95wES8ejF7wKdohuqF8nUV7rs1As+QGGg/B254RSSYIvFNZhvsuAG/54e9joHMw4uzDc///YbTJ/4eBnOIOwQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:33 -0400 Message-Id: <1503490967-5559-10-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc60da18-7af3-4c7b-082a-08d4ea21b2c7 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:c/Jsc9swzOhSGKTbIlbC+VQhU1nDmkzHhIDVn2ZPiEpMbnpS3QIehZCsgRbg3ctoGrZL7y3MUGcK5V4ErcH+Cy/yEe1FgkEU85YS3j0NwrIbwP8wlCXBeEZXJGBNrk7o2Bi+HGfuo7r5SSrPcryBWAPVB9sQep/VtHTt/2MrkRHRgt6JfWO34AOjXj7YKr1TJKGFLthZot+KLDGf65mpIbo+lu/C95Qer/YObtqH2qR66tAjh8L3+GB5okUs8nLK; 25:Q4st03uPS8DHaJVkGrMiIKDpggOgqv9d0nb2Hn6goCX/b0e6lvvI2j7c5K7Ba2Zh/WY0zY6KnL3Xt/ytobLW2JFC9Ruw1zVH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bE; 4:yz0NeRkX5gDRekYzeFcaA5Ua3oRyBLuyisAl/dpLnWBt2O0JN+tK2UtlmxETFMh4uIJgj0sSbBdvhAU9Gcppkiox1Km4K3momotLQggNshvWLKy2SwgmdNEuOTk1IhkfpI8qZSknL1X9KQqSMuq9PFsyQv7UjyFOXHsf2OkVOGNb98DbOSbq3EUoV/3rxcFOJBd5MRUNfGROr2MraIfNMB59VlAvAyad7dRobclpQBZrwvMYamcoqpuYuBDe+WmBGXmzf0MkuSCEhys6PuUVQUK0x1DvP+m+ZsDCHIesqTV2eU71ajchOddw+hC0eSExwrEL0oj377nB7WOKzUFNyQ== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:enune6F294V3VgY+LE4dcdWBgGWkPmhZ1UUbPHbqS?= =?us-ascii?Q?RckbH8xt4F3b6G0Rys5n5qIh7ojrlLXPNQUfb92pBprb9k9+tp5Y4TdKPndT?= =?us-ascii?Q?cGCa0mDMjZ96Im6u8FwCe0amZYLF71O86vQOnKri0BVbsPzMUxN2LwqQ0Au7?= =?us-ascii?Q?Sc0n0Ml1+imRoYn9bb+31kxFXwhP/va5FBmiitlgUhZ5wNiQpeZtLaU96fWS?= =?us-ascii?Q?rgx0xRVLW3iJc5Up3Z4ZkNrU34F4Ms9DVcozdC3EUzPhmk8aJnE0Wh67ntuT?= =?us-ascii?Q?4dbjNwWP0R0sIxmbXpMN6fD69ozOTLoPhxMXEun6CKFxpeEifUlzTpnnrye4?= =?us-ascii?Q?zOIRIRUjbH1YUmBaFuFlr3xxQuWeHN0NrGJbDoCKcfKmOffSq6JulHVq17LW?= =?us-ascii?Q?nxhR64T60TxAztXs7VPExXkQcDl5tYw8wd7DD1Gn39TPMa+K4IZ2L60aIQec?= =?us-ascii?Q?qXx4yu7FK65eoiVeOC+GGslQM/0ePyjn3e2D3H9JpG3DCnYIdEjxgNq/O9dc?= =?us-ascii?Q?Xe/Wnlo3nkYYI81RDgPBwHt/k/jB5yqSg7tiuoXe1R1FFr7InKJ87n8sWGqd?= =?us-ascii?Q?kB8pNUIduXQbPLqH3OsEcRQYIghnwQkecGcEpwjc84UKHBeUn2GxcxPw7am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==; 5:xy3M3AvFNsolitPLc2LSQzkh28DzfrilmsEmpKjCx7VN2behGrB6RtCHocaMvJ6mY8eEB57IHrEZaGHfSvBdIeQWbWB5Ws/cMg0mJnzqcz/Ofwh3XYrVoK4wwwgD4piXG2wUX23qe9wOkozdY8wLIw==; 24:i7/nKIzNQ5OsFjVlUwFKmBFViqNHy4pC7CFSVv6kwJeguK5RkoVKK/ZCcKKWeAT24ie4VhrWEHzoNpQfRUq2bH/XhXl0dtOLQQ9Mx7cfRF8=; 7:HkbqShYetftkln1EZjGu/eBhq58zRTOyyz9cmMMOFpPm2QrRVjYUm9Ad2BK24MKONfiFKLIYcTOQl77sNzzkpq+wctQEvJTfflqXjCJLtSqSVVng8q3QufXOzj7R6cHnoLv8hDEjSPcB41VHRqaTab8DYJqFBMAgtSikeW9+RkYmdjOI8NGK6E3Wsr6OYFT7WSvQ65Kuye6ZaJEwveMLa/k35An3r1O7/ideYDDpkmQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:fTGCvX4KZ57A0ejBDI5isfJTG8WWtWV/Tm5lxVXsve37EP+guf+xdhCORCP+6puIyz9BuX6mYeQKOLPqMqqCl6x4RCleoplaCPIjyVI+BjcVabtOdVUUpJsteV41Qy9eLFazYpPXw+6zFgTfYnW16KX0fBsvJzXExnyhmrVzp04zipow0XRD3IoMyCmmXFkUy+WzYGr5wnv16q9AUmO09PNjFMSYNiUdbPNOu0KkSdbYX827n5vExx3IB+luHgvs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:01.8416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 09/23] OvmfPkg/VirtioLib: add function to map VRING X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add functions to map the ring buffer with BusMasterCommonBuffer so that ring can be accessed by both guest and hypervisor. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Library/VirtioLib.h | 26 +++++++++++ OvmfPkg/Library/VirtioLib/VirtioLib.c | 45 ++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 40c51a2b3305..3d9314b3acaf 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -62,6 +62,32 @@ VirtioRingInit ( =20 /** =20 + Map the ring buffer so that it can be accessed equally by both guest + and hypervisor. + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to map. + + @param[out] RingBaseShift A resulting translation offset, to be + passed to VirtIo->SetQueueAddress(). + + @param[out] Mapping A resulting token to pass to + VirtIo->UnmapSharedBuffer(). + + @return Status code from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT UINT64 *RingBaseShift, + OUT VOID **Mapping + ); + +/** + Tear down the internal resources of a configured virtio ring. =20 The caller is responsible to stop the host from using this ring before diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 8bc5b9aea4fc..535635ac0ba8 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -505,3 +505,48 @@ Failed: VirtIo->UnmapSharedBuffer (VirtIo, MapInfo); return EFI_OUT_OF_RESOURCES; } + +/** + + Map the ring buffer so that it can be accessed equally by both guest + and hypervisor. + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to map. + + @param[out] RingBaseShift A resulting translation offset, to be + passed to VirtIo->SetQueueAddress(). + + @param[out] Mapping A resulting token to pass to + VirtIo->UnmapSharedBuffer(). + + @return Status code from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT UINT64 *RingBaseShift, + OUT VOID **Mapping + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS DeviceAddress; + + Status =3D VirtioMapAllBytesInSharedBuffer ( + VirtIo, + VirtioOperationBusMasterCommonBuffer, + Ring->Base, + EFI_PAGES_TO_SIZE (Ring->NumPages), + &DeviceAddress, + Mapping + ); + if (EFI_ERROR (Status)) { + return Status; + } + + *RingBaseShift =3D DeviceAddress - (UINT64)(UINTN)Ring->Base; + return EFI_SUCCESS; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491022111729.8379605142958; Wed, 23 Aug 2017 05:23:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 975BB21E49BDF; Wed, 23 Aug 2017 05:20:34 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0074.outbound.protection.outlook.com [104.47.40.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B0E4121E49BA5 for ; Wed, 23 Aug 2017 05:20:29 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:02 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=iwOu1K3btjVl5MAaXz4VaRHQpKTu0utFRkKAajcvezE=; b=Lp5HvhhZ5b0597iqVbV5ntawG9OsAc5DjoIe37NwJiROzjjm/6YvsfpH1/WB9uC8ADI6olCm4OkvPZFfPDsprszajSy/AcPXOVXHj7lnOG6eCHjVWHvLlijffzhEU+k0+txMfpb0pgqkLvN3PNawId9OJ5ivZCx4u5aBLEXrLuI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:34 -0400 Message-Id: <1503490967-5559-11-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 09a27489-ebb5-4003-8e98-08d4ea21b30e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:mg6Qv5dU5a0id5anjknUfbQbLE10+gdNxL6c/kFw1Ikfbm8hrS+8eVAlMudmW8ZuzZ8XvQTSfEgSmiO4AmG0zG+h1sLuCU0Dq4vz6Qup6C3rTkEneEfgwkNb7hi/YLU/pwuJOI5GFHA3t13JaIrro2cWjwompYsRPq56BxnZYIw5boXMOOpKq8I2xRrFAP2YBbgnHHGi/VpYLA6sZjqUXq8NEQfmke9uOVy+owONXAPNExt/B8N3JPwBxcQmEZaX; 25:G+YJLcnj+1aW5ibJyAZW4YcgMxi8UNwtJnzcRjpsifMpOaZdNpRgEbZ4vUCpytFNlKaG6fyByStcj42mGG8B1SNz840stebj9LrkRpvjAQY13k+KXPPRa1AY9i9P07RKBJEMyQDfo+T/vx9aPKGgYlaaK87GhlADhRaw9g3JUW6pp8dgiclqeSczNuthETWKXkUWKAS+hu/TsapGqMlcY+LbDW9MMHSiAEiKfZZocnzH9DRru5rewsFr09iB9iBA/O6ywq68ncnlnW3aUelUN8YxyYsdwDAKcvh4PNKMBz5ssNqTgAMtjIG1/EVpMgub0XsdmfGz13f6F7bZ/Ceg4Q==; 31:hR2mQ+xzpgZPMMgiL6lrid8ZgrhMdgFoJTBujmfAZav5+ZF9z3L9HbShKref1EC2bAvC5Rm4qdZ6dGa8IQUA/suXwImFUlFS0t4+rPfJ1KDROyV2vKNfcwbpyOOHCmMwDi//MsH+u6xPjcYPtWwNfARQCXriT6DDhEu+RWqCHS/7pOK67fVGgu3HyCTPUDtxh8XaL2mqMJ7ryfMyLyBZzbGpvdS0E4tOVndRxV931Jk= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:KFjXzPkn+TE5/TQGFv1okS6q7+3vpFI8Qn6OT01D2V1RnbZqY1QWecXAjHeKE+BB83dPWnbyPYTe2A3y995JruvVO7NA2x44j+vm7+36GY7DqU1c7Ku4edLk1rZ7XwXFTYS7/btZ+QRUiyziY8iAAo4W+i39bIt8TS5EXM9vcnOBxacOAGmEAh/qMc5gggwOj+KevsWeab93oIatx4pyHyPtb1Rc3sfSkHUD5hOWfB3Gl8TchGUXcfcfmxuTDmJDgIYt91q/BU4p2uzfw4BhOUJ/0R4KvS3e1s8Td+8TPtw7CJ7zPgR2o58GnlrYJoox2+6gM2LFAimOO9Wd37gUnYTwCU7qGqL8p/fLGeFBJuzEvIm9eWaXAcsN/D0Gu/wNM66uIGxAYCMUdGWHlGkm5EOHM9fmbf9g5s9CS1jbD5aF9QEgcalialeb+Zf46fpkMHWOWiSR18yLObb4FWjJ7NUoD2D01V//Rfr+yf4sArMMQyAAbgL7dL+7Z3OHJXiq; 4:TbwzX1Q2tdY9oLUHTg5yUaGyL9YpOQjeTU6hOC8qnNi6Rore1R4Zs8d042LYOQbt9uTtHNLHqq7tZY2IUrbHMfAaB/J+3v7Bkk6oXgSkpS1EKt3lx2WhP181eUEe6tuhpExVlTQ5NATfBiGwbVeSGCIEosxVEz0i0U3bVusYbFa4vfJpp7IbfkvSfZ8wF/JIriG0TYRhgy7CnOUgyJFBD6NgoXbQC37kKrDIiGtVJ01BvBkTGnY7BnaLwedcswLdOr7hedR6xM10ds7i4/Z4Ih44CQ1vgTO7or3L/GnVHt/Q8lwFZo/q6ll3FTtLW7jHz65H7naj/3l9tYYvVpY5gA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:4DRwioHH9dOW+RPsYjbEejAyovITtpLJWYKEXL0UN?= =?us-ascii?Q?4kQeG6QYDQtK1f5280A2DsPx+4WfcYh3I08l7Og9QwanSaG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eGP8cIRFPZH2E/VhZThvsU/bUGE7g4QLYHpSmHu57Mwynv6dx81RkVCI9BZGPC2lgTsBzf5zhOn+OsIC6ecz7nSs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:OuHKJsqgrPukvhQXe3Q9RJwBLBKvhs4IrsKNLwIbr29WHfcbIth3x5cfgemwhVgERJN5INMAIPlX3gxi2U1vkInnMPyqdVCSeVtAcrnIqIBzrCb7qqYR7aoZ+6KzkTPBt68JzlMsMqosn38PRRRnxFaXrWAEJZx+VHC+zWCmsZIVzEITJ5vHWMmebIY28DdnANI/fQSMaq8qmap51V7oPNo8D8/Ff0KNLH2Vqk4V9u6DQf8Ds3/u4km2XHlyJ6bs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:02.3259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 10/23] OvmfPkg/VirtioLib: alloc VRING buffer with AllocateSharedPages() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The VRING buffer is a communication area between guest and hypervisor. Allocate it using VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages() so that it can be mapped later with VirtioRingMap() for bi-directional access. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/VirtioLib/VirtioLib.inf | 1 - OvmfPkg/Include/Library/VirtioLib.h | 5 ++--- OvmfPkg/Library/VirtioLib/VirtioLib.c | 22 +++++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.inf b/OvmfPkg/Library/Virt= ioLib/VirtioLib.inf index fb5897a88ecf..e33856de38c4 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.inf +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.inf @@ -32,5 +32,4 @@ [LibraryClasses] BaseLib BaseMemoryLib DebugLib - MemoryAllocationLib UefiBootServicesTableLib diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 3d9314b3acaf..c3e56ea23b89 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -42,9 +42,8 @@ =20 @param[out] Ring The virtio ring to set up. =20 - @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contigu= ous - pages for the requested QueueSize. Fields = of - Ring have indeterminate value. + @retval Status codes propagated from + VirtIo->AllocateSharedPages(). =20 @retval EFI_SUCCESS Allocation and setup successful. Ring->Base (and nothing else) is responsible for diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 535635ac0ba8..e5366e385f5d 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -19,7 +19,6 @@ #include #include #include -#include #include =20 #include @@ -44,9 +43,8 @@ =20 @param[out] Ring The virtio ring to set up. =20 - @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contigu= ous - pages for the requested QueueSize. Fields = of - Ring have indeterminate value. + @retval Status codes propagated from + VirtIo->AllocateSharedPages(). =20 @retval EFI_SUCCESS Allocation and setup successful. Ring->Base (and nothing else) is responsible for @@ -61,6 +59,7 @@ VirtioRingInit ( OUT VRING *Ring ) { + EFI_STATUS Status; UINTN RingSize; volatile UINT8 *RingPagesPtr; =20 @@ -79,10 +78,17 @@ VirtioRingInit ( sizeof *Ring->Used.AvailEvent, EFI_PAGE_SIZE); =20 + // + // Allocate a shared ring buffer + // Ring->NumPages =3D EFI_SIZE_TO_PAGES (RingSize); - Ring->Base =3D AllocatePages (Ring->NumPages); - if (Ring->Base =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D VirtIo->AllocateSharedPages ( + VirtIo, + Ring->NumPages, + &Ring->Base + ); + if (EFI_ERROR (Status)) { + return Status; } SetMem (Ring->Base, RingSize, 0x00); RingPagesPtr =3D Ring->Base; @@ -143,7 +149,7 @@ VirtioRingUninit ( IN OUT VRING *Ring ) { - FreePages (Ring->Base, Ring->NumPages); + VirtIo->FreeSharedPages (VirtIo, Ring->NumPages, Ring->Base); SetMem (Ring, sizeof *Ring, 0x00); } =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491023920243.1751712493533; Wed, 23 Aug 2017 05:23:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D099421E7901B; Wed, 23 Aug 2017 05:20:34 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0085.outbound.protection.outlook.com [104.47.40.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F1F6221E49BA5 for ; Wed, 23 Aug 2017 05:20:30 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:02 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=phTsufAqtqJAqJH5Yy0QHPEuG/3962+bzhtaL4v2trg=; b=n7dXO3TqSgxEN0lboVBJ2y+32Nyf2nBqaxqk1WrTFdCORNZ6PiPb3jWIwu+V7NTxs3lu8qZynmaedDQH0YtiAHnrV9g1+nPzoKOeKl3h+l76uEnSCOB4Uya0X0kqRIwcsdGwIFBzky7RYWH3nYJyRkfj2qnrr38q4dHvvrRpqAY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:35 -0400 Message-Id: <1503490967-5559-12-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce6124df-b681-445d-79ed-08d4ea21b358 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:XhDWj9LcSeVQG7gPMb/sthV5gXBwm0kTwxLtLFDyxkNW/ZgOAkVOLRvCDqt5rBOJA7KNJeikjRESijQsg+v990C3fxpkNbpCG68UJyope6OIKdOxYPUO12IhhLVtxv9bJjS6tL4krhfnrbKYnbWhN3zASZfmjoibq25XdYTC1eLhpNPenRODDZxk9pGb3n0S7n/GrRi/HpoRWF14UdiovUut9yhQnzRqU/cg74jgKqpDs7KYK9ZIEP/mfQWXyGdR; 25:I9+4sjHW/0S+ms/nVNrj1juZAz50TvH8kknYiEsjwAMhIQ/g+dHyk+VoVpjtVLEBPnjOwASlmklN9WjC8pYhGL+hpaGlfXQfKaXVqTFMknWnBIlG3R2fiQv7w1Xwsv+sj28LRWJ3lFyCfuhwyOSyCqMdrjhw1ANgnKoInKAdrYeUFxcKN45HEWqfkYefM32751Rov43vwz5/SnVAjb9pami5+/onCx+X449ObhtwCelmZre6NnfKjHfhV+YW8w4VgQIXvhc6/dTED5nfHaMBBS38WEFLoZkAjNpnrqeaDvuqY92GwZQT5+3Olt8cV5xwHe1gnZtKLUqxdXjyfLs0sw==; 31:TiVv42dp3grxkF7FKUnaasd7rEvUhYJsYrL+iZEvv5r5k9tcfOkbcB8D6wb0myC9I18kAyY3mEEHhmIl8bQjRi+SmajZVQjT8cHnvnuseAgB80vScpBshbKspcuWgD5W0Bbr5yBRpmy3NocrpvBM3Kn+P/WeIYoHuA4dUkRFESoupK+gufBZyFPnWtBPSISTatyn87IZhhG4NgB7Sb/3nB518sXfpO7NGJvFgvIcnAU= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:KNoXjcTe3iMcrNw7ADxjJ6qE1ijoMNNHjvWqfLc16v8maIle18Ew5B+enq5kZr0bJSicv38OPDNj8u2PVqqhyltvp4y0PKYToWYhAzTK4arl5CclVBaBm6i1nFgaB2IrPrwTDoGF3uvlNE1IgAxfow/AxVZXPcLjtkhwvyAXMXBG4kPiptfiDBodgir+slUxsZ4q5YwO1PwGeMu9ZLNOewFZuexIuYHzN4BC0p78NEJKgy7vCNv2sr5kJZfEEJB9VMXg4Qa4n22gJ9A84WC+qHfsUVTkFDlOdvpXuCcoZZQg6mf+GKczn+gN4SoRLDUU7oB+mUHbd8EL34LNAv6ltrCJZ/sFoWxGxINQFP93Y5ybLrh71wpMai5sNrTxzkjum3tUDCwivr0nluqfpfQAkmf/x2WcsUvLDyI2NtAnaMuSWf5WjzW0QTFRzBruJBRjLFkHgXEotW2MpwviKomjqbEihJABQqy0AJW6xTxG6d9qNbmqGqa2MUYp5WCkMKwh; 4:bNO3EDAlGsaCpLqy2W4T7Vw/PLRZywfHgA9pbhbtX0l80nQdLvUUkuDvji/AlmJ1hj3tboTAiO6sUb93Yxy1F7PFviJZ++0RvuxUYP7zkRUOPLVJH/HZBgDNAdKP+BmjCIkUH/+NIKT3Hj5PXG/ssZDcQUWJBpPd+IC0+P0KHnbS4uGVyQkNQzsXx9YYDiNOIx7aJK3uuElP9/r9wJlnOfcWjZI5GYyO8ZmOLiOSyHRmL7qjbUdd38kEg6Xu3M1i7ppidVcIgu/jVcNqGSC7fOGbqHBAWnbgcbQsIjvTSeHbFI+Q77yFPZb+ycpREZC/I67lhLU+WQ/lY8S3fqt5hQ== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:PcDHf8vkjQYyTlSuUT1jPI/7PKqE5zZHGsXOwSrLS?= =?us-ascii?Q?+Q+DjRob63T198SuUqhMLj+JSyDHuMMpcWRwq2ZnwMgsScRH2vcK3wRi2O6O?= =?us-ascii?Q?mkDFzB6duVcyf2KmbrZKT9GqAGAj/+n3NVcha4o+0HV2tMV+9BeTvdn2GONI?= =?us-ascii?Q?GKtJaqr6joVGemvLC8vu7xaIw2uA0PdgyzAkGvxW2NSxOs6ljqukQJuG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Jpq5xwuXH+iVE5kmR0hIeM8y+OwFI?= =?us-ascii?Q?0OJ0q2tRz4kxrblcq6tmumYXxUZP5qM?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 6:NQCfzaYm2ytnFOsrSw2P6B+sSNH8mL3lu/rkg4pwuC8lKUjNaJshgcmFjRX7FgvZh1cNgjAKpLqzKPIsFo/Z7yBZFg2BtdaAQPeK711PiBmzKGPni8UVDeuE8paldrRtoE8DpseX9KpJYKyeuY1Uf608m7AH0CaZOx444uCdTh0sPkxrjNao16MtZuScE7DR27teIz9eBRDiIp5a57JtrwWpsDW+A3JBB3rk9ia2lXXbGCfcF7YL/ieK2K/x1pmcvjbRm1ZMsAL/oRiIa2IDayzMFxnCQOgVYJaOQMioD0haShMUAiPw17IQTTOcyNSD1gfI0SFIekj6KpB1GXUPFg==; 5:0GO/vDsYnCYOVCzlCMoIcjhC78DQs7RLW1YLNmbM/dvHDcaVJsEZEm8O9C+J19RZcNYAVXOMmEPYH0onOyuUPLwpH1VHK7xz+efvx4mi4W4y9yCmmC/EPPMLJI3WGSyIU1gywHPFWEkjxV+osadymA==; 24:7f4CmZMSaaJSAqcMTfdoYirwu3fU4Ss0iKXGJKoonnyPSykxhd0aVbpPyRqPm1WrFI7+FkMEh6WGdGvQLU57GvvrXegxjhBXsuGeRNjCZN0=; 7:Mr3dGecfTFQp7mcQxoyNu9ilw5YyFJDh59EXjK2v/uJBU+HLLa6u3Jdmhriij0BBZz5cotl20+2Wqhv2ABlmibv1e3ps8YzgnbB84QiBe0QnX035uGvH7d4II0lgaZHSB6svacd4MJWNVTcENTF979p481jXi2xcrBYdGl8TxBRt86ATNipkYpYAqzDVz5UrljyQVrJKUesgxfZ3ata0YXs6Cm1fGSqdfHwgfUPngaw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:qYlpldu4Mh1dsrNZ1vDJ6xZAJFMA1l2TgQZtCiyoiOqze5eWzrg63cDoWY2eEzWJks2BdOh42TxgVNxCFEc69Idnu6dJFeHxpz6SJo71IIdtH3twNRPBARZ5KikOV+PZjLLn7BcZd69/aN2LxseDnj1jtLBOWP2au2TL2kI39WNRkcwEzvZfYqbVJyiEaYN/3pq+QfwpmyyK4B+kjrNLhj7VVwYl/HRTtoICynfWxmVqkpBW+yv6HXkiSUIfh36o X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:02.7947 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 11/23] OvmfPkg/VirtioLib: change the parameter of VirtioAppendDesc() to UINT64 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch change the "BufferPhysAddr" parameter of VirtioAppendDesc() from type UINTN to UINT64. UINTN is appropriate as long as we pass system memory references. After the introduction of this feature, that's no longer the case in general. Should we implement "real" IOMMU support at some point, UINTN could break in 32-bit builds of OVMF. Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Library/VirtioLib.h | 35 +++++++++--------- OvmfPkg/Library/VirtioLib/VirtioLib.c | 38 ++++++++++---------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index c3e56ea23b89..a966311ac941 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -151,33 +151,34 @@ VirtioPrepare ( The caller is responsible for initializing *Indices with VirtioPrepare() first. =20 - @param[in,out] Ring The virtio ring to append the buffer to, as a - descriptor. + @param[in,out] Ring The virtio ring to append the buffer t= o, + as a descriptor. =20 - @param[in] BufferPhysAddr (Guest pseudo-physical) start address of the - transmit / receive buffer. + @param[in] BufferDeviceAddress (Bus master device)) start address of = the + transmit / receive buffer. =20 - @param[in] BufferSize Number of bytes to transmit or receive. + @param[in] BufferSize Number of bytes to transmit or receive. =20 - @param[in] Flags A bitmask of VRING_DESC_F_* flags. The caller - computes this mask dependent on further buffe= rs to - append and transfer direction. - VRING_DESC_F_INDIRECT is unsupported. The - VRING_DESC.Next field is always set, but the = host - only interprets it dependent on VRING_DESC_F_= NEXT. + @param[in] Flags A bitmask of VRING_DESC_F_* flags. The + caller computes this mask dependent on + further buffers to append and transfer + direction. VRING_DESC_F_INDIRECT is + unsupported. The VRING_DESC.Next field= is + always set, but the host only interpre= ts + it dependent on VRING_DESC_F_NEXT. =20 - @param[in,out] Indices Indices->HeadDescIdx is not accessed. - On input, Indices->NextDescIdx identifies the= next - descriptor to carry the buffer. On output, - Indices->NextDescIdx is incremented by one, m= odulo - 2^16. + @param[in,out] Indices Indices->HeadDescIdx is not accessed. + On input, Indices->NextDescIdx identif= ies + the next descriptor to carry the buffe= r. + On output, Indices->NextDescIdx is + incremented by one, modulo 2^16. =20 **/ VOID EFIAPI VirtioAppendDesc ( IN OUT VRING *Ring, - IN UINTN BufferPhysAddr, + IN UINT64 BufferDeviceAddress, IN UINT32 BufferSize, IN UINT16 Flags, IN OUT DESC_INDICES *Indices diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index e5366e385f5d..fcd484fffada 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -189,7 +189,6 @@ VirtioPrepare ( Indices->NextDescIdx =3D Indices->HeadDescIdx; } =20 - /** =20 Append a contiguous buffer for transmission / reception via the virtio r= ing. @@ -205,33 +204,34 @@ VirtioPrepare ( The caller is responsible for initializing *Indices with VirtioPrepare() first. =20 - @param[in,out] Ring The virtio ring to append the buffer to, as a - descriptor. + @param[in,out] Ring The virtio ring to append the buffer t= o, + as a descriptor. =20 - @param[in] BufferPhysAddr (Guest pseudo-physical) start address of the - transmit / receive buffer. + @param[in] BufferDeviceAddress (Bus master device)) start address of = the + transmit / receive buffer. =20 - @param[in] BufferSize Number of bytes to transmit or receive. + @param[in] BufferSize Number of bytes to transmit or receive. =20 - @param[in] Flags A bitmask of VRING_DESC_F_* flags. The caller - computes this mask dependent on further buffe= rs to - append and transfer direction. - VRING_DESC_F_INDIRECT is unsupported. The - VRING_DESC.Next field is always set, but the = host - only interprets it dependent on VRING_DESC_F_= NEXT. + @param[in] Flags A bitmask of VRING_DESC_F_* flags. The + caller computes this mask dependent on + further buffers to append and transfer + direction. VRING_DESC_F_INDIRECT is + unsupported. The VRING_DESC.Next field= is + always set, but the host only interpre= ts + it dependent on VRING_DESC_F_NEXT. =20 - @param[in,out] Indices Indices->HeadDescIdx is not accessed. - On input, Indices->NextDescIdx identifies the= next - descriptor to carry the buffer. On output, - Indices->NextDescIdx is incremented by one, m= odulo - 2^16. + @param[in,out] Indices Indices->HeadDescIdx is not accessed. + On input, Indices->NextDescIdx identif= ies + the next descriptor to carry the buffe= r. + On output, Indices->NextDescIdx is + incremented by one, modulo 2^16. =20 **/ VOID EFIAPI VirtioAppendDesc ( IN OUT VRING *Ring, - IN UINTN BufferPhysAddr, + IN UINT64 BufferDeviceAddress, IN UINT32 BufferSize, IN UINT16 Flags, IN OUT DESC_INDICES *Indices @@ -240,7 +240,7 @@ VirtioAppendDesc ( volatile VRING_DESC *Desc; =20 Desc =3D &Ring->Desc[Indices->NextDescIdx++ % Ring->QueueSize]; - Desc->Addr =3D BufferPhysAddr; + Desc->Addr =3D BufferDeviceAddress; Desc->Len =3D BufferSize; Desc->Flags =3D Flags; Desc->Next =3D Indices->NextDescIdx % Ring->QueueSize; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491027661548.8369695924148; Wed, 23 Aug 2017 05:23:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1508621E79030; Wed, 23 Aug 2017 05:20:35 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0085.outbound.protection.outlook.com [104.47.40.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2286121E49BA6 for ; Wed, 23 Aug 2017 05:20:31 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:03 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=HLFMKmf89s/SpGaTuABk4HPrnnoX5td1vOHd5QYXM6k=; b=eEUu40mCSVm0tjyqBE+8exWMRBmr+BoYrZd8vXNjTzjvjums2pKsSZAjRk7duOYYLLJRHnCZ00rgT/RAGGiGw11EHuBo5SS+wZBGmEe1rgh0r1OEuX8PWj2/vR+QAxOVaoVq5nBtAvCS7LuF0c/UK7zs2VG6NUqz44Do7As0xj8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:36 -0400 Message-Id: <1503490967-5559-13-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74cdf765-5002-47e3-fdd1-08d4ea21b39f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:DCM1qbeiw0HHiUxYEpTsQaCqqMeff9e6/Q6G127QfowtF1iXmtjE6CqKBQFSWfMDBXk17s6GM/ryTLpNflr1DVZ9EhefCsXTeUU5Eomgbg6GVp1nrGU8C+8sPDCQJb2vuOEbKd2nYsh0yXvuw4ul1TLuUmdQ+9OvijUrNPUPcBilW1ChOwk5xJ1ew6G6bYAKUXu6yIXCFN5WOyZ/ZcN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4pegItwqYHzU+Gcm/7NNFiBSX6M+4eqgK+BNu7KO+AZucKPEgIOMo29cW6C4C9Duio7cZXTp3+2Lg5ryyWegKxjsEABi3NPH10pPFh7ma7KjP0buiDAZjCK7l8OuwSuWjxof2P2p7Ngx; 4:bu0/xfghBk4F5Pjd/m0FAghKIJ7ZEoxp8u17X6z8yFYClc55SB0eafv21BjUDHE7Le0YQnirKQw7QaKNUzFezdYOl0B+hSChN2eMlPxm7YnFXwmv3WhbDbzR0oSDMzzmCGJb4owcKZAt+4CQeJU6Wb2GfDdIVasEoEp+GHLWUs3POZXC3ADCrv4l6Zp7xfA3pqW4GiCXWX7pDu/hmU4/IdW4HL3XhS3iPU35ROWP2qMEcICTrZ/B1Nprf4PkfvpfH1pAS6rAdqNfj8SulXno7ksWdg7lv3JLljysjJ9exTzqZuMUDrA8Lv5niCmHEfD48/Dz5HJKXPaBg+nWi7YCJQ== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(51234002)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:SklKJEHCmjrLrk/J0j8zeyCdpguH/ytMMVlUCr2fN?= =?us-ascii?Q?Z5HzBDHzmGhPHQFRMOJ6fAFabIMn2UkGogGXunldHMBCLsSWKxP8duSxtAY5?= =?us-ascii?Q?hx2Zuj6J0EVEjlZiHkqLOqOdDyZUCxkIdz/O1MGJvY+YZ1dgRgoTOzNKQAUT?= =?us-ascii?Q?1FSstUp8PByyV4DV6UgAnePf+N2nxTzYUI00qAUUWNsPznyViEUi3DpU4N1J?= =?us-ascii?Q?GKX7Ykna46FD/PaUW2CNI6rMU8v7jIMWf9cNPe7iCeTCLGkXN9qee9f5y40S?= =?us-ascii?Q?zjqqBPio+Bh9KL5gwJhAl/wS3F5Qh3IduujGi7LscMj/a/ls8i0nepfl65m8?= =?us-ascii?Q?fbEpngjy+nmr7H8+dTDyJydrVlRfKS5Wq1T3FQfWoezBOFDqPVT534DY5xMu?= =?us-ascii?Q?loYMLXhOuVFladEE7QxjWlxarf87qJnE4BN88kRVEQWd2mo+bEIKJKEfsVNQ?= =?us-ascii?Q?+VFlr1TocoXSTC21wGPU3M6ZJ/C1iJPatGmxCh61OoaaPSSx8Y5JtT85SYPX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B6G7IANk6K9CHRlVjMUL61EodqxiIT2D0bQJfFXya2ATnFRq3D7BMURUrr6xf/AjvTbaFSuM08oMe+UEtueNlBdDK81q7ylHmDrwlj5lP61fWk6sdRRotVrdagZQDICQrC+G5bdeuZkGWze9jdSOaIPa3EQ==; 5:8xKZAZfOd5kxjxXRDqSlrh2PPmKgE1fAIs0bOGdKRb8ArrRMH9aOxYgKkLrUF81LRPTytJLY6WskGta8CrEcHt8QutYbPnoTMkLz9gCv8P77Cvk224mBwiFXx6peQgGNIsXbIStpTB0CCkHxVjZw5g==; 24:ZJ1TPN21hBiEFLohCTDnT1ZIffLu97h6APLurqhEoVTdP8UInL2NEfANGjKTIFZBR3cNgsOlNRvhQ+ag22EZ4tZl6jTXfmoAXO9WBCxazbw=; 7:nER3DNerwjyTIVeWjDV+SxFqZ6rc+IJNqaDYyuC82XBPYLmOlUtd7yr81LGuHr7YULHA2R7sID4ZCKOwUu9gebPE7CdbnqzTys9KzSMBVWnkLxoLX/3P1h4H1dBQSJb/J44dQsSV9MiVM3YLllgUNw1zJ/5xeiU7jJpH81SjdqVWhIsW94pfJwtZ5np6ZlEgL4mCFpy955MP6Bkuwc5gGNfYk/5n6I2JuGGWNnROqmc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:Eny1Vsz33PEj5hDLcdMkF2q+TtNG7sod0M4inYi3ttvUniV76N7va1Lh9eICXr7CHXRrZSP/4wda4nv+27oxIJCFhNL1saC6CWeDLHrmcxP1HlWxWZz9noaJHGavSE4veIgg21ECQYoFGkXmgw1pGlN58NiyIjad1QsS+Lk+5xwS2c9ehESMy0jSkuCtNm69d4doJ76dpFNuTqL7SNvHN/XoBpiQN56MAf7ETGZfbEOu6wv5a8m/YvMsLoggLWvW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:03.2634 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 12/23] OvmfPkg/VirtioRngDxe: map host address to device address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" patch maps the host address to a device address for buffers (including rings, device specifc request and response pointed by vring descriptor, and any further memory reference by those request and response). Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/VirtioRngDxe/VirtioRng.h | 1 + OvmfPkg/VirtioRngDxe/VirtioRng.c | 82 +++++++++++++++++--- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.h b/OvmfPkg/VirtioRngDxe/Virtio= Rng.h index 998f9fae48c2..389c8ddc8d31 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.h +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.h @@ -38,6 +38,7 @@ typedef struct { EFI_EVENT ExitBoot; // DriverBindingStart 0 VRING Ring; // VirtioRingInit 2 EFI_RNG_PROTOCOL Rng; // VirtioRngInit 1 + VOID *RingMap; // VirtioRingMap 2 } VIRTIO_RNG_DEV; =20 #define VIRTIO_ENTROPY_SOURCE_FROM_RNG(RngPointer) \ diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/Virtio= Rng.c index 0abca488e6cd..59f32d343179 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -140,6 +140,8 @@ VirtioRngGetRNG ( UINT32 Len; UINT32 BufferSize; EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS DeviceAddress; + VOID *Mapping; =20 if (This =3D=3D NULL || RNGValueLength =3D=3D 0 || RNGValue =3D=3D NULL)= { return EFI_INVALID_PARAMETER; @@ -159,6 +161,20 @@ VirtioRngGetRNG ( } =20 Dev =3D VIRTIO_ENTROPY_SOURCE_FROM_RNG (This); + // + // Map Buffer's system phyiscal address to device address + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterWrite, + (VOID *)Buffer, + RNGValueLength, + &DeviceAddress, + &Mapping + ); + if (EFI_ERROR (Status)) { + goto FreeBuffer; + } =20 // // The Virtio RNG device may return less data than we asked it to, and c= an @@ -170,7 +186,7 @@ VirtioRngGetRNG ( =20 VirtioPrepare (&Dev->Ring, &Indices); VirtioAppendDesc (&Dev->Ring, - (UINTN)Buffer + Index, + DeviceAddress + Index, BufferSize, VRING_DESC_F_WRITE, &Indices); @@ -178,17 +194,35 @@ VirtioRngGetRNG ( if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, &Len) !=3D EFI_SUCCESS) { Status =3D EFI_DEVICE_ERROR; - goto FreeBuffer; + goto UnmapBuffer; } ASSERT (Len > 0); ASSERT (Len <=3D BufferSize); } =20 + // + // Unmap the device buffer before accessing it. + // + Status =3D Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Mapping); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto FreeBuffer; + } + for (Index =3D 0; Index < RNGValueLength; Index++) { RNGValue[Index] =3D Buffer[Index]; } Status =3D EFI_SUCCESS; =20 +UnmapBuffer: + // + // If we are reached here due to the error then unmap the buffer otherwi= se + // the buffer is already unmapped after VirtioFlush(). + // + if (EFI_ERROR (Status)) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Mapping); + } + FreeBuffer: FreePool ((VOID *)Buffer); return Status; @@ -205,6 +239,7 @@ VirtioRngInit ( EFI_STATUS Status; UINT16 QueueSize; UINT64 Features; + UINT64 RingBaseShift; =20 // // Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence. @@ -282,25 +317,42 @@ VirtioRngInit ( } =20 // + // If anything fails from here on, we must release the ring resources. + // + Status =3D VirtioRingMap ( + Dev->VirtIo, + &Dev->Ring, + &RingBaseShift, + &Dev->RingMap + ); + if (EFI_ERROR (Status)) { + goto ReleaseQueue; + } + + // // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resour= ces. + // size. If anything fails from here on, we must unmap the ring resource= s. // Status =3D Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 Status =3D Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); + Status =3D Dev->VirtIo->SetQueueAddress ( + Dev->VirtIo, + &Dev->Ring, + RingBaseShift + ); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -310,7 +362,7 @@ VirtioRngInit ( Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } } =20 @@ -320,7 +372,7 @@ VirtioRngInit ( NextDevStat |=3D VSTAT_DRIVER_OK; Status =3D Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -331,6 +383,9 @@ VirtioRngInit ( =20 return EFI_SUCCESS; =20 +UnmapQueue: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); + ReleaseQueue: VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 @@ -359,6 +414,9 @@ VirtioRngUninit ( // the old comms area. // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); } =20 @@ -385,6 +443,12 @@ VirtioRngExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // Unmap the ring buffer so that hypervisor will not be able to get read= able + // data after device reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491031666832.7960038136471; Wed, 23 Aug 2017 05:23:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 496C421E7903B; Wed, 23 Aug 2017 05:20:35 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0085.outbound.protection.outlook.com [104.47.40.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 457F521E49BA5 for ; Wed, 23 Aug 2017 05:20:31 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:03 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gKTaD4odvk7hMu8Yj+XReAgk88UGJSVVp9N09Vh5Zzc=; b=mfCrhWk88RiOuro01UP6I9eOYIFvHQFdJgUjjuLwpie/0GlzaOx2PHUI5bFJLy5Z9NQejVX/c+kTltbiQ8+auKqEbHWN85JLf1oDygqIjQ3S+e4eU/reBrZZba9K5vuiYbZdp+pgFX6YXezpfx3SJhb2WKheTdH226KsjPeRVV8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:37 -0400 Message-Id: <1503490967-5559-14-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ccf496de-0b08-45d6-1129-08d4ea21b3f1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:981w4ilpq4pbd9DxVO2EFzIV8CCIDgTXIqLTh0lep1BFgXhs27LEslAnL/bxMwEVaGEm7kZIcwBHCZZeJjXq2GlAEZ2cRIt+ybx2cz+kAWJL+6vIwxHUoiGYQZSywOVxnb3Ot2JKNww8oJd8eZ2nlGkwCUIA/AQNOgGQ+5kHAqOY5EyVc0lpf0BOfoyd6y2E0fSnqtGYB2PfAHpPWuGFwl9YjGfO66/0YKwTwp3VxmbtAJ4EQkT8ZuHVulsS3E6X; 25:uS9U2gFqGup8dF4FMdq5DBd6WFeXXNArCfWnmeS304uRIF2P7T+CgL9RdDBNMAh8lbfGxyHqqOfpKxHEyPX3gc7qUi4dvi14mbBYbt/106G3Jz/QWRlTRUtIdvr1D/P5j5hn48g27kfSKLXVEN+rjcRiqgzwLyqQpdDUBJq3sschMXZKIxShdeHB5R0JB2Nl3bW0SjK4I0e4XGgcr+zD16SEzvCWV9qNvMNJC5vSpZfF5ttxrgLwfCQvhqj6WZRNysDZeJP+q0YTzYZ/yOQTuikH1+NK1rmjvpRbNanyckIBpsBdYvpgQzzu4xw8FqdM2gW0KuC3wti+rAxSNFRltw==; 31:jF8OprMQvCf7ETSjWkisCicKVS8m40lX8bhB2oBZBNuw791t4WcrJRMT1UVklKCB4kbQ6qO+o9BoibfTBsd7W7kRUsPvr5InDMuvHWwbyO11qKzEXZPxIIVt8+QTBsdaLEVdZ3XyvHCFf1fX8wOowXNT4ta45O/5YCrkVlp8zqbI/+ToCxvPXIueOS2j19ujC/GG4vIO0GCWMg3a3vknEMIpPokTY5+f1XRH4s5i15w= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:EzcE1H69rbNQbDfrBuIe994U4vfNvb827KEvGm9hVvFVNZUYrukeWwR7+hh+xnnTKhIFwutXBhHEjGs2vMF8Cgezjyb7uPeO7c/DMfYlOokNXUOSWmQFxE64MunZOgvpLAB0PAAd3iClNB+pUri/rsKgxokYPVjt8Yh5y9KLJ7/GAjhUDlRbuzUZSOR3OxfRUM4abxfZjQy4B08ScukLIZauf2GsZRtyWTQqiSvjeCwd7UD7moAj4Tp6vYDMxZPaxU7Yqko0ilkGgTW6yttedzFZc7Ox/gwTwCAHTPrIXUKK+IgThCuwYC1z80N5wzpgt466wlqRRAEFhZycwNdw4/8JOuA3NHrOUr8ikJglN+oae0wXzPHTritBb9/Lj3cR5avXiCwwbBouVYimtQ2EPx3nQhWtV9FraRl09wb+X1NmENWlbvP87bSKcW3LaQVBpJm41yGZ0D2JutW0Lya81DTjronzxr4X6FSNaG5p3IXXmajPL6D4I7SIJUiAseFj; 4:OKOHnFFm8ZwrUEe0dXr5VnQEyu0FIUkM77BivkDGPaATDki85jlTVjB8l4fVTpMLbiwOlyvNrf53llo5CBjnIKiFH8UGFj8vak8a8qrDr2NotFVGy9nzcKzRSt/WB7iYzc/tpMERyqFShbPmW7gxf94GD4iSslUMJRSoj5vbKvCHUBYunJm0NMKj1TWHWkC8njHRxk+4+ZoY7bgnr5e+sN1fJPXuQWjpBO1yrvwfMI4E1lEh1XQmNygOXZcq3hsQB1y6AZA62Daxxp8jd6Ixp2baOVecL9ZFAm15P/1dKateqM/wkPLr3XZKzj17buhM1IQ1VqKZ+mwY2hW6KqCQtSOaXR6FsIFXfuuWwESaf9I= X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699)(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(51234002)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:IBJkKbUgcNdUCVnbyqfURpypG77X97bx4usUkK8fE?= =?us-ascii?Q?4EPqVBhKPoQe0/BAWD1pcDb8Fx8L8P77K3ndHer0gRRluEUWoQA+PWDfXxQr?= =?us-ascii?Q?9GEeoRMrWiMpiJkIC9d8Uy/38Q1dpbnqQAr6dBRx/kq+CdXXiZ+2zDAwZQVc?= =?us-ascii?Q?5xjn599/LutDyHgsrXhSvXl/2c8UQOOvwcLFxH1c1ZlWl3YRrgg1+14MGqe3?= =?us-ascii?Q?8hRN2KZShU1JtKrV4G0DVskLX9cWLRsQKZ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E+viFDzMkMlM3kHr12vGLEIB+9PoG4fb2j3newnWCi3?= =?us-ascii?Q?jhnW39rBxQmlpXcyqZXh6GtQuJcOESkKmXB?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 6:6tBxXM9aLVQChxYZPJfV1qEdF41mGH/22KrpAKXdBEqfHD7qK25pyt/PP7Jmscj0zCGcW1wB8yB4st+mz24xP4gd9wBHzZEECmJ/s7uzQJabGmina+gWOHSF9V+QxrBr9X2kCQ9GMAg340FBU1WvoQJRO00vIkhqxdjvnbGWv1+CfXsyFJkgL4fi4GVidKD58Fi3gXI5N/qvlH0mJlKab/kJT7uwMxSKMD6KuWd5NxVVp0lYNdytaX4P7IhwH5kSZ3e/c+ogfPeXQO0622AIwZ3UpzlTVuHb8qwiHjLq4hdPJgbosBaYVR2LJW30TWs/Xd/2BNlLFcesMFsJ2x9M3w==; 5:BDBOe8PogNSdi/uU0SErMCcS6gxG0xaR3nHY+DAC+gWTz6QeK8rk9pHTsf6KgCsHrOKFB4ckvjZSybaReU6GAQYSQIoqgsUpAZLFAM1sKIZIFFwLuA+72FWS01dpIWAuiK4SnNOj4PqL8emDYAEJwQ==; 24:LCIv+YsBxKN6S8fPFS2s965nxoZ6/mxYGtMgXU6OKqoeiyLh/0PxKqYDI+WVKVBFosdb9150X5YRNW9VHWoHrHqMuYBSgA/FYMT8T8K9pgM=; 7:t8XPLdukAaU1SAML9DwS55qXU+AxbCvNXTM6fHy1lD8q15Jy8/8f7CEQyfU+WUS6ys8O21pC1nklm7hUMjGIB7hDo0HKHJWkr9Z49WPqz1AmqO2NbYOxfGcfia/BoanHrdK2MoCCwSD+I9KwSQf6Sc8B4E4LE/MfO2SWbaQ56zSgTLPHL7QIVnB8FHpQVmfuLg0hpds2kqC3e57svgta1V94Nz65yBCuW2oaIPNYmy4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:7QoeBBrHUjqtkZKBeMijqwbxeKpVlpUA+JtVoDlf4q3sOTConGZPoiVKfYkjo1jCZU8oH4XBeMeC3DzZu+ydVON/rk+MlYgew/oFOpau/LBSqnaDFSnff6jr6+ForLieTwA361OGwnhQFUDxxgluIy63UsFW1XtgE9ACKfPjWmEmSoIt8Nw+eGWgh6E9MLgSqAfDr6NR9DHzjrDJqofbAHo8MlSpJZEFR7jB9VtqkdO38+RhwWvOQAdXwMHpuKrZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:03.8103 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 13/23] OvmfPkg/VirtioBlkDxe: map host address to device address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The SynchronousRequest() function, programs the vring descriptor with the buffers pointed-by virtio-blk requests, status and memory that is referenced inside the request header. The patch uses VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() function to map host address to device address and programs the vring descriptor with device addresses. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioBlkDxe/VirtioBlk.h | 1 + OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 201 +++++++++++++++++--- 2 files changed, 180 insertions(+), 22 deletions(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.h index 6c402ca88ea4..9ec0b956b818 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.h @@ -41,6 +41,7 @@ typedef struct { VRING Ring; // VirtioRingInit 2 EFI_BLOCK_IO_PROTOCOL BlockIo; // VirtioBlkInit 1 EFI_BLOCK_IO_MEDIA BlockIoMedia; // VirtioBlkInit 1 + VOID *RingMap; // VirtioRingMap 2 } VBLK_DEV; =20 #define VIRTIO_BLK_FROM_BLOCK_IO(BlockIoPointer) \ diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index bff15fe3add1..e23762743f75 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -232,7 +232,8 @@ VerifyReadWriteRequest ( =20 @retval EFI_DEVICE_ERROR Failed to notify host side via VirtIo write= , or unable to parse host response, or host resp= onse - is not VIRTIO_BLK_S_OK. + is not VIRTIO_BLK_S_OK or failed to map Buf= fer + for a bus master operation. =20 **/ =20 @@ -249,8 +250,16 @@ SynchronousRequest ( { UINT32 BlockSize; volatile VIRTIO_BLK_REQ Request; - volatile UINT8 HostStatus; + volatile UINT8 *HostStatus; + VOID *HostStatusBuffer; DESC_INDICES Indices; + VOID *RequestMapping; + VOID *StatusMapping; + VOID *BufferMapping; + EFI_PHYSICAL_ADDRESS BufferDeviceAddress; + EFI_PHYSICAL_ADDRESS HostStatusDeviceAddress; + EFI_PHYSICAL_ADDRESS RequestDeviceAddress; + EFI_STATUS Status, Ret; =20 BlockSize =3D Dev->BlockIoMedia.BlockSize; =20 @@ -278,9 +287,88 @@ SynchronousRequest ( VirtioPrepare (&Dev->Ring, &Indices); =20 // + // Host status is bi-directional (we preset with a value and expect the = device + // to update it). Allocate a host status buffer which can be mapped to + // access equally by both processor and the device. + // + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *HostStatus), + &HostStatusBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + // + // Map virtio-blk request header + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) &Request, + sizeof Request, + &RequestDeviceAddress, + &RequestMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto FreeHostStatusBuffer; + } + + // + // Map data buffer + // + if (BufferSize > 0) { + if (RequestIsWrite) { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) Buffer, + BufferSize, + &BufferDeviceAddress, + &BufferMapping + ); + } else { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterWrite, + (VOID *) Buffer, + BufferSize, + &BufferDeviceAddress, + &BufferMapping + ); + } + + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapRequestBuffer; + } + } + + // + // Map the Status Buffer with VirtioOperationBusMasterCommonBuffer so th= at + // both processor and device can access it. + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + HostStatusBuffer, + sizeof *HostStatus, + &HostStatusDeviceAddress, + &StatusMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapDataBuffer; + } + + HostStatus =3D HostStatusBuffer; + + // // preset a host status for ourselves that we do not accept as success // - HostStatus =3D VIRTIO_BLK_S_IOERR; + *HostStatus =3D VIRTIO_BLK_S_IOERR; =20 // // ensured by VirtioBlkInit() -- this predicate, in combination with the @@ -291,8 +379,13 @@ SynchronousRequest ( // // virtio-blk header in first desc // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request, - VRING_DESC_F_NEXT, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + RequestDeviceAddress, + sizeof Request, + VRING_DESC_F_NEXT, + &Indices + ); =20 // // data buffer for read/write in second desc @@ -311,27 +404,62 @@ SynchronousRequest ( // // VRING_DESC_F_WRITE is interpreted from the host's point of view. // - VirtioAppendDesc (&Dev->Ring, (UINTN) Buffer, (UINT32) BufferSize, + VirtioAppendDesc ( + &Dev->Ring, + BufferDeviceAddress, + (UINT32) BufferSize, VRING_DESC_F_NEXT | (RequestIsWrite ? 0 : VRING_DESC_F_WRITE), - &Indices); + &Indices + ); } =20 // // host status in last (second or third) desc // - VirtioAppendDesc (&Dev->Ring, (UINTN) &HostStatus, sizeof HostStatus, - VRING_DESC_F_WRITE, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + HostStatusDeviceAddress, + sizeof *HostStatus, + VRING_DESC_F_WRITE, + &Indices + ); =20 // // virtio-blk's only virtqueue is #0, called "requestq" (see Appendix D). // - if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, - NULL) =3D=3D EFI_SUCCESS && - HostStatus =3D=3D VIRTIO_BLK_S_OK) { - return EFI_SUCCESS; + Status =3D VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, NULL); + + // + // Unmap the HostStatus buffer before accessing it + // + Ret =3D Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, StatusMapping); + if (EFI_ERROR (Ret)) { + Status =3D EFI_DEVICE_ERROR; + } + + if (!EFI_ERROR (Status) && + *HostStatus =3D=3D VIRTIO_BLK_S_OK) { + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_DEVICE_ERROR; } =20 - return EFI_DEVICE_ERROR; +UnmapDataBuffer: + if (BufferSize > 0) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping); + } + +UnmapRequestBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, RequestMapping); + +FreeHostStatusBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *HostStatus), + HostStatusBuffer + ); + + return Status; } =20 =20 @@ -580,7 +708,8 @@ VirtioBlkDriverBindingSupported ( virtio-blk attributes the host provides. =20 @return Error codes from VirtioRingInit() or - VIRTIO_CFG_READ() / VIRTIO_CFG_WRITE(). + VIRTIO_CFG_READ() / VIRTIO_CFG_WRITE or + VirtioRingMap(). =20 **/ =20 @@ -601,6 +730,7 @@ VirtioBlkInit ( UINT8 AlignmentOffset; UINT32 OptIoSize; UINT16 QueueSize; + UINT64 RingBaseShift; =20 PhysicalBlockExp =3D 0; AlignmentOffset =3D 0; @@ -729,25 +859,42 @@ VirtioBlkInit ( } =20 // + // If anything fails from here on, we must release the ring resources + // + Status =3D VirtioRingMap ( + Dev->VirtIo, + &Dev->Ring, + &RingBaseShift, + &Dev->RingMap + ); + if (EFI_ERROR (Status)) { + goto ReleaseQueue; + } + + // // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resour= ces. + // size. If anything fails from here on, we must unmap the ring resource= s. // Status =3D Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 Status =3D Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); + Status =3D Dev->VirtIo->SetQueueAddress ( + Dev->VirtIo, + &Dev->Ring, + RingBaseShift + ); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 =20 @@ -758,7 +905,7 @@ VirtioBlkInit ( Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } } =20 @@ -768,7 +915,7 @@ VirtioBlkInit ( NextDevStat |=3D VSTAT_DRIVER_OK; Status =3D Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -811,6 +958,9 @@ VirtioBlkInit ( } return EFI_SUCCESS; =20 +UnmapQueue: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); + ReleaseQueue: VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 @@ -849,6 +999,7 @@ VirtioBlkUninit ( // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00); @@ -885,6 +1036,12 @@ VirtioBlkExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // Unmap the ring buffer so that hypervisor will not be able to get + // readable data after device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); } =20 /** --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491044171353.65812215303686; Wed, 23 Aug 2017 05:24:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D1B9921E47D40; Wed, 23 Aug 2017 05:20:42 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E85D621D2E628 for ; Wed, 23 Aug 2017 05:20:35 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:04 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=w1RaodsklB38EBptUS20FsdyP0QSPOgM9RMYMVPP9pI=; b=Xnd7DxgpFz5qyIzA2/8QOX5c8lhLegbtSbGcpkyF/rwGCjxh+cNOwBiORqIsXzutG8gRr/BMPLYuWG0I/6LMzQC5OY0iaMDOpjpkXQ92ejMZcmi+Pr96fvBQVBu3Aryl7Zo32bfvMOyHZHJ8nQf+Diw+/Eg2WP2ntrqvn5pVZD8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:38 -0400 Message-Id: <1503490967-5559-15-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06900425-d747-43b2-bb1b-08d4ea21b43f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:NlduUbhUh65SaFEPx63vsPGziZyYzBS2B6xsYRhror2iY7ndgi4vKWG26yz/Pd+sJ7o/AkQfup7OmsYnf1XYGc8c2aOKsLzyCLFLQUGo3gCHHsGbXllL+F4ljhJUtTHOAOm92c5u24De1CDW3E4xbblsIPUx4C8kgJTqQRrG2rmmS46lzLa20Z4OY4Co47NAv/GxcskIBX1UQ3zL6jP6hRZTF13PapN0xLYa6TuXhoFx3etQdI5RtUrqMIVszffg; 25:FncrD5XtNntgAGRNlIFQUwwUq+JjGgbrB3C0Iz3in8drIQIeef9pL4XMEQvOoxAa3MgVaZy4S1bom9dk2GQHT6VYxQSXBUmVWKPKny3e09XvE9pEgNOZoQfVl0t5e+CDBbi/lqFPXfCy8Gr+KGMhZeHHLOrP8u+yKpVpAJNfYCUce1KWFyB/bBz63FwAdFtS/Kv7Y84uQn8jg0GNE4AqImGN+Cl3r6tuRA71NOsAIkqp47WKJ6uOO4hIE3U2+Xqb0ptxlIvGDoW6JE0fXaPlKIE1A31O+gJEf0PYI/W5NeAm3Cd6GhW8XEe206UA+ON4dC/13UhKPAOSjzNcjmwZFg==; 31:crlqf0ATJpW2NRbOglTA+T1R9zb68lkIXSoQtFFQJSIxdAjy2kTchCRNSgI+BHa2LclKbnGhP4h7JKTpILjUEgx3G55Eh1M2b6sH2B2CQVAgAdWSP590dHCgpYxI08aval1FJS9GkQqkPzqxuiaCkiLEQPKoH8Px3P+OfxL1LYFyhFhb9wuxQfWj9kyVQr6Pt85TVb2xAfposLSag/FhS4zO2Uje3UUVpCx81O6gTc0= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:0sFR1DLsEM7Dn9+BE1toOpm4kjo65Vw7Wj7BXRfty7G0GUMIlkbZee0Gyou3l8wZ8E/9w3mYVnq5C5TIUCztldyaoB5TMoc4h8F08yaqqxmaDAbs634pMoP+7UczTs8uXLKxeWiDsjRjjt0SX3d+6DdXMnBWIbgWbufSPQ4JzmXJty4oMgGfLw6YiayOQWQhwUvroPmGvJosgO7lAXKqb7L5uoSS0z21VhQlm+GaYNI9PLFjblru1ivULKOAdx4XDmhryY0T6upbx9g53F4FlTFYsDV+ARScPw+6FJtFJRxD0dtlKWHYCu3aXXe77+hN6+P+Zvz8ltx5QYYigfMd9oknhO0zVb/BKRmxaXapORqlzoCHjZa1hzmfQgz49TfLcymu2KGQDMbX0qMgfwNFFCghKAJ0vLVhEpUJ8V72ogoO4WHSdlA8ryvC5AE5vTGEprf12hoyDDn88mDVAB0W0LNW0kHrL8B60p5q42TbWJ2JDL/s0luu2rAJr6eDLRxS; 4:uK+Bl4n5Tibn8iP6LwZ1tbLs4OzelU4dEE5dvBeien6N6yQ+Tue4iyKdVR7I3n7m5ml+SskBgqn1qkqfZptLmgYN1iRWKVRL8zEXjjk3DRMEghIBIMmYud5nPsy9lp1ZZh1/funRwTQQStZEDbZKT4PDPwtDtXDDND3aa2PkoKjwbx1ravnu1V+IyxGIR5sxAjhnfvkKkclwaZd4eiwC5A1312cFrG8CZi+d9aPpmULu8mLRtGz/fcaJxZttHrxc7XGWX51Mksd4xcZzBAizYaVqtS+FKTBiByXYLrTx/N12Qo2AnIwNwL4gZLchwiPerntyE7Nm4iKh0w7U3elrlbUq/bWhrOib2ILU7IcesWI= X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699)(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(51234002)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:B5Ijmyb16O9AfM5koqpxsatM9+wPrSKigsTB24nvz?= =?us-ascii?Q?lLW8L0Ur+f5tK4qV6WbggDBgNCGsWLR/5cO8EA2+Rip5z7GgRHe6RafrV75T?= =?us-ascii?Q?PLC5QdRdzimCx3p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KDF/1IPvFHpquPllvdkDuf+2WUm9pcLgKkEyKD1tFeEuoCrNerXssQ+iAanrn7Vw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:NNBXziN61dS0BqdhwvUGjiDcDQX2ZrkEwL5foSrlNbaP0y0IN02eyL2RLLNEPZLkfNEJAP6af8quxvrNtGC73sa92QPrs9+dUpu5nip/H1/qPsS8OhEhyYF86vaEfoLVcHwkR6JifiSZjVAhX90NpDo98xTjYKKH8DiNJrdiv4I8p4UdliShTtNBukhH7+S9J/0ImabhJNFMhsrSidVzvXguJ7Vkg05WSBWBib379ZQyyWgYkdGLqboq+KJ7tR8e X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:04.3259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 14/23] OvmfPkg/VirtioScsiDxe: map host address to device address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The VirtioScsiPassThru() function, programs the vring descriptor using the host addresses pointed-by virtio-scsi request, response and memory that is referenced inside the request and response header. The patch uses newly introduced VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() function to map system memory to device address and programs the vring descriptors with device addresses. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioScsiDxe/VirtioScsi.h | 1 + OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 210 +++++++++++++++++--- 2 files changed, 186 insertions(+), 25 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.h index 6d00567e8cb8..05a6bf567263 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.h @@ -60,6 +60,7 @@ typedef struct { VRING Ring; // VirtioRingInit 2 EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1 EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1 + VOID *RingMap; // VirtioRingMap 2 } VSCSI_DEV; =20 #define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \ diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index a983b3df7b9c..ed7fd1dd58a8 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -409,11 +409,19 @@ VirtioScsiPassThru ( UINT16 TargetValue; EFI_STATUS Status; volatile VIRTIO_SCSI_REQ Request; - volatile VIRTIO_SCSI_RESP Response; + volatile VIRTIO_SCSI_RESP *Response; + VOID *ResponseBuffer; DESC_INDICES Indices; + VOID *RequestMapping; + VOID *ResponseMapping; + VOID *InDataMapping; + VOID *OutDataMapping; + EFI_PHYSICAL_ADDRESS RequestDeviceAddress; + EFI_PHYSICAL_ADDRESS ResponseDeviceAddress; + EFI_PHYSICAL_ADDRESS InDataDeviceAddress; + EFI_PHYSICAL_ADDRESS OutDataDeviceAddress; =20 ZeroMem ((VOID*) &Request, sizeof (Request)); - ZeroMem ((VOID*) &Response, sizeof (Response)); =20 Dev =3D VIRTIO_SCSI_FROM_PASS_THRU (This); CopyMem (&TargetValue, Target, sizeof TargetValue); @@ -423,12 +431,93 @@ VirtioScsiPassThru ( return Status; } =20 + // + // Response header is bi-direction (we preset with host status and expec= t the + // device to update it). Allocate a response buffer which can be mapped = to + // access equally by both processor and device. + // + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *Response), + &ResponseBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + ResponseBuffer, + sizeof (*Response), + &ResponseDeviceAddress, + &ResponseMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto FreeResponseBuffer; + } + + Response =3D ResponseBuffer; + + // + // Map the scsi-blk Request header buffer host address to device address + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) &Request, + sizeof Request, + &RequestDeviceAddress, + &RequestMapping); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapResponseBuffer; + } + + // + // Map the input buffer host address to a device address + // + if (Packet->InTransferLength > 0) { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterWrite, + Packet->InDataBuffer, + Packet->InTransferLength, + &InDataDeviceAddress, + &InDataMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapRequestBuffer; + } + } + + // + // Map the output buffer host address to a device address + // + if (Packet->OutTransferLength > 0) { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + Packet->OutDataBuffer, + Packet->OutTransferLength, + &OutDataDeviceAddress, + &OutDataMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapInDataBuffer; + } + } + + VirtioPrepare (&Dev->Ring, &Indices); =20 // // preset a host status for ourselves that we do not accept as success // - Response.Response =3D VIRTIO_SCSI_S_FAILURE; + Response->Response =3D VIRTIO_SCSI_S_FAILURE; =20 // // ensured by VirtioScsiInit() -- this predicate, in combination with the @@ -439,31 +528,49 @@ VirtioScsiPassThru ( // // enqueue Request // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request, - VRING_DESC_F_NEXT, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + RequestDeviceAddress, + sizeof Request, + VRING_DESC_F_NEXT, + &Indices + ); =20 // // enqueue "dataout" if any // if (Packet->OutTransferLength > 0) { - VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->OutDataBuffer, - Packet->OutTransferLength, VRING_DESC_F_NEXT, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + OutDataDeviceAddress, + Packet->OutTransferLength, + VRING_DESC_F_NEXT, + &Indices + ); } =20 // // enqueue Response, to be written by the host // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Response, sizeof Response, - VRING_DESC_F_WRITE | (Packet->InTransferLength > 0 ? - VRING_DESC_F_NEXT : 0), - &Indices); + VirtioAppendDesc ( + &Dev->Ring, + ResponseDeviceAddress, + sizeof *Response, + VRING_DESC_F_WRITE | (Packet->InTransferLength > 0 ? VRING_DESC_F_NEXT= : 0), + &Indices + ); =20 // // enqueue "datain" if any, to be written by the host // if (Packet->InTransferLength > 0) { - VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->InDataBuffer, - Packet->InTransferLength, VRING_DESC_F_WRITE, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + InDataDeviceAddress, + Packet->InTransferLength, + VRING_DESC_F_WRITE, + &Indices + ); } =20 // If kicking the host fails, we must fake a host adapter error. @@ -477,10 +584,36 @@ VirtioScsiPassThru ( Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER; Packet->TargetStatus =3D EFI_EXT_SCSI_STATUS_TARGET_GOOD; Packet->SenseDataLength =3D 0; - return EFI_DEVICE_ERROR; + Status =3D EFI_DEVICE_ERROR; + goto UnmapOutDataBuffer; } =20 - return ParseResponse (Packet, &Response); + Status =3D ParseResponse (Packet, Response); + +UnmapOutDataBuffer: + if (Packet->OutTransferLength > 0) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, OutDataMapping); + } + +UnmapInDataBuffer: + if (Packet->InTransferLength > 0) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, InDataMapping); + } + +UnmapRequestBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, RequestMapping); + +UnmapResponseBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, ResponseMapping); + +FreeResponseBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *Response), + ResponseBuffer + ); + + return Status; } =20 =20 @@ -707,7 +840,7 @@ VirtioScsiInit ( { UINT8 NextDevStat; EFI_STATUS Status; - + UINT64 RingBaseShift; UINT64 Features; UINT16 MaxChannel; // for validation only UINT32 NumQueues; // for validation only @@ -839,25 +972,42 @@ VirtioScsiInit ( } =20 // + // If anything fails from here on, we must release the ring resources + // + Status =3D VirtioRingMap ( + Dev->VirtIo, + &Dev->Ring, + &RingBaseShift, + &Dev->RingMap + ); + if (EFI_ERROR (Status)) { + goto ReleaseQueue; + } + + // // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resour= ces. + // size. If anything fails from here on, we must unmap the ring resource= s. // Status =3D Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 Status =3D Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); + Status =3D Dev->VirtIo->SetQueueAddress ( + Dev->VirtIo, + &Dev->Ring, + RingBaseShift + ); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -867,7 +1017,7 @@ VirtioScsiInit ( Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } } =20 @@ -877,11 +1027,11 @@ VirtioScsiInit ( // Status =3D VIRTIO_CFG_WRITE (Dev, CdbSize, VIRTIO_SCSI_CDB_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } Status =3D VIRTIO_CFG_WRITE (Dev, SenseSize, VIRTIO_SCSI_SENSE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -890,7 +1040,7 @@ VirtioScsiInit ( NextDevStat |=3D VSTAT_DRIVER_OK; Status =3D Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -926,6 +1076,9 @@ VirtioScsiInit ( =20 return EFI_SUCCESS; =20 +UnmapQueue: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); + ReleaseQueue: VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 @@ -965,6 +1118,7 @@ VirtioScsiUninit ( Dev->MaxLun =3D 0; Dev->MaxSectors =3D 0; =20 + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00); @@ -995,6 +1149,12 @@ VirtioScsiExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // Unmap the ring buffer so that hypervisor will not be able to get + // readable data after device reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491037854509.18926811804624; Wed, 23 Aug 2017 05:23:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 99DB121E79014; Wed, 23 Aug 2017 05:20:42 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C40C921D2E634 for ; Wed, 23 Aug 2017 05:20:35 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:04 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=d2rbhAAgtrh//FRREhTr2WBIabjSragiyVuBHqAul4g=; b=oC98K7B7zxs8k1WP+xLc8bHasHp8s4EsPsggl8KAAb1jiVG+KXPXkv5yESFD0dUnmjhvCkzSLuX/RlxU2CEFgds64MgdXhpozWM3OWeG/5E6/la8HyhL/VgXnhVp13mWn4Q3P6sOl0y3CjPDi9jGfKFJJhCUjD4dQCJ1nAvZsno= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:39 -0400 Message-Id: <1503490967-5559-16-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 844ec527-f019-46b9-418a-08d4ea21b487 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:lVd3s2uCO+/jCi7VR1eyX99SK3IdH6DMv6WrfTRaSJxCJxdjTMqFMJ+wUtAgAnRxWNSzG3LsuTp0gT3EbKAqoKTgNjCXjl80blYJRjJsQEOMcPC5H7Mieq+aVEsMA07exLaSzU32p/AV9rGXIWYHFykx+Llf6+KOpTcmzyB2FWpCYrB2dWWKviwiJgLOnZDNsbcZflfCl6AK965P/fFFbuMkMuYyBe4h7sYCW2qB6FHFqgRBSleSGeJARvJ5N7LH; 25:0r25IBpT3dUvuOvdKyZ/Mu6s4LCZrf4j+fLoXhbZiNICJD62XILGCTn7s+kKSg614s3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IpsN8+vEk4u64KGJ6j2/H8J25PBC; 4:cA40tJ4XCmHeRaZBjUN2E7oV+X3bbnRrZQlKqDKyISkiq0T7refX7ZwyUGgdGRaZlDJmxwhJIwhL0GyNmSylYk08F5bzjQLbVLCZ0OnmeHtRegpxqkPydGrP4i+P4GAllkdQkOL/uCorCdZ8yv5WVXQDvknn4doBqVYN++QBaPlC57WGU/z3Vtz/Ba+bNyiLXUF5az/hqRxtpJ/pcPlP8zeJFbdY4aTD3Rtvw7UcFs/XNoz+HzVA/moM22L9onANLuyy7d4FglIYHN9cwqjZH+Ma/YuLmhJpKELVpDtFm8sxRjFN+4LoqkelRkPJ5m/pr0s6nOi9NDy+hRXY6eADKO1n5wnRirsphdwUaGXoJ2c= X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699)(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(51234002)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:6KSEwfqWdTSgP06PBG2A/FcsOGmDm6CHOjfbk+31U?= =?us-ascii?Q?7UBWSw6fQ3eq8wquSd3qPpJDT7EBqNc8976PJWdZxEMzsEbuDQI8N4pJx+fR?= =?us-ascii?Q?yQ/h/JIgXZRzKhhujv6a0c4sH99D7dOdpQhbqkjsnplweVFToadLb6PNMVtp?= =?us-ascii?Q?4B1z0s+m47WCD7dENqSecXapgxJYqXG0FEVIGV2/xfitrE6uJG12tb2qxAOR?= =?us-ascii?Q?J4vR27OAgZTMIBrnEHv7+jpjai+huEShISl9dpIxv4upN5Q9XnmC/CcwJstY?= =?us-ascii?Q?47vvhN1AYrVhKEdLDgdcZYodpuF50PjzHsulAd9AY/HdPV1dBgwnXdM2uacd?= =?us-ascii?Q?WcWU83ed+NGQX9ZrnZz6AjBOLEBJMFUc5zulnLyhHfDkQ8OLKtOr8MrUQUOh?= =?us-ascii?Q?446vg9OeChwMlh14ZQXwh0kqxCAoQ+hMc1cvKJrHBq0RDwFbjjLpqkevoBFS?= =?us-ascii?Q?aDYCut+7/EEFgxIqoJK6tvNPqjhxfZBhm9lOkOd5/ta+ZUk7BrfC1n4Eow09?= =?us-ascii?Q?kMvU2JsZ/2IrEsvy/pQ5skGCA1VCB1LOfNpJ0uDeK2KL5JE+yxM7vreQKKhH?= =?us-ascii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mvtu4UzPsMsH8HFqNOt4L1e3qlAixI/Fs70DIgGHmANbBi/1QSXURUA0LiphfKMhaI6FEFgnVQ==; 5:CfF3SKdDOiEYe68oC/PPdWiXKikHAzAv1E2A3n/Ug9CHoEKjqdKmwwaoV89SwwUzLYmi+aNrVPgt3L0NdxnHSKG8HnSle6S/HuWb1iHsmnh/BG8nlVfGmz6AYnCDX2xiKNYx9yNLo6IYZeAbbzAvrg==; 24:91LsFdph6RMEuCmLeNa3dl0fGyvlTh2k4Mboj4cDrkA+kQwfq+GAfgMTzYUrNscY82U9YN7rEB1mnDA0lmo4Pphjec5/VZsM4RYUe0hK4j0=; 7:USNqHm64L1XG8GWXq0zCiV3hIDVdCe35PUT4HeeHJ6BBY/AnX9gjwUQHGF43Q38zvMWf6fdnzUXpTK5D5MiRwmVkqCm0HZCTF8vo9Pa2qigujhKekMprbRTPXFot3MuZ5oqhia+/ZdsAqs8bz49/VpOnILIqNyEWsx2rte7nrn1J0NEhVz0AXoQ2Uayf/fXG5/i2BCULxnOOLe9bwvr2RRguKAvUlP01P02xvB6ivDk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:dic6nCaJwwPCoJsNmjlAleSML01XhG1xJYvyFHBJApESqCw2Nc9gy4+kNpKIhAbOkzgzna2xMEsyDXs8VBU0A/8zOb2RE1Pv3ksy2HBwzNFYci5tpibKmh1hH9xKyiA+q2OvPRe81fa+e83CmPlQp0xac/gZLtHCv1nxSrxFKjFGkF4WA9Qjt6pTavUDB3S7SVJe1kXmkek49NqTtmAjniFIurUtksyDJVNwCTFEITwzdhgMXrxaYxDJDwm52+Bq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:04.7790 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 15/23] OvmfPkg/VirtioNetDxe: alloc Tx and Rx rings using AllocateSharedPage() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The Tx and Rx rings are accessed by both guest and hypervisor, allocate the rings using newly added VirtIo->AllocateSharedPages() and map it with BusMasterCommonBuffer so that it can be accessed by both guest and hypervisor. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioNetDxe/VirtioNet.h | 2 + OvmfPkg/VirtioNetDxe/Events.c | 7 ++++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 40 ++++++++++++++++---- OvmfPkg/VirtioNetDxe/SnpShutdown.c | 2 + 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 710859bc6115..d80d441b50a4 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -82,10 +82,12 @@ typedef struct { EFI_HANDLE MacHandle; // VirtioNetDriverBinding= Start =20 VRING RxRing; // VirtioNetInitRing + VOID *RxRingMap; // VirtioRingMap UINT8 *RxBuf; // VirtioNetInitRx UINT16 RxLastUsed; // VirtioNetInitRx =20 VRING TxRing; // VirtioNetInitRing + VOID *TxRingMap; // VirtioRingMap UINT16 TxMaxPending; // VirtioNetInitTx UINT16 TxCurPending; // VirtioNetInitTx UINT16 *TxFreeStack; // VirtioNetInitTx diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 5be1af6ffbee..6950c4d56df1 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -88,4 +88,11 @@ VirtioNetExitBoot ( if (Dev->Snm.State =3D=3D EfiSimpleNetworkInitialized) { Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); } + + // + // Unmap Tx and Rx rings so that hypervisor will not be able get readabl= e data + // after device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxRingMap); + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxRingMap); } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 0ecfe044a977..803a38bd4239 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -35,11 +35,13 @@ the network device. @param[out] Ring The virtio-ring inside the VNET_DEV structure, corresponding to Selector. + @param[out] Mapping A token return from the VirtioRingMap(). =20 @retval EFI_UNSUPPORTED The queue size reported by the virtio-net devic= e is too small. @return Status codes from VIRTIO_CFG_WRITE(), - VIRTIO_CFG_READ() and VirtioRingInit(). + VIRTIO_CFG_READ(), VirtioRingInit() and + VirtioRingMap(). @retval EFI_SUCCESS Ring initialized. */ =20 @@ -49,11 +51,13 @@ EFIAPI VirtioNetInitRing ( IN OUT VNET_DEV *Dev, IN UINT16 Selector, - OUT VRING *Ring + OUT VRING *Ring, + OUT VOID **Mapping ) { EFI_STATUS Status; UINT16 QueueSize; + UINT64 RingBaseShift; =20 // // step 4b -- allocate selected queue @@ -79,30 +83,38 @@ VirtioNetInitRing ( return Status; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, Ring, &RingBaseShift, Mapping); + if (EFI_ERROR (Status)) { + goto ReleaseQueue; + } + // // Additional steps for MMIO: align the queue appropriately, and set the // size. If anything fails from here on, we must release the ring resour= ces. // Status =3D Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 Status =3D Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // // step 4c -- report GPFN (guest-physical frame number) of queue // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, Ring, 0); + Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, Ring, RingBaseShif= t); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 return EFI_SUCCESS; =20 +UnmapQueue: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Mapping); + ReleaseQueue: VirtioRingUninit (Dev->VirtIo, Ring); =20 @@ -456,12 +468,22 @@ VirtioNetInitialize ( // // step 4b, 4c -- allocate and report virtqueues // - Status =3D VirtioNetInitRing (Dev, VIRTIO_NET_Q_RX, &Dev->RxRing); + Status =3D VirtioNetInitRing ( + Dev, + VIRTIO_NET_Q_RX, + &Dev->RxRing, + &Dev->RxRingMap + ); if (EFI_ERROR (Status)) { goto DeviceFailed; } =20 - Status =3D VirtioNetInitRing (Dev, VIRTIO_NET_Q_TX, &Dev->TxRing); + Status =3D VirtioNetInitRing ( + Dev, + VIRTIO_NET_Q_TX, + &Dev->TxRing, + &Dev->TxRingMap + ); if (EFI_ERROR (Status)) { goto ReleaseRxRing; } @@ -510,9 +532,11 @@ AbortDevice: Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 ReleaseTxRing: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxRingMap); VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); =20 ReleaseRxRing: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxRingMap); VirtioRingUninit (Dev->VirtIo, &Dev->RxRing); =20 DeviceFailed: diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpS= hutdown.c index 5e84191fbbdd..36f3253e77ad 100644 --- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c +++ b/OvmfPkg/VirtioNetDxe/SnpShutdown.c @@ -67,7 +67,9 @@ VirtioNetShutdown ( Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); VirtioNetShutdownRx (Dev); VirtioNetShutdownTx (Dev); + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxRingMap); VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxRingMap); VirtioRingUninit (Dev->VirtIo, &Dev->RxRing); =20 Dev->Snm.State =3D EfiSimpleNetworkStarted; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491055652600.8280064528967; Wed, 23 Aug 2017 05:24:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4F98421E47D47; Wed, 23 Aug 2017 05:20:43 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A65021D2E628 for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:05 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=g5L0FMZqbCBq7Cx68uGBRcOvBovwZv0Sd/dPSXZ4Aw4=; b=RcNNVmekd8WOE3L7rGtlZCrnJCFIpgWxiL6zsWaPosDo1cwqW4bI+DGv2W/F8dMPSKw2eZZnHfjgCYb6c8/wtCykPyAoU4jbOdaCpciapwssmwjtVB8KTGppr1sRtdYBnq+QQoScNwWTf7fsTmJEzWVsmzLGpUNdV4mscP8rgzA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:40 -0400 Message-Id: <1503490967-5559-17-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7060c7ba-1ad8-438d-c804-08d4ea21b4ce X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:RmtHVF+LTmI0ZJOdytR/WxH+hyHdPU5zVP66oh4Qwl9hnXNx3lz3+clPdiN7tJ0dV7mbHq62ZAoK4r8kTIfqVB9f1Ljx2rG6JcpIDguKwc/H++TXX5RLprz9tjkvTpP7GnHuAN1h4Y5I41oWyRr/HB1joNy19CmaMYHvnV4epASzil4Y3BBxxqcOrcHL+PKg3aCTj+4Aj8mr1KyEw1B2BKpwavZiIEiLupGfRBVmu8a6/uspbK6UfYI1zYcsMXRY; 25:C03hI6cNItnhUU2YqqSkSa7v1sfK+DtNKXSQxsOMI7ljJnXnvFYdFEl2ccpyzNsprFuukQBsi/viyP+0TzxnUiJP/5gUPPPYilxGgBlzP8r2oANNkNmv4z2XjupiokP0VSK82gvZd0KRdZf5bagmZ1yMz5UrcTVoadAS7zwxYKTJIAVqkBnzvm386spcXQQm4Bax651IoxTGnGaeVr/WHRWOu0zElSPh7cbHN0K6ovaPNNyqlHAWhgxaKX9rEohotF7PuJGYyxQdxlS+m7I2vwvY2PGT3IIp/IuS9cPVQ67/Hf1oIT7BBJIQbN7kyXv2sAKllq18iK+3//lr11JV3w==; 31:Rdac4i8qUkld2CCCne7Y4zP09DHA77dFKYUvwLvrfeSTMdGs7XrJcTyXfeX+SCVFfRz/mXU9mAOa1RyrRyjW/y/SZXZ0pg5X0sUcw82RpQdr9Gss8us0LqvF6u0NA8SsmT1ec5YTsOm5frtDeIw4kfYpySoBwuNVe1z8JuMkVYM4zzSRh20Q//hJ809UJ7SbXfwmGVjJU5viplXc1agOZ2bkTvT58eQlkmgpVGUOf98= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:kpiUGncvmQPLd0wbicSO0GATh4khSpWLp8FWz9WLL1Dz619hc66Ndp8Xdek3pHQhkgp5xGBXQKowVSEH8eHCHUykZvkNPjf4X1Mr5qJNfWcPvj2SUomYK4QRmGy7LFBNNf291xdgqP9mLIYEKjD5sPSL1J8+WsoUTdkZCdeoNeC/i5ZazlH/1vnxdDWR5bGnHmj5hwN986RyDdctzsqKJJwJ75oxqp6Xb15BKQox7cNXWJI8aCjMv/R7vEOSf/dbphus+dWpEljNquspLSLG0EjrosZ1Q4CrjZ+jHOOKJnZZM7MmS3ECz550C9q6RLAhdJch+CQjQcCpiZQs5Cj50+W5/Dql2I8SQKxHS8mgUfx65BR8j3rjXPNVKOgwXB9rvxohTWunEaQVRsY3PNJ+idRe6Cw4BCtFNtw/wruhaotbPz91N27MEH05y99rA1uZa4Jz/3Qshwgoem2cY0NuqKOiNakNyC5K04qPZ0qZ8OY0m7XOGviRmOuh1SM01dlT; 4:+D7L9xkqttM0eUyOm5VOjcb8wbSMrXIcXwiJspNdYTEda3AOL5YBWFRrX1aOeFCEN39MMtwpZuHwA1Rhs09C6SeUlz9CJ8q2VJNmxXZW3ssSkfHjqFuBSTxwrZ66MtzWAh2LY1HJ2xv9huhvlJKPbzd5X9hT4ypw3mnWs3KkFEndpgTtuH3BE+HSjZNzmr0rIyhketXhF8DuFgPP9CMQ5tS+5z28WXqzg0jP2RV4DGVbS3+4rHfU1xDK7orNtfTcn0XdZkJUz+KcVaw8wMLxo2b+0RA+jotp3Q1yikl8+HSPw/0XYpaUc32EQkvAf3EmG2ZTwIu4Ak+cVpLwHRheLQ== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(6029001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:0gtgqDqqMTCZsPAzIks1aQ//+ikKdHC0Y7vVLyPel?= =?us-ascii?Q?Z+nGklJl9FJswAJTW1mHdYC4BDvqK+A7YtWSmQC4mGarhlqMxUZI6dqp4YCR?= =?us-ascii?Q?w2h/CwHdr1GGtOetR8XYgE/OThXYwLpgrZem1eJmgzjCQJ2USSbB/MPiDxOB?= =?us-ascii?Q?lbq7nkaFiFKCDmOH7n/ziYvJLpBSwGQA5+vw+57ALX4j06euNnNPYwKbOR7n?= =?us-ascii?Q?dY0krq3HHeW7MWgETQSLlTb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q?zEXCl05cR8WkrXvNYbbf33WeMQSDpP+KVzubauy9b97L9kSsLJJGw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 6:+rgYGBNLsBf+ZKC9auTIy+l/6hqEoSimdkSjU5ju7FhQms/uNvJukPsiQhn1LlKBNshdNYeL3e7OM2JR2iqXfJZXSIF8IAzw6QVZQ7SPC7PvtzsHyJAQIEf2F9LauEvjQwLiJGaY6KvcOmrykezmfPfe4LMMY8s/l6dZXeDFZTBqAxv1amlImFsnYw+c+XnBYNgHOmHd1NxtryvwWgeQObtfRj1ELMQnJjHqCp/FAIWYJR4P/yk9xK5ZPyl79fLKlZkDz7vLd3brGCY14G/5mul/W1n53XaG7SndBa32EMBOB5bMYCGjsIb9akRfaQY7GtWX8qpLW99DaWGVXCvrkg==; 5:sJ1DHy4IOUzkIUDLcRNevGnDelov9CnhiDuJu+tdoGnRsopaFtSGvryTsIf6K4Whvc3UnJcZSkIkyHLGW9L7gBm8hyDvfldgTdecsoR3YFuldksAamIHqdahBTTh1Z35xwupymKRX9Gd37wyvju8iw==; 24:Oo/tebA/0hx7K7QWq378/hiJrS8Ah5NlHlGBvyT6avwpvxr0R+eJJUPb+D5CZsHznW/gdyiqdLW5vWTdzFGn3hwuLnOIx+MNNHfL8wBzuLg=; 7:3T40GdPuW+mNZlhV7AFfgoU+Oq1RXKuIt8G3Cl+NR6xU6oGoKFeee4Dpaz+JERgoUHsOyby3tA8godWBoaprRVSFzcFAllNwYFk2kRgozg99MgN7cgXzZHufdL5O//oNBevgHnyua6txBj3P/HOltvRSGHb5POhmABxSgav7/UMmS9QTRIHdcE+Q5DrPyA2nByPBuD4K45kpC105qfN9b7iec6H8d3JT2ZjpY0xKKVU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:ECZljH0IDBoCZSTdO7TsjIL7sbgal23fPF1RGJQKYEdbZXdPRoY4ZvOSWozeZsyH/Zq69M7LTt0f6cYGphCed29Sp6HMWl+QFQjn1H2aPEaJmIbhcVHHZiA3EcSgpTMJUFrKNIy4B1maOsU3raUqmLTJkil5RXgZGL4NQ+wTkzwssz6105RNKWWSpRBNSZAzPQXEzx4f+lq6xR0lafTrjr2j3WwX9otJ7XgrLpa8z1tc1kdmUneEOiVIOzXCdNyj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:05.2634 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 16/23] OvmfPkg/VirtioNetDxe: alloc RxBuf using AllocateSharedPages() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" RxBuf is shared between guest and hypervisor, use VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages() to allocate this memory region and map it with BusMasterCommonBuffer operation so that it can be accessed by both guest and hypervisor. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioNetDxe/VirtioNet.h | 3 + OvmfPkg/VirtioNetDxe/Events.c | 6 ++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 76 ++++++++++++++++---- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 7 +- 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index d80d441b50a4..7df51bd044f5 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -4,6 +4,7 @@ Protocol instances for virtio-net devices. =20 Copyright (C) 2013, Red Hat, Inc. + Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -85,6 +86,8 @@ typedef struct { VOID *RxRingMap; // VirtioRingMap UINT8 *RxBuf; // VirtioNetInitRx UINT16 RxLastUsed; // VirtioNetInitRx + UINTN RxBufNoPages; // VirtioNetInitRx + VOID *RxBufMap; // VirtioMapSharedBuffer =20 VRING TxRing; // VirtioNetInitRing VOID *TxRingMap; // VirtioRingMap diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 6950c4d56df1..0586a82cdf09 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -95,4 +95,10 @@ VirtioNetExitBoot ( // Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxRingMap); Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxRingMap); + + // + // Unmap Rx buffer so that hypervisor will not be able get readable data= after + // device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 803a38bd4239..bdc3fd7ac6a2 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -249,13 +249,17 @@ VirtioNetInitRx ( IN OUT VNET_DEV *Dev ) { - EFI_STATUS Status; - UINTN VirtioNetReqSize; - UINTN RxBufSize; - UINT16 RxAlwaysPending; - UINTN PktIdx; - UINT16 DescIdx; - UINT8 *RxPtr; + EFI_STATUS Status; + UINTN VirtioNetReqSize; + UINTN RxBufSize; + UINT16 RxAlwaysPending; + UINTN PktIdx; + UINT16 DescIdx; + UINT8 *RxPtr; + UINTN NumBytes; + EFI_PHYSICAL_ADDRESS RxBufDeviceAddress; + UINT64 BufBaseShift; + VOID *RxBuffer; =20 // // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depend= s on @@ -280,11 +284,41 @@ VirtioNetInitRx ( // RxAlwaysPending =3D (UINT16) MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PE= NDING); =20 - Dev->RxBuf =3D AllocatePool (RxAlwaysPending * RxBufSize); - if (Dev->RxBuf =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + // + // The RxBuf is shared between guest and hypervisor, use SharedPages() to + // allocate this memory region and map it with BusMasterCommonBuffer + // operation so that it can be accessed equally by both guest and + // hypervisor. + // + NumBytes =3D RxAlwaysPending * RxBufSize; + Dev->RxBufNoPages =3D EFI_SIZE_TO_PAGES (NumBytes); + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + Dev->RxBufNoPages, + &RxBuffer + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + return Status; } =20 + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + RxBuffer, + NumBytes, + &RxBufDeviceAddress, + &Dev->RxBufMap + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + goto FreeSharedBuffer; + } + + Dev->RxBuf =3D RxBuffer; + + BufBaseShift =3D (UINT64) (UINTN)Dev->RxBuf - (UINT64) RxBufDeviceAddres= s; + // // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device // @@ -306,6 +340,11 @@ VirtioNetInitRx ( DescIdx =3D 0; RxPtr =3D Dev->RxBuf; for (PktIdx =3D 0; PktIdx < RxAlwaysPending; ++PktIdx) { + UINT64 Address; + + Address =3D (UINTN) RxPtr; + Address +=3D BufBaseShift; + // // virtio-0.9.5, 2.4.1.2 Updating the Available Ring // invisible to the host until we update the Index Field @@ -315,13 +354,13 @@ VirtioNetInitRx ( // // virtio-0.9.5, 2.4.1.1 Placing Buffers into the Descriptor Table // - Dev->RxRing.Desc[DescIdx].Addr =3D (UINTN) RxPtr; + Dev->RxRing.Desc[DescIdx].Addr =3D Address; Dev->RxRing.Desc[DescIdx].Len =3D (UINT32) VirtioNetReqSize; Dev->RxRing.Desc[DescIdx].Flags =3D VRING_DESC_F_WRITE | VRING_DESC_F_= NEXT; Dev->RxRing.Desc[DescIdx].Next =3D (UINT16) (DescIdx + 1); RxPtr +=3D Dev->RxRing.Desc[DescIdx++].Len; =20 - Dev->RxRing.Desc[DescIdx].Addr =3D (UINTN) RxPtr; + Dev->RxRing.Desc[DescIdx].Addr =3D Address; Dev->RxRing.Desc[DescIdx].Len =3D (UINT32) (RxBufSize - VirtioNetReq= Size); Dev->RxRing.Desc[DescIdx].Flags =3D VRING_DESC_F_WRITE; RxPtr +=3D Dev->RxRing.Desc[DescIdx++].Len; @@ -345,10 +384,21 @@ VirtioNetInitRx ( Status =3D Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX); if (EFI_ERROR (Status)) { Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - FreePool (Dev->RxBuf); + goto UnmapSharedBuffer; } =20 return Status; + +UnmapSharedBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + +FreeSharedBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + Dev->RxBufNoPages, + (VOID *) Dev->RxBuf + ); + return Status; } =20 =20 diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index 9fedb72fdbd4..4c9d9ece0790 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -39,7 +39,12 @@ VirtioNetShutdownRx ( IN OUT VNET_DEV *Dev ) { - FreePool (Dev->RxBuf); + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + Dev->RxBufNoPages, + (VOID *) Dev->RxBuf + ); } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491049896885.518880347409; Wed, 23 Aug 2017 05:24:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 155A221E47D44; Wed, 23 Aug 2017 05:20:43 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 17F6121D2E634 for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:05 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=a1xsqvS31ryoYBnlQepiFNy7YR3E9rrDKKCWw1l0SNo=; b=rxR3p0FGRiyJdzz5nbqF7uguYHjojB3NHJ87ehLifViKcrn+osmXuFDEqIGLMlkzR4e+f6PkuQlnmcvwqMKbWEARQaRD6rhFdn4UR8S2RI1Fx5sljHRHyhgst9Z5svwhFsY4+nbQq5VLjxG7pYaFc9Q0DtXHQJjwaJsOs8hfywg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:41 -0400 Message-Id: <1503490967-5559-18-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8cb5c258-df26-42e4-4e6c-08d4ea21b516 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:hDruoq8fetSIcD9q68/jxHu+oxwFUt5kSRfRNPApMY/mNGvOAoyHdf+VI62cT+jSaQji6TFAsB7zxPtsv1/03bfbOWZFbj+s3G/PDP83XfICD4dvAuEfOdNisSk/eLkcTfLdj/9TNULN9TMjfwJjXWHIV9ZGLFQ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LxJWayKWYR6Wl9wZvK8jdLSCGMcsYmJkUr3kH4U8xUoquTJhBmduATHep3CiyqHr6n1KjTP5cHxCyUQWs35Q/akcaH2OrLFtpIe3g0H0Cf4aXkDBOxBzDLjlWhEiwW95h9vTzzs6qTjb3uPNmdTXvvls/thb52rE3DsCJdphD9HzEWTc; 4:AfIb+dTX6ky6VbZCnV9Wrr08bT31itjJJ3BOOSQUipx4BgndazJH2w0UN7+UExeoJ+RmnqOs9Y2NGfyXsqQO5Ao+FXJm9E6EH0nJYAXCE7yptMfPfc6jpoYF0nIOadySP1SiyQ72WBmSlVvIMKTbWvKWwU0ovLrawDe6yBBV1bzaSpFN5A339yC8hAGzumSAWSV/um8vu05GshQr4l9+Lwjtzt+gEj/QmVc/DDGm75M7b5gQGFzVILwbY4NBwQ2vE/cdVh+nTZHBSpEJfZWQJPkSlx8QWKcwOFMe7SUBPd//aqrgqW/SJOC7KnMkf0rBs8pPHKwgAqTkDKpUATcmlg== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:mOubQM2k/YYU23Vs1HHXpjY6UNzQqGsH5XgKniAUZ?= =?us-ascii?Q?ydN4y166ZoZLcZQKED10bFBEnako/tt1mr4XiNbygYw9e7vgwmmhnQDMxy2b?= =?us-ascii?Q?vRto6hZGBb4cz0MTh2jlq17MD8jxUxHOV+rJ3FGhLfLnGPIqemKLqNN7NqRl?= =?us-ascii?Q?2NbJETyUgiAm+i4rbTvW5ePDMXxA5dGKj7IbYCruhDOdOsDMhYHWNP0835jn?= =?us-ascii?Q?vSnYWqvs3x4jMlUTc1TWnEpTl+KV4JBIz6gE6o3wcLBf8LvxWj04y3J2Maf6?= =?us-ascii?Q?MZPbT3PBKxluk3W63AjSZBE6Z9Te7vbGE2X7WhMLGK/tActjttAQ4t1aAwih?= =?us-ascii?Q?WvbDyQpaZgi8rYTzuTA5xSb0+aFhqhd6hvjv2fzIwfxCJ1/Foo9SPHondmvZ?= =?us-ascii?Q?x218ezzVkRv1Xw9XHw5ggSVK7K5OKQSd3WAYcGWWOClJHB29hU+ZlvUUgn/+?= =?us-ascii?Q?cGfW7/waG+zSmd+jE/o4d0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Fwwb7FrsOaGROc5rMw/PtKNAGw+R6j/3WF6+AheevU6j5LFcVRoIA6ZR3bJtA4qqjFm7qgtg2A4OWv35Lt41r7yWpDVx01vIw2vumT/ohDECOV8z7WQeXBOkewYHi3TIF08T+Sfog6utmweyh9140elkR8sofsLRHw2xV6/JscZ2+yp66dxVZnwGD7+GhQ==; 5:MJyrIinvHco2oVCc5OwcQx6oVX6k1I/1gPyxW3LZP4N+Susk+iYPHNP2COHMz4NrieAJ9Evl/gaOrUiTUnuTgRPrEH75LAuSxBKMxjLX6e7p/OcbP0z+WlT7WPeE6N+2rGiAYon/1pAtrORQsFzfSw==; 24:EMO5we3i1rMsnGC+X2knVnOwrJ3JbPdsLAqxbqr5SenQ9Ls0yLJuLSKAn0hoHPjejjXM8YLYRuNqdgfHguh6oQQGTpLwNEm9iX+zAZquK4E=; 7:vwfuAfbao6S0XZyrnt+EYqjJyV/GaDPomLK3Sbg6wteIUA2MidQU+L+B40IPvrXaDbwhykh1DNA35QddQwBjhWI0nqXiZAxj9gPNlypwsqwgKvakU+o0YB0b+djAjFgdypmjwXdWFepq/tSOTcPRL+G0p51lGioJjUCa0vp1CLrWoT1vmfzkMPD9fVHz9/gxTfsFIeRBnryEAHHCkEy4mrrViJWmKjvPmgMmBxN9crU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:cVGfHQPQDA5GWKTeB2ZSrH52QptSEdwfZsybR59coAYTlFkiPXoeBuEnScr/dizyJMVGyVO0Y9S6WpB1y8fKo6ARylCaTEU5KCmgvpRrwGFrVhGrKLbs04yDuOPNhN6VeUcYMR8czr7D5Dm+iCYMwgCbpAtvLZxqm9ndK/0P+zxpBFkk22xkMEq6pLQtaBwG8fyyWvFHcsUzgCZxXoENk13jNMq+Bv0MKS5s0KJGuTXolUEM5iUTXNLH1zj9oWYE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:05.7323 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 17/23] OvmfPkg/VirtioNetDxe: dynamically alloc transmit header X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A network packets are transmitted by placing them into a transmit queue, each packet is preceded by a VIRTIO_1_0_NET_REQ header. VirtioNetInitTx(), builds the header once and fills the vring descriptors with the system physical address of the VIRTIO_1_0_NET_REQ header. The patch uses VirtIo->AllocateSharedPages() to allocate the header buffer and map it with BusMasterCommonBuffer so that it can be equally accessed by both processor and device. We could map it with BusMasterRead but since the header pointer is used after it was added into vring hence I choose to dynamically allocate it and map it with BusMasterCommonBuffer to avoid the code complexity. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioNetDxe/VirtioNet.h | 3 +- OvmfPkg/VirtioNetDxe/Events.c | 6 ++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 65 +++++++++++++++++--- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 7 +++ 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 7df51bd044f5..3efe95a735d8 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -94,7 +94,8 @@ typedef struct { UINT16 TxMaxPending; // VirtioNetInitTx UINT16 TxCurPending; // VirtioNetInitTx UINT16 *TxFreeStack; // VirtioNetInitTx - VIRTIO_1_0_NET_REQ TxSharedReq; // VirtioNetInitTx + VIRTIO_1_0_NET_REQ *TxSharedReq; // VirtioNetInitTx + VOID *TxSharedReqMap; // VirtioMapSharedBuffer UINT16 TxLastUsed; // VirtioNetInitTx } VNET_DEV; =20 diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 0586a82cdf09..9366aa00a1b3 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -101,4 +101,10 @@ VirtioNetExitBoot ( // device is reset. // Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + + // + // Unmap shared Tx request mapping so that hypervisor will not be able t= o get + // readable data after device is reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap); } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index bdc3fd7ac6a2..3d4eb70aa630 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -18,6 +18,7 @@ **/ =20 #include +#include #include #include =20 @@ -151,8 +152,12 @@ VirtioNetInitTx ( IN OUT VNET_DEV *Dev ) { - UINTN TxSharedReqSize; - UINTN PktIdx; + UINTN TxSharedReqSize; + UINTN PktIdx; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS DeviceAddress; + UINT64 BufBaseShift; + VOID *TxSharedReqBuffer; =20 Dev->TxMaxPending =3D (UINT16) MIN (Dev->TxRing.QueueSize / 2, VNET_MAX_PENDING); @@ -164,24 +169,60 @@ VirtioNetInitTx ( } =20 // + // Allocate TxSharedReq header and map with BusMasterCommonBuffer so tha= t it + // can be accessed equally by both processor and device. + // + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)), + &TxSharedReqBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + TxSharedReqBuffer, + sizeof *(Dev->TxSharedReq), + &DeviceAddress, + &Dev->TxSharedReqMap + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + goto FreeBuffer; + } + + Dev->TxSharedReq =3D TxSharedReqBuffer; + + BufBaseShift =3D (UINT64) (UINTN)Dev->TxSharedReq - (UINT64) DeviceAddre= ss; + + ZeroMem ((VOID *) Dev->TxSharedReq, sizeof *(Dev->TxSharedReq)); + + // // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depend= s on // VIRTIO_NET_F_MRG_RXBUF, which we never negotiate. // TxSharedReqSize =3D (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0,= 0)) ? - sizeof Dev->TxSharedReq.V0_9_5 : - sizeof Dev->TxSharedReq; + sizeof ((Dev->TxSharedReq)->V0_9_5) : + sizeof *(Dev->TxSharedReq); =20 for (PktIdx =3D 0; PktIdx < Dev->TxMaxPending; ++PktIdx) { UINT16 DescIdx; + UINT64 Address; =20 DescIdx =3D (UINT16) (2 * PktIdx); Dev->TxFreeStack[PktIdx] =3D DescIdx; =20 + Address =3D (UINTN) Dev->TxSharedReq; + Address +=3D BufBaseShift; + // // For each possibly pending packet, lay out the descriptor for the co= mmon // (unmodified by the host) virtio-net request header. // - Dev->TxRing.Desc[DescIdx].Addr =3D (UINTN) &Dev->TxSharedReq; + Dev->TxRing.Desc[DescIdx].Addr =3D Address; Dev->TxRing.Desc[DescIdx].Len =3D (UINT32) TxSharedReqSize; Dev->TxRing.Desc[DescIdx].Flags =3D VRING_DESC_F_NEXT; Dev->TxRing.Desc[DescIdx].Next =3D (UINT16) (DescIdx + 1); @@ -196,13 +237,13 @@ VirtioNetInitTx ( // // virtio-0.9.5, Appendix C, Packet Transmission // - Dev->TxSharedReq.V0_9_5.Flags =3D 0; - Dev->TxSharedReq.V0_9_5.GsoType =3D VIRTIO_NET_HDR_GSO_NONE; + Dev->TxSharedReq->V0_9_5.Flags =3D 0; + Dev->TxSharedReq->V0_9_5.GsoType =3D VIRTIO_NET_HDR_GSO_NONE; =20 // // For VirtIo 1.0 only -- the field exists, but it is unused // - Dev->TxSharedReq.NumBuffers =3D 0; + Dev->TxSharedReq->NumBuffers =3D 0; =20 // // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device @@ -217,6 +258,14 @@ VirtioNetInitTx ( *Dev->TxRing.Avail.Flags =3D (UINT16) VRING_AVAIL_F_NO_INTERRUPT; =20 return EFI_SUCCESS; + +FreeBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)), + (VOID *) Dev->TxSharedReq + ); + return Status; } =20 =20 diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index 4c9d9ece0790..aeb9e6605f0d 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -54,5 +54,12 @@ VirtioNetShutdownTx ( IN OUT VNET_DEV *Dev ) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap); + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)), + (VOID *) Dev->TxSharedReq + ); + FreePool (Dev->TxFreeStack); } --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491062062812.6263002352015; Wed, 23 Aug 2017 05:24:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8826021E47D4B; Wed, 23 Aug 2017 05:20:43 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5CC3D21D2E634 for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:06 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jP8riQ++Nl1IaoX3VZ3/fDoabQyH4dYJv6iAUCImO/w=; b=NbZ1RbdxB2Rcte/2E+rvrWCMCa5z216P6xqoLDPuntIOaiUf6AYlo9nAXvqgrjX+DPVPjoS64riDxhi6oIdDCGSTErvuDNFQwWqtUdhpwjnKsjbDMx2dRDjtoVxree9Du2a4FC0dl10XfGuN9vzE83lOseZmY/QJuPFm3KsEzbA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:42 -0400 Message-Id: <1503490967-5559-19-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac0d075e-a632-4604-d4d5-08d4ea21b55d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:svfzHp0scNhac91nuB6Jcux/SNzg3hHOL+2ahImUrgtStJs0zwCXtM71Ll5gNepqzvL0fAsRrRdhFl3XK8PuQUNyXajnSI6I/3QeIINpf4xYwGfyNWMzuWf+UbPwnMMec466O3FkCb1WalIgjmI0jvKJrnD0OQzrSRbms9TdNSBA7NJiprf9FehZYoQktljHAzdXWhBFShmWnO4vz6PPjST4M8Q767+9HXgFBDikbg8ug99KESToTUq15/C2Y4uN; 25:oCjfEcSo1YXakfW/BIg0dQeBotj29UH1Pp9oIcqzyemP7MHqkEd/s+gyo/c9AdAJTbzA6Zm2DQsdCBDBI4c2TEkizpzafrojpzOs2JCfBYKEPH5CjIav3lx/8ylAzLhgQ6HKyvbCRXr+MfEgmV6ankj8kGfOUo1+CLts3IHh8x5r5Ge2pp+B124toabYKA6UcVrOdITTMjO+WCht09ohI9iH3XvBa1rreAuiN0j+6DBUvO+1YthwBN8EZDEYiRc5ABrvqF4S3PHr8pqWdlvAoU/OIfKIkMqSXWcVbq0tDIQv149ZFL+afIj7s/hFqRidl64BzjcC0QPb+naeLujaAw==; 31:coLf4Ioc/NQdIfuzWWudngsgvleOdDL64kdXgmYVSIQghwn66OI7QdjuqrbHL0vzTnndKZqAi4q89CIXBVV7ms2/U/w7f82PFgoJux2gTzB0YHGIO2nRpSrhBThWNuKl/hP2RguMNJKAtLpa4VCgwzwzRVIporQ+bFStIgcfzscPB2uQ28709rB7bJDZyP4DrFPaGkIFRb11/PutA9aoHF0WunB+AAGDB7VZShTY4DU= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:GDKLlDLA1gx7EkFQ1RHHSBhHsj7fAEx2TZ8iBRQvEJXn7zPoGHGC9tufwJA4ymSVOX/upy60pT0QtZYilJ1IuUejT0xUpltjJp3V6muASRIIWIPB0z2o4lwARhUIVDb02AT6fM7BrunGpc1penMYX6uuek+ncIhgYtjsWmInVXgj6KfAlj9XoM2MH8XOSzBzCmQnoOr4gW+WFTX1OKKeWS8q2hNh6VldYuiwzstrWOVMqOKOu0BTLYxsCMMITd9l7Th/Luki+1g9dYp+LPjWpR0y+DpKLioY+33+iR4iQo888FctFOnUDGkyBhhGsR7eELeWe6O2eFqzgWH78jxM/7z62318QJbUwoVImNBXPTsYihkU8u7jPdKP4x+TeDM+dEwpc3vVixrfmdZC8PXDGSHmhPn1EZ8iHV98I/3sf9jueAUCQr/V/a2sk485h1UP7mb3pupOsoeB4ET9JlAiJxGb4+awKJn8LlcY0BND7UHhOTVIdfjPF0Y38jN4frLF; 4:YcZ2c1Ulwzc2MzZzcqEWR071OwzAeBtrARWLVIV4H7u2W4YPZw5AhxpM48wDAih357FAiSJVc/gZlV11Lfa5IUD4mHTjy9RE7EUnqYYoQh0nrRszPBy3uL9ioAJNvyiZS+adcnf5aqY0UwVnb//Ha4iwo10oj6o/RrzPPpEkO2w2/l5IhfjpTp5co/f7YUDaXiBj4hWFSoD+h0Ht7UTOa/5qnyW3DM5Zj/2yXQ9Csd5GUZOWK2rGBIGqZPN8b33bNFCoYfXyv0lBbPo4+X2ckWxuLVd3xsuQr2TlnOpzTrRYQXnUJPFML4lZYmyWaMelPLr6Rr0yjDqmiUL+/P4nuJb8pvFKmcrdAL0caZD3QEw= X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:bMic3gxIEjRSF5iJIasqBignxXdqlBMoki4/mlMsC?= =?us-ascii?Q?GU2Cv5V0hHSXd1u+ZiWc/5mgpDV7GwYq56fT2Dz3zC+IsWdeXVbLulFPwmBp?= =?us-ascii?Q?2KVlS/EXDs1n2TaaGnhckE2ozW5Tj7Lh7ETq0bnVeUtPK24jiayZ4FFNl/rX?= =?us-ascii?Q?Z4FmbCqmSIKWjqi115gXTeMJ+n3jUZhdv5dPfkeB+K6Y18uXJ4jva3wQmWNx?= =?us-ascii?Q?Muzwldt2ejzVjZRNuyOIFVRBHG2dLnHg+PCM4ZEklK+zFV8jhafC1CXGNQuU?= =?us-ascii?Q?yyuhdmlAxyPuED3cwplX/Jdc4DBtZITTEvkkanAqi+497kXMt3QscpeVaPcF?= =?us-ascii?Q?8jhVLRBXXzqj75IH7lNanDLjgKfnpDPrfRTOFLtRrQke35PSDmnBu42DqkVU?= =?us-ascii?Q?BBa5/8LbTRCCsHr5wqJbtqvpGypjW4KoJx7bpXWPSKOUPrcWEPj9SOl/m85z?= =?us-ascii?Q?kfnoevBuSVDFYv9HLlcVzlBOhyjTOXOI+9luwV+ZMvz03EQt2VSuwddoX0GG?= =?us-ascii?Q?inIcP9tC1p+rxGLD8kPu0LLiMfvsOxM1YwBCOW1dNK3qpiVHsl5siJlH9Uzt?= =?us-ascii?Q?o4ivQqr8jdB4A5oE22wdFRfVdTGnbEDKKGM99eDwusjIY4iH7BzdK3MNWViH?= =?us-ascii?Q?PtwHEsdqamPbBC+qCh2HZ19lyk9VO/AVD11w3TW+AhNB2xVuFNGmcm5ufoaA?= =?us-ascii?Q?2tbRUQX+w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uVwJn2O1UjEqCtH0cGSA5hSsJCGxDqLfSPQJNyXnlt+ENScjtl3KGw==; 24:zIZx538ofOj2jLHI+XZJupq11UUQBNB7YjhlG9Pq1MiZYq7lW3TYVBDnRSzGTiMNZU2ck0WER+BTozlFrJ6yhS81KZVK0YQbDm/y3Ae5pU4=; 7:uBP2ed7ejyDiqzpQNydgeSmrcx/t/IspHk6PitiZ6ZLCQki4JJmEeGKHB+4whazEghzemkEDemTyn/ledJq4eZZ5n0qrk/SrfA+p7Af+MnUA/WcY0ssxdwPJyh8UBi5tFCuy1q7lmEU/meWUeeFC+pzb3EIYnfFpn/RYmADZbRFf+/azZNzoVOp6PuU6JIaqRlXHwOFDwb1dqc3MU81DNm+OcXkXj2jaWQN070XdYY8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:dXbCuxrXCK3pFfbFENAWJuEZiYfDLVcC+umslAqLlIYkHuW+NDVIO1AlCxbYhAriJaTL+R66uDd2Km43aYsBCuqK9usA3qPEAtPYYNI6xbpikVFw1Esw7bCXZqH32gV1pDYYoJQWqwweGkqvBMYVU4pfWSyZG/XI0l3y6nu6iygmRQ2B49HmLW2kATnThrENHle26LHvAvE2g42UoZP8J2eXAZ9j0KZRD9Ju9P/I79abvr+Rok66dPzmmjXcPhwX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:06.1853 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 18/23] OvmfPkg/VirtioNetDxe: map transmit buffer host address to device address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update VirtioNetTransmit() function, to map the callers transmit buffer host address to a device address. Since the transmit buffers are returned back to caller in VirtioNetGetStatus() hence we maintain a simple list to maintain 1:1 mapping between host address to device address. The list is consulted when we return back the callers buffer after data is successfully transmitted. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioNetDxe/VirtioNet.h | 17 +++ OvmfPkg/VirtioNetDxe/SnpGetStatus.c | 29 ++++- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 119 ++++++++++++++++++++ OvmfPkg/VirtioNetDxe/SnpTransmit.c | 30 +++-- 4 files changed, 184 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 3efe95a735d8..ac75bdeeb449 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -269,6 +269,23 @@ VirtioNetShutdownTx ( IN OUT VNET_DEV *Dev ); =20 +EFI_STATUS +EFIAPI +VirtioMapTxBuf ( + IN VNET_DEV *Dev, + IN EFI_PHYSICAL_ADDRESS HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress + ); + +EFI_STATUS +EFIAPI +VirtioUnmapTxBuf ( + IN VNET_DEV *Dev, + OUT EFI_PHYSICAL_ADDRESS *HostAddress, + IN EFI_PHYSICAL_ADDRESS DeviceAddress + ); + // // event callbacks // diff --git a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c b/OvmfPkg/VirtioNetDxe/Snp= GetStatus.c index 694940ea1d97..d532551456d0 100644 --- a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c +++ b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c @@ -5,6 +5,7 @@ =20 Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
=20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -47,7 +48,8 @@ @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. @retval EFI_DEVICE_ERROR The command could not be sent to the netwo= rk - interface. + interface or failed to map TxBuf to bus ma= ster + address. @retval EFI_UNSUPPORTED This function is not supported by the netw= ork interface. =20 @@ -126,8 +128,10 @@ VirtioNetGetStatus ( *TxBuf =3D NULL; } else { - UINT16 UsedElemIdx; - UINT32 DescIdx; + UINT16 UsedElemIdx; + UINT32 DescIdx; + EFI_PHYSICAL_ADDRESS BufferAddress; + EFI_PHYSICAL_ADDRESS DeviceAddress; =20 // // fetch the first descriptor among those that the hypervisor reports @@ -141,9 +145,26 @@ VirtioNetGetStatus ( ASSERT (DescIdx < (UINT32) (2 * Dev->TxMaxPending - 1)); =20 // + // Ring descriptor contains the device address of buffer. + // Lets unmap the device address and get its corresponding + // host buffer address. + // + DeviceAddress =3D Dev->TxRing.Desc[DescIdx + 1].Addr; + Status =3D VirtioUnmapTxBuf ( + Dev, + &BufferAddress, + DeviceAddress + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto Exit; + } + + // + // // report buffer address to caller that has been enqueued by caller // - *TxBuf =3D (VOID *)(UINTN) Dev->TxRing.Desc[DescIdx + 1].Addr; + *TxBuf =3D (VOID *)(UINTN) BufferAddress; =20 // // now this descriptor can be used again to enqueue a transmit buffer diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index aeb9e6605f0d..5e1c610c4a18 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -14,10 +14,29 @@ =20 **/ =20 +#include #include =20 #include "VirtioNet.h" =20 +#define PRIVATE_TXBUF_SIGNATURE SIGNATURE_32 ('t', 'x', 'b', 'f') +typedef struct { + UINT32 Signature; + LIST_ENTRY Link; + EFI_PHYSICAL_ADDRESS HostAddress; + EFI_PHYSICAL_ADDRESS DeviceAddress; + VOID *Mapping; +} PRIVATE_TXBUF_ENTRY; +#define PRIVATE_TXBUF_FROM_LINK(a) CR (a, PRIVATE_TXBUF_ENTRY, Link, \ + PRIVATE_TXBUF_SIGNATURE) + +// +// List of Txbuf queued +// +STATIC LIST_ENTRY mTxBufMapList =3D INITIALIZE_LIST_HEAD_VARIABLE ( + mTxBufMapList + ); + /** Release RX and TX resources on the boundary of the EfiSimpleNetworkInitialized state. @@ -63,3 +82,103 @@ VirtioNetShutdownTx ( =20 FreePool (Dev->TxFreeStack); } + +EFI_STATUS +EFIAPI +VirtioMapTxBuf ( + IN VNET_DEV *Dev, + IN EFI_PHYSICAL_ADDRESS HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress + ) +{ + EFI_STATUS Status; + PRIVATE_TXBUF_ENTRY *Private; + + Private =3D AllocatePool (sizeof (*Private)); + if (Private =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Private->Signature =3D PRIVATE_TXBUF_SIGNATURE; + Private->HostAddress =3D HostAddress; + + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) (UINTN) Private->HostAddress, + NumberOfBytes, + &Private->DeviceAddress, + &Private->Mapping + ); + if (EFI_ERROR (Status)) { + goto FreePool; + } + + *DeviceAddress =3D Private->DeviceAddress; + + // + // Add the mapping information into internal list so that we can retrieve + // the HostAddress from Unmap(). + // + InsertTailList (&mTxBufMapList, &Private->Link); + + return EFI_SUCCESS; + +FreePool: + FreePool (Private); + return Status; +} + +EFI_STATUS +EFIAPI +VirtioUnmapTxBuf ( + IN VNET_DEV *Dev, + OUT EFI_PHYSICAL_ADDRESS *HostAddress, + IN EFI_PHYSICAL_ADDRESS DeviceAddress + ) +{ + EFI_STATUS Status; + PRIVATE_TXBUF_ENTRY *Private; + LIST_ENTRY *Link; + BOOLEAN Found; + + // + //set Private to suppress incorrect compiler/analyzer warnings + // + Private =3D NULL; + + // + // Iterate through internal txbuf list to find mapping for a given + // DeviceAddress. + // + Found =3D FALSE; + for (Link =3D GetFirstNode (&mTxBufMapList) + ; !IsNull (&mTxBufMapList, Link) + ; Link =3D GetNextNode (&mTxBufMapList, Link) + ) { + Private =3D PRIVATE_TXBUF_FROM_LINK (Link); + if (Private->DeviceAddress =3D=3D DeviceAddress) { + Found =3D TRUE; + break; + } + } + + // + // We failed to find mapping for the given DeviceAddress + // (this should never happen) + // + ASSERT (Found); + + Status =3D Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Private->Mapping= ); + if (EFI_ERROR (Status)) { + return Status; + } + + *HostAddress =3D Private->HostAddress; + + RemoveEntryList (&Private->Link); + FreePool (Private); + + return EFI_SUCCESS; +} diff --git a/OvmfPkg/VirtioNetDxe/SnpTransmit.c b/OvmfPkg/VirtioNetDxe/SnpT= ransmit.c index 7ca40d5d0650..f71953c92c99 100644 --- a/OvmfPkg/VirtioNetDxe/SnpTransmit.c +++ b/OvmfPkg/VirtioNetDxe/SnpTransmit.c @@ -55,7 +55,8 @@ @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. @retval EFI_DEVICE_ERROR The command could not be sent to the netwo= rk - interface. + interface or failed to map the Buffer to + bus master address. @retval EFI_UNSUPPORTED This function is not supported by the netw= ork interface. =20 @@ -73,11 +74,12 @@ VirtioNetTransmit ( IN UINT16 *Protocol OPTIONAL ) { - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - UINT16 DescIdx; - UINT16 AvailIdx; + VNET_DEV *Dev; + EFI_TPL OldTpl; + EFI_STATUS Status; + UINT16 DescIdx; + UINT16 AvailIdx; + EFI_PHYSICAL_ADDRESS DeviceAddress; =20 if (This =3D=3D NULL || BufferSize =3D=3D 0 || Buffer =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -144,10 +146,24 @@ VirtioNetTransmit ( } =20 // + // Map the transmit buffer HostAddress to a DeviceAddress + // + Status =3D VirtioMapTxBuf ( + Dev, + (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, + BufferSize, + &DeviceAddress + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto Exit; + } + + // // virtio-0.9.5, 2.4.1 Supplying Buffers to The Device // DescIdx =3D Dev->TxFreeStack[Dev->TxCurPending++]; - Dev->TxRing.Desc[DescIdx + 1].Addr =3D (UINTN) Buffer; + Dev->TxRing.Desc[DescIdx + 1].Addr =3D (UINTN) DeviceAddress; Dev->TxRing.Desc[DescIdx + 1].Len =3D (UINT32) BufferSize; =20 // --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150349106879370.85822376809881; Wed, 23 Aug 2017 05:24:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C503821E47D4F; Wed, 23 Aug 2017 05:20:43 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F8AC21D2E628 for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:06 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lAByullkl1Yu54Dy87YEiZn512TqWXLpbA89S6iv8/s=; b=W4ARi3bqzit2hBdpCyfjcX0ZefXjxe+sxmCHKdv+HVvI4utBhI3DrgJctx4igz/dIK5qzCXC8XN9JWIxBcfjg9Bt3BTLoi5P/DZ1Ah4l+Q1A/eybz0Y8zElmfF1uWagGb2QyvMANIkX/wCO7vDMPPErrPHTCkFi15wh77NdkOiI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:43 -0400 Message-Id: <1503490967-5559-20-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbacefdf-2b62-4246-1ff6-08d4ea21b5aa X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:2sXFsFnWcqdVr+g7CwpDslbcj7lbN+oTsEYCC/0MpjA6mSdt9b2ySI3RmT97ph148E8gGiRTwWpfobmn43LylHyvaYF8XdCM5IkkrF0NmU9vmCgCcumkDnBHjPceWwbU5bH7qYXZTgpwHNoVx0fCZouZlrJkxj9XY7s3h93sG93al/zSOOuoP8MOFRBWzguglTYhtpEh0or4ymlyfa+6lQ4lmVjGxwRkjR8wE89HnUijTJbwAmvx1xLYYUi6vf6S; 25:H5U7esnSr9ycPIh6fG6whwhWPMbVtDmjAMfSp+C15b6PhWfSDradNv7afK+no1hGfFyfthUWWCPn5e8WH3ucsWyeaTpPrJRyPnCDin69llb5KwyaVOROvCNngNX1OPVh/AiKtld8FvZl/QvjVkRqBTlj2noTlhuaofoItzZpPEcW/ilieUgJAqWDJUOg/vbAyuMrRgasFvpwb75QeEIHggKLGxCul2bCjoLEzrB6fpGlSmMFzOaGv+uw5P0raAaMt0h73Cpt7BmprRCid6ZaGAtDyFJhtk+udp4Xt5aQkbPoWrhk9A8toe9DONKi8KXjBQpZoZ3OIZyHRu/rVwe7qg==; 31://mKAO0yuWSKHNFChtBLBWcWvUj+WQvl2AjaDzZQXMPwaPAGRSVszs/YqSXgIb0jwr+Mk6n1HJURVQxhicbxRLYXgVCZkvx3G3SDE0FGXrXRGQ04ForJV8H+ktxxjrAuk//A2a48KhG9ewxpuZFGkDlcPNvV+XAWf3lnR0gKv0IlB+m3d+dPDVrlr5sWqUxxpTnVHKsnvUraPqXadd1AMe0/qfqF4w+Sz31hp4vbyns= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:GZz7uqOBS2UCYZwJalpD+H10RYcIqSPjBhPyrUNyKZ788bLJa+e1LrI1sLcmsjKLOb83rfOeNeWL2vRZKiVhEv2N+OjKvlKlD71HCYj3czevbOE1Mq5bxIlov7WDh96bdT/vmae/3DrvFDAtIcpqhqn4v3DJpG55ZKlKwyhRd80yBSml9fVfydE8ycg+wXUhDdIMSK2JKXgRi6xNkcchI1f+9Kl0mO+n27ss3O/+Z3LsiGOwK8SkbgvIF2gFhKcrSYqr4lRb6OZ1HSOsnLDiDze3jaWLm72SqZQXhuaJYUHdzydafKCULvHa1XZ5hgnOyhPZLL1wllLP4dxraPbv4kya5+jQ8fAlzz34C9UndA8kJg9ZDQNjLtQGWI8zTvYZRjVEb6seREiUKX1sOaHSNb6FJjTqyOisnYvdkuBrXVQJ01F6Xoei1VV/EHkUAHwR7xsH9SY9DJu8Cm5MY5zNPpI5EE6FrrQ83ayrEq95PPbBTxybIDcHBtb42qLEAWqH; 4:puk28Wxcgh9aOB02jGcWvWhj7yUZMuAvq5QlokGLAozBhZKHlKQNBe2eWdsaUzBeV3sel5DPT813JEovlYciPED6FVLYWYqOmK/iKFUOGaZ173slf/e+oS0IIaRRmd9AKVrS2Os6BoGNumsBxDQILND6j6vJWXmxvemCx9viVsv4trKzhIpHc0PnuvJTuZ9+Pktm0WLWa9EbS4v98nSakIak03Leca8oJf/zSKUenwFvQX/kQXjxfxczpe73h6AKVbpV1pQkQuUHci3Rc9voUgV8OJ1ZRfZUh4Kew5FB5V9n/b0AdZnWi2Hyr24UcNZ8nVQB0iLM6q+i/R5ibYKXUA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(966005)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(6306002)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:Xk83u6rnzQeWzixdSHFhFFphLwIV45Gh92CaOqrMg?= =?us-ascii?Q?61L8t/zmw5wkJGubbWdddD9CJYLQCnnXyyjJJrK571pSgTMBWjWF81XxAiXb?= =?us-ascii?Q?bbOaBBQ6H59z+RipNw+jGEJOOENa7CtPPh+AkK1b6DHD9BSehR8XqDdFiQ8w?= =?us-ascii?Q?vKQlVtaG+i6cTKYB+pwqWRe8FwtAF6omg6s/YKapvslMxGQujRIjhJN/bjLY?=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osticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:/TZe0OKRegcBTpf9YUiVETqDG7Uvr038JxW3s+UyB46d2Lj93SFPih/yFXvFxHwqZ/HvMYH/1SUHf1Lxk8mAyySAJE/FGthW5Mr6/LViV+ZcdSktsYl0922pdg0hCVwWFefDbZR0F2rlibFqWCQ2IkzXbMlQsBr+MycXcK0D0+rxrx/Glwy+nXFiM9wTx4ALDNDnfxWD6KhwdxaCFPnDAegUFBi+J0qVvwQ1ybplbkyi5VD19tZFfEfJtJtYzHkZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:06.7009 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 19/23] OvmfPkg/Virtio10: define VIRITO_F_IOMMU_PLATFORM feature bit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This feature indicates that the device is behind an IOMMU that translates bus addresses from the device into physical addresses in memory. If this feature bit is set to 0, then the device emits physical addresses which are not translated further, even though an IOMMU may be present. see [1] for more infromation [1] https://lists.oasis-open.org/archives/virtio-dev/201610/msg00121.html Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/IndustryStandard/Virtio10.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10.h b/OvmfPkg/Include/= IndustryStandard/Virtio10.h index 4c9b62a3cf59..c5efb5cfcb8a 100644 --- a/OvmfPkg/Include/IndustryStandard/Virtio10.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio10.h @@ -2,6 +2,7 @@ Definitions from the VirtIo 1.0 specification (csprd05). =20 Copyright (C) 2016, Red Hat, Inc. + Copyright (C) 2017, AMD, Inc. =20 This program and the accompanying materials are licensed and made availa= ble under the terms and conditions of the BSD License which accompanies this @@ -81,6 +82,7 @@ typedef struct { // // VirtIo 1.0 reserved (device-independent) feature bits // -#define VIRTIO_F_VERSION_1 BIT32 +#define VIRTIO_F_VERSION_1 BIT32 +#define VIRTIO_F_IOMMU_PLATFORM BIT33 =20 #endif // _VIRTIO_1_0_H_ --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 15034910750461000.4110648279341; Wed, 23 Aug 2017 05:24:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 08C5521E47D53; Wed, 23 Aug 2017 05:20:44 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A211F21D2E62C for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:07 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YY+vASHcZkg+9gChPWo6DhYdrGP7E30ALMAIDu7jtDo=; b=wEvOi3BT0A9PjDEKn3ymXZayR/fZjrHGSEzIZRyeIN+k7taz8qCeHcoCidmsVsREiANWpLOpL864wgDUVIXHUrJhPK5mJpG4mWnu44NOAANzXsjoES8fiIlbvNTVFzdP+RDr9BCNuYwfhQjGVLgTG1vYMAJtVDbgcvgF5P5SNsQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:44 -0400 Message-Id: <1503490967-5559-21-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cfdf56e5-718e-414a-a66a-08d4ea21b5f1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:idZSlaXF6wZYjKwA+aB3tZW9mkd2MsaFe1PxXUQRTRw0YPdzy8hHC6paBeRT9S+yGOeirISyoF6o3e6J0HC5d2spQChShT0uVD9qLNjS2u/oopxy75isZukz6NL/1ovZupL/8hEViLyW580Egq6J+RPSUkBw6zlVaSrXN+b/h+sM2eFNk5me6z3WcD8h8NwXSNjkQMEavHGenr82nwYr/KK//dO5XkjM3FWKtlRFBOkiU6vqCgt7ALTXM2vwJWaE; 25:qSwlPpOIEPmSWqGVDOngtqKN1wOCn16SbmFXC2ZwcNxRSxBC2UuT8af1eV73Nw7HWaSiZkxvi3dTU2bO50/0gpbSDwy5h4XLkCcd535CTNv/Y18l3yP2HjOIrG3X7SBDL4huSpMjNwsel6GqHvDBfQ/H7A85VN+cLO3heOaVtI963VvBIHP84cAbmY4mYn5Y6Y8DHFkMvrRCwmW+6lubUiLvlbybZ67mItLZKQMuaAjRZdviMc2M627F4HJkIQyGcqfHo6zTh+HIuG6u7RQ+061OMnzx7rLfvBmu6HK7514kbBSp63CjDS7am/gL3kVxk+GwWw2/ncxfIGxWaRlGRw==; 31:RsF7e3aSvw8wE2Ur5F+Tu/ikXUFN5uR502lorMr9IoEgRbpbRdw0gzJ+9/yxe4S4weos/PNDNKonPNF/0XXGiPn5C+COjngnFUF9lsG5PdEiblsC2QJjRMBGihXBzvHQSkVUg3kWMIpOqwJBtHioGSlZbwUTszYX1q3Sm7zqJftncVrA5POc28Xs1KqfOdiIu9ObKyXpEwBGLQxPECuYNMwIeL26x/p0zhOjziuf5dg= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:KHduew1PfgmKt5SkAlU724MWc/uwnf7WttPTiu/Y6fbe47md4sq9yvW9wxuFvNuhpn8Q1jDs0knWzyRUNVNFGeXemCq3jCZGmu0M7V26pQqmhmup+oYF2s15/W0Avjwjs2V4UYp7e7LYQ1BBFE3nFK5SPxOJd9Ly1X6HiMrb7USqyscg4qqxAmtZuIHaDLNiiVdbxDSP9ZNm9SBObTAA1Rqw0Qlpp+HRAOOTHmlsMaNZkptSfm4p67q3lA+6EvNMnil93egeMMjBc7UfCdQ4WqEdxJgu954wUqx04I3cMk2MWjUov3APn2WC/uhTPYHCKVoJsHMYBm3bFgRpIigl1RNZ8nQAnc+C4S6bZuYJk6AjlZ1PwYS2GHu9ohUPN7LpLJHcwLurKDrXjZy4oaRHGftKulWFKHWESmOZcmCo7h7hXI3stGEdARag/6h3XojV6+jkJkJKl7rt2Qak8me8tCKeUc2vp8AEISGSq2jXYcbC5X0K8Frkrt6NkjeYN0K+; 4:QptHR8JyetpVWwC6LD2Gt19j+T9Sl3g6M6M9dMZSC/mQ1dHbmfpyg3AUvGt21frvX7U9mK8pKnd/8KRMUj4dwZgk827UcveX8Hq8rVJ+wb48YuNqD1QfRp4r8mVdc5KybiqmrvN/y2sHatfe/5GpA56yeGLJQQvqnfYP/I7LN7Z9yKD5x4yrkS4Ao7IYkb3/W7SueLQt2qbqh7hnKeaXjELnyvCqmL36gwdPmDxT9RTxQAf6cpWQ7A5sxu0RAg2uqtdsjXcAUPixr/M1HNYNCVkcfmShZ+2XYxuzL8hoehxZUAHB4Nbo0YjVd/8RfRZeZcCYdjXZY0+Du0WjopSc6g== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:4gtdHgNC3YJLyCiNp63Eo6Gz41j+tEx4ELUgustwG?= =?us-ascii?Q?ZtVdZfcgUYyR40H7Wk0DG9SPa1u6ijq2qud+1DPG00POGlonHCYiCbskyTyW?= =?us-ascii?Q?BrL9CT131DcYRgHNdAd+9Up5UiurW9sWHWCDE9V27mpLqaXjrO2RUPHlqmgV?= =?us-ascii?Q?ofa1dsrDL+cOjF4Ax9pyqtKA7AVZ6CLSodD1QrE2H6qfpYMGwAb/Jeyt6Xbg?= =?us-ascii?Q?kvxjyXk4FWLdB9wB/GfUwXk4yNn8yzugXS5+YSrAAK/8zuBynYay/c2siYbb?= =?us-ascii?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Vk2r7D2oVsHBu52MviaO5cGwZAN/cyzDMBNbVD+rdj1QUpoGEGw1ul4/ejfAYqThD6VMxmpsuFJAXjIo42Zk3qtxU4nMl6N9uCVMZR1fJiVYb6pj0ZpbYcLNSMudG5Qd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:07.1697 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 20/23] OvmfPkg/VirtioRngDxe: negotiate VIRITO_F_IOMMU_PLATFORM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In previous patches, we have implemented IOMMU-like member functions in VIRTIO_DEVICE_PROTOCOL to translate the physical address to bus address and virtio drivers are updated to use those member functions. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioRngDxe/VirtioRng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/Virtio= Rng.c index 59f32d343179..32512d882f7d 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -278,7 +278,7 @@ VirtioRngInit ( goto Failed; } =20 - Features &=3D VIRTIO_F_VERSION_1; + Features &=3D VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; =20 // // In virtio-1.0, feature negotiation is expected to complete before que= ue @@ -359,7 +359,7 @@ VirtioRngInit ( // step 5 -- Report understood features and guest-tuneables. // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; + Features &=3D ~(UINT64)VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto UnmapQueue; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491080289954.5721808985421; Wed, 23 Aug 2017 05:24:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3C34C21E47D57; Wed, 23 Aug 2017 05:20:44 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C770521D2E634 for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:07 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KhtIB3qIwY4G1o1XoMA9cKFwTTtE8fijA4hbyYVSz8U=; b=5Az8bBN3pzUvSURgfjGBX8gjcidxlGYiKmuhRAPjEgAZ6SG4Zl4TyZ+NmyW98cpXWWgxeo5Fkp1ti3ykiIjGs4Qc4gYmQzulK6/lRwIFtVAUoxjpBQ5gv2cniRv8vCvlBKuI0V7eimjdlIfSNhfSRWc9F327NYxrCPH6ryduFrA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:45 -0400 Message-Id: <1503490967-5559-22-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ca3bc9b-d94c-4ee1-58f0-08d4ea21b640 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1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h5ovPLKctYGYBSs1WBi+QEq6bKI6ykYkOVH6/N9G/+ez5yNE6QsIZz0K2zLPDzR3xE3uJug3ZXunNhflusaH7vXWdN39EvRRqOf/Dm9nIcZ8V05yvr3K/0kudUYybtnQVu/h8fnnLj4Vfppt6Wr/lqWGACDMxUPSA/8tA3Qk0+O+zcQGxVxiTcV3QK1uv0goTMQAuwKX6jsjspeeL3kgJwGF6bMbBBnOBsvmWxu0Kknm9jogR2zAsCII5sJujLHr/dup3ZjtwrurntvRwhved7SRokHniATBKBi4Ctzled81h95C37B9SkXljm9ZxI/s9EPVHCrCbJggBd+WgFl6LOs2YIiMPc46schYlgwDPcW3G7; 4:H8QfHQl7kxuSU/GCxiqUEmBIQs8uhap+LRDjXwbYU653Ft+4yTQvTk2wrDGSqQ12D67R4j19F0W/7JmyEsgRS26Usm2X8qJ0T6BfeCb6heuEnu21QE85SpZaSMN5+lDFXZedbe+a1E2yf2Q3cYKa6tr1aO+4j9D3WLNm9bkw1OHjnAbXGY0BzClRv00zAga0odsD5a0R0cBH61zedSnR9QeTy2EEt3wkPn2qLm5yJ9RCKF0CnO6silJxxlLgkGRHf+juXotCkA8i2vASr/dbzExO/1bKtzDH8EMvB70fWe681ztHVxmqmR2UIkDt+hXZUDa4Zx1byjQaDEx3+mdpKA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:wVAGWgCjQcQz6mUxXqZd1ujj3lXwMUihb7Af6hXrc?= =?us-ascii?Q?W6f4mkcsu2/C1u5pB6KFbdFX9z0wDdDVIFp/g+bpO3qpEpqRyCK+xGOlWtoe?= =?us-ascii?Q?gAlwts8ydvuN4p418dgp1RCdHHO9Tbe++tbj42DLRq0hkSie0O3eGMhgH9Xt?= =?us-ascii?Q?sAT9DmGAd+WE2b6HRaBMxY7QR5QHMuQXqJMyt4QykHVa1X5hfSJzoRpFSiWg?= =?us-ascii?Q?yEqRH9nQuwZaHyn4AVA2uF9RjJn2XrAd3hLnYskPxqr8W2aRErAdSzZ03Ol4?= =?us-ascii?Q?eEVlpPB9/x1bwE0UDVeABbpeibWUYMHCrrbsl5SKpXERgi3isZKzWfymt115?= =?us-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microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 6:VcNjo0Xm3880Zw7hTa7a0aw7a14nnbWH3p48NCtP2G571uPeGwNHLGqBeR9gI36QwwSecsb8bp2TmcqSN1a41WFCWKa09/vYPa3pPlvgAZzHnZ+bYfFlWM5PDv43WQDMJ3QkR3xJIhcQEJENYFdS0hdm4IKJiJlGqw6kAo3OxyaP4MpPRkL5SHCElYnjNM15UwxW/3dJmZBbakSsrsYHewq4pSLuQb1BQWQLZey5KhpsDdwsjdMl+Ea8ckOl9bFgN7+yczKjohn7uZBpn2iYVyI4c4onyn17u3qKHCnWs3vaMspUFWNBAyq4QJt//VXZBuf0bxUrxY69/1EfXbapDQ==; 5:guNXFogt5xtu3dw/3b4ad7TQNv+GJ1P6S9fN1glTnASslOamgKkFsqWQ4S++7YvU5VkdHSx59XnL3kWHLotH3DGRjpNrEFmwHfBUCudFL57NZrfRBZpjZ+56ps0HNihh1XoH57URP9IUyf9lMnxE5w==; 24:GAI7N8doipXAsAplOuyKM1/vUPMOOcB7dqwmfvlF37CTq/qxJXf0jUq310Nm9UVvN9Np0dqBjnR8xyua7n//6kImT0ljE7TuCiQomIDnRZ4=; 7:67PvkvPdwxyVnvXHxoM/OT+lgFlqvQAsWmIHjBICnrvahmBzweOxOSKJNV6QJLa1Hac/5GhmzzAvFKXLFs75p0hu3oJictX+FNg5cVjgXkimC8xCPh+QQxXqsOWxY/HIsQT4FiLK9AxKpU7jirCF2vqG0DlnK8AQpiGfPQ5pe4sZDuw+0NuUke/OECTqb7eupGjDd9fQafZp6UWQh8Ib5MZ2278gAk90hDCNVEm1wNE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:ld2XoUIW7IEXaj1w4kVpBWUhbanardNLVKwjRCEno4pwFhMBdcTZreTqu4v2Bl39Q4X2Uba7bFHoT4jE83x+Lo8xM6ySs3bCEVUtwEjO/G3OOtwnFrdC0Zuf3FfXLDwRcsPmvsdp9GqwoYK/P92y3bqAc152zMqpgtFE68GfF14Y8oMqHGS6T1zHqnL6hOJzecRhEJF6F8P9pbov+/tn8OHf64PErcusLYXhhuSOw57WvzaJjW2YV04nWrq69vG3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:07.6853 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 21/23] OvmfPkg/VirtioBlkDxe: negotiate VIRITO_F_IOMMU_PLATFORM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In previous patches, we have implemented IOMMU-like member functions in VIRTIO_DEVICE_PROTOCOL to translate the physical address to bus address and virtio drivers are updated to use those member functions. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index e23762743f75..fa6c527c0d28 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -824,7 +824,8 @@ VirtioBlkInit ( } =20 Features &=3D VIRTIO_BLK_F_BLK_SIZE | VIRTIO_BLK_F_TOPOLOGY | VIRTIO_BLK= _F_RO | - VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1; + VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1 | + VIRTIO_F_IOMMU_PLATFORM; =20 // // In virtio-1.0, feature negotiation is expected to complete before que= ue @@ -902,7 +903,7 @@ VirtioBlkInit ( // step 5 -- Report understood features. // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; + Features &=3D ~(UINT64)VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto UnmapQueue; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150349108646791.83373116560495; Wed, 23 Aug 2017 05:24:46 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 72B2121E47D5B; Wed, 23 Aug 2017 05:20:44 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EA69521D2E62C for ; Wed, 23 Aug 2017 05:20:36 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:08 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=k2F49mUvzgSgld7mnxLQZq9ybHsDZiARHWSQkJZrFJc=; b=KXDvY9V2aSmhBTM4FEa/psxzKEU8YKA00c0nLvgsMCyPaegVkMqh495nKHZIsQjTeH61CA0v1V5ZwHXFUoVivLbSk3oS8lNTIL1ki2CtWjP/0bNKS5e839eQhrkFnlZ12Hwe55Ow5dN3rsvlNl5PpjnOBb+nkoZGAzE+2i6wkcQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:46 -0400 Message-Id: <1503490967-5559-23-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6b9aef7-f8c6-44d9-1598-08d4ea21b683 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:l5nzVSzbTyt9wBy7qWSx3+1X9E3UxSXlEePEvA9zkWUSVP/l3bGqMujoy8DqObamL5cCh/nJ80Vc92bdpKZD+m/7jgUNBHg1Ad+E+iZq79Nbd69wxLCrXPlNYNG+N2usTnv+e2YlSuhnYib25mub5oCzlV4W577BLGEv424Z70ZDeN0U4FPBlL464X0AOHn6OidWwwJkDiH8r40o2uUyyXcIfOP37nPCpWVOw7Uf8cOLQKddlT/r4jHPNQYnKSmx; 25:MN7L0Jem6NpXUVfGRflIP2dfnYBzB75Nxa2iUrmZ2wd5OFCFpnIteE8hwtp+e8UROFSZRGGn7HOHxQHD0dZIH8TlZF2vrpZE8DnMppxuPNRlOAY+1k78h6J0S9rT57oJUtNRXSRM48eQr0kt7HJhueHvLgngDyW5GhFi6DENDSKclv5JQLXsH1YTPlqm2ugJdhXWibkP5OQUj7PpFfmqjQzI2wy4xtNJFYBsPiprNm9J0P0thFaZoEjV3GDuZ9+zEos0hWwfVEx1NLHd2kKKsZn4hzsEnxjrM7OOeKFHhRXREhmyCB6cu2Gkwn0lIDCDJOjY2i5XwrPjFq6u0dR8lg==; 31:UcfJvdq8uQjbHonkXpAhBCVVLbWYpnNxJA3P0pOTz7lhMsa3i3fiaVUHzQa8U+XbdMp8vJNPDBlBJfoD58CxCVmoFBfoywILGoc2XZMAHolckaVWagRSvXjFhKVyTo25vY10yTP4dxM435vwdk3aalOHo3371haF48EwGoyKFVcE9fq0jKqufXNDQeAzJVDhuV3i67IKYcyzE+9C57+AKLltq8XsZD5QLi5ARvp1A6k= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:4axyKLosZQ0c7cJzFL46vtYChQd/qneKNXfmfPhZ1CEhnCiKmvX5aB/RXwcFwB3E7O6dTots10rM5V7mwewwqjTMKV32EbfZq1FRXnlg1bVGj5STQ8FEm0uqvyqmMewIzTj9nidJ5drp4BmHUPTUNZsgk7qnjZKugg+B1D+EtfrC3pr2JANDG3/wtiEuh6ZRuH9ziFDdfSow37GdmhI/mm6+9qdVA2rZ/MjtQm463JXtkr11p5fH6lGUZZB8kliVHj+9UWdaQOEbIUe7XlUCpV5sCb0OUlKW2Tchi3Pg+A0sHkD0WruzRsXG0IPtFop4c/ueedcjs2TbtZRNezG8yXXBpuUyDJ8vccdSECkYEVa67FeGivuw9tQBuOKK85Nlun92kUWm2WrPU9f9FRFn3S8egCFsALA9zZLGqUMyaZkgayupF/zjnBhjj3nMS4ria1VWht1pZtB3jniFqg2SEoe/CDl0alDYK0ItbuC2aRjVGr6LDj1HmKT5RxNA5VTv; 4:2V1f+hz6YC80cPiq7Yq4LVc/bR5yfz5QlsPwiCMvw36ZHkOjYxG01KLtydutXJ1pT1gtYNWJRMqH1dL76jgVDTw3bb1mZ9N1hs+VC86mUxb0zxpnJizEvbcpvwCzox/grtn/5GujBUObnuclOhdP/byeUCDuU6SrAJxab9Y5wI/WHXzGJZ3Kj6wjpKWl7cSZYxRghDTwJBAuLPntBEW76W3zRFWfMtReNIRMwHma1qIFqxJGG8i6MhWR7EBao1QxL+yZq3hOkp5GOc+3OfD6AnGFrAuckAmlHZ26jnuwXtZSMGR1d/T2rty4U2wZirOPY2EkvZ7i7drRdNl+wKNsKg== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:lpKTwPPC7gtd0sYfYZAsZeY112eeqbCqzu4c/JKQ+?= =?us-ascii?Q?A9PNWGhP7geQpbePsRf3eWnnQN8SabFf8GG3rmvzhrymGaSE0mLRdxfk3k5I?= =?us-ascii?Q?3uia3JoL11x0trnN5Cc6D25wNwWGW/O161Lta9pmtceewA4D85VbWQcd6YlV?= =?us-ascii?Q?i8ovNF+DnQ5tzt3+HOeu4NSmLF2BgD4yaQxWgiHi3C6WiIRO6Cz99CWPou4I?= =?us-ascii?Q?DaPZQsg+bb1Wng7s3myydELRaWAdDHeqn4FuViKvoC0jcERkw85iv0qxM5EP?= =?us-ascii?Q?f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diagnostics: 1; DM2PR12MB0155; 6:V3svOL+PifKp/w6aXM24Un4TA+1a3N6VVCd+Y4kR3Ezs/LMWFKDSJlWW1K11ikg1jm/e//RlpwTFvZZWI0GmnYtihOB40AaaBNx9qO+uc3CDO8ABakTGG8SUjStuQCXRFk/Yx9LLk+0xLh0mUSUIGnZyXxOsK75UY2eRfx+I/0IUxwiHgdoSOLrzX423gZC7R+kP8JdnThk2deXuN/f9TSIhwFbDAIIKx9Url6/q7snu8kA1BsuRHvZtQL7m808rrloCD2obP813KSb4qBLR5c/EFxJu0f2aiYt3aOOT9IKGkTLONl7xR7jOJ4PcQle1PrSJei+k/YkZMZbP/2DxJQ==; 5:GG9rchDjT+kTUOjbnkU2l5Q8l7xKTMZE613LO794by4JSirLeUSn3I3bjxB3MSuzsTWTSOZvguNBhqW1dP3Rz5hTHCIcnpC8XHGr4hRWLt68chlHOqxGyJxghHvzMoO2pgBAuuuRGc4aQ/00R0LgAg==; 24:yJyaXFvQjsJ5ephb46Gvtu76Kbw5yOVbTFD5HU2NjmL+pIrEMfxTJIfC9loraZsfyn0T/FwWr6W4qXOzBUfrwja7k0OxDTMs09LmuxsfIAA=; 7:KJgZm3UMBSuk5tQTKL3ERxQl7aoUXolQQfmVQu5W/7xk58OJMwKWms0cBb6C9CnHFtWT/H9EfzNV1DsrxQaTQR4UmYte2Ucr4eT5wOEp4ii5Q5fNZUFkHFl9oOHOWLO2rRUKP3tHGlAGUd3UvUWS/EOTIdmzx2JUctYke3pdESq5Qyrc5GQyuu9zW8d/U08DkWWbKI/NHa9WEYSufxu6HRkmOB1p/a1Uv8QpBVukau8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:5YDHhYBFyuqygerCBFg/lSdapIjLQez5vOKmQGHtyRIl/UwBjEV7U71X5thgbaMakJHQJDP21hEHgVvGtfqP8ABz+os5a9TcNO3+ox+OmasszqPsHJKOeUg/F1+Os2/YF7ty5xEEe3Sws5TbglsmPW7QkIFVfdWp6pTDKAqcK+ZY8EbAGoYX7tq4Jly4X2RktFmmEUrI5gkA+dsN0JDiWKulU2BS+uELPjrPbAc9GmmlhxXeDdERClakRw7HeM3K X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:08.1228 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 22/23] OvmfPkg/VirtioScsiDxe: negotiate VIRITO_F_IOMMU_PLATFORM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In previous patches, we have implemented IOMMU-like member functions in VIRTIO_DEVICE_PROTOCOL to translate the physical address to bus address and virtio drivers are updated to use those member functions. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index ed7fd1dd58a8..91a008b2caa4 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -934,7 +934,8 @@ VirtioScsiInit ( goto Failed; } =20 - Features &=3D VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1; + Features &=3D VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1 | + VIRTIO_F_IOMMU_PLATFORM; =20 // // In virtio-1.0, feature negotiation is expected to complete before que= ue @@ -1014,7 +1015,7 @@ VirtioScsiInit ( // step 5 -- Report understood features and guest-tuneables. // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; + Features &=3D ~(UINT64)VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto UnmapQueue; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:42:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491093526587.1747026059; Wed, 23 Aug 2017 05:24:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A830B21E47D5F; Wed, 23 Aug 2017 05:20:44 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 18C2C21D2E634 for ; Wed, 23 Aug 2017 05:20:37 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:08 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BL8utUKNh5PkzBm+YssswrjFN+WXQEHtPi03QYTshTI=; b=4x+F3GWmW2NT2gr7zrIFMSdwSI97R+3bomIa2eAv1Z46MvYRToI1rVjcWg/hIxgQEyGthpV2hvYzP7gMvkuTlOfBwYVpMejhIs7G0S7cR3clgX0MtWGdZqKR2j5G7ID079YcFKLRTAoSfatofAlA4bQ2QNun11U4ivOxMByZKFE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:47 -0400 Message-Id: <1503490967-5559-24-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c93408f-f0ae-441e-9c12-08d4ea21b6ca X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);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No5IkisaFmbYP/XXayq0aXEYJo+F674idgtFUhnyYpfkNVx90U7gacko9c6KOnsgSum/8AJ5YZluxze8Mrga0SlijAA/2k+FiMz0BL0N7dkh3Jl8XD7iOSwpgVnCzrjT+EOTQiEPmC7a5k9kR97LXlp22WnoDSuZ1gCY8oaWCIrLdr86gQw/X8BtGJTaGzaI8u3c7EIFj9dujkE6Twmq86jNtj+9YMh20cyQHWh/szryyotDvo1sIN5lZaG0Mz+f76eD775yFkT6Abc0H8k78Nsva70oQ6BSN2gfkeUssbkPopuplB3oS010GUTdEo64+yO2cluc6OUxdTWyaiNS23Y/r3ot5t0BCwzZv9FkCRdqeRVrsTFyHgZEOyE9S3b1Kly7sASDsglQMzkR+AgW4DNKx; 4:1H/9JEiV+hwV03xFt0Kcc8/DPd0s6fVnKKMRafy17QbM/jzJclMmc8LmXF/Nn0h9v6iVHsPlVhJANriM6ynfvjKQ6YCwe0jYKHLCayjJYOs6nXr6PMN9hhEXfsTVGBpLIFCvmseiwq4NoANiZcN8DENWjRWS6jKd622Usa2Iho+Tu9q3kVQSOO67uOvY7hzf8h6PxbewWr+ge5D2YX+xvjoYrnWuj43pUxmYXFRLnTKFX+CwVI4yXTngNZzmkfnNwSJhlR7cuSCXEKP9T6kOntu/bznu02KNHzTQjbRicxqpMQE7q/utRp8ETZQd/ohc8SSm4MrhiKqPTymv5DNCTA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:zCzx88ZXdNCj8y6P4DtsNQPKeiDE52RuesyDlThq6?= =?us-ascii?Q?9f+6OlipNZyGu09A3A5UU+kVHAoVBvDdTsKK8PDIZhGyqGPjuvg5HRzdTZOn?= =?us-ascii?Q?F83ksfSWwlYXuR7DN5DTeVVkB8Hi39okXRPen3Ea9S7rrWhyLE1Knv7fXabV?= =?us-ascii?Q?+dDmbAVhc8aJ+IFnzfap4oQ9kC8a/cT5KDBJn3KbYIOf7M0GJ+35l/NUrjHb?= =?us-ascii?Q?XOeXuZU6Lk4Ol9ehPxGPS3RvNse3VkMOG1OZqczPrndJAv9mmBN374s0eRSN?= =?us-ascii?Q?b7DGKyGz3NWgsRwAK32ez6ymhlfL5vdubYrSWqDPAoRk0l5/5g2xF1fg6AbP?= =?us-ascii?Q?zXtPGXeHf2Xslr8Iq/Z4u9N0ry7dFWuJNqr3eQmTLnLH9bZnpuBhgxw6iEiK?= =?us-ascii?Q?mLjhCWEheb25nBhsIPZyiYJoF610SMwSM6ysYgygDDWIbuK1XQDauUHBqxC4?= =?us-ascii?Q?5fsV2TeOrBM35HKJ6Zifh62KpkBasXp+llzzLDOrX13SgFgG4fCO4De2lFzJ?= =?us-ascii?Q?p/q7wBpqa+aE7T9U1jlfK7ypuPcelt864O6Cff5YFJtfyXaYMyRj1fNCna3q?= =?us-ascii?Q?gT1vH+ULMUsRDHnx6OsfqXpnRAe/ws4CRwR61qTuOg7MqpW+6mz3cxWsBE4+?= =?us-ascii?Q?hokaPF7sVN4vhjtua6eoyoTGXZNFkeqZNyCbdyQkZ45FwaGIPvkKT4gUvoio?= =?us-ascii?Q?TBz2Fae3XwqC5ZnpIV06nEqb7HuwGOBLezRdUyEMiF54UYEjVTxKt4UjpaM0?= =?us-ascii?Q?I1cS7AntvVza0AyPXTVwOarxbQRsI4/J2x1ym6g25umb8T4z+ru4fNVYLO60?= =?us-ascii?Q?Xr8dwe8/lh5UB/d//ZR+J9b7yelIlZe7oaHwPEe6HOit06MFrTi9tacJSyNl?= =?us-ascii?Q?jE0NJXAmHSVhRtx/Q3UUqgB8WnjHtKomlbDqXQr1fR0HFm1EejnVJapdb9bU?= =?us-ascii?Q?UOGMPNnDbQmeCRvyxO6JPycBzFnUIp508GKPYAwsngaQpm9/Y2jgJFj2GSbW?= =?us-ascii?Q?tDWXOtG34tOwCU/EX20IBScqSyfeLPEKdGFGgopiYWAA8GWnkogwNWmi0LMt?= =?us-ascii?Q?CGYdwnJ7g3+meirhMInGXKpFho5Fe/yhqyM8sVCktmL24LSL8Oo7t6+Xh9v3?= =?us-ascii?Q?zfnUzs+1HnqYEOSBesSj5tedF7LCtge?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 6:7IP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KF8fXwFd+K4wsCTUAzLdo1nzHISwKZEELSMbv4VTY0BQK3AQ+egsavKKvLBOYX5xlDzGmrYdOuHM2lAOKiLJlyJ6vdkBem+I4DyTjWQ9rmjjx/8LYQETNA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:08.5759 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 23/23] OvmfPkg/VirtioNetDxe: negotiate VIRITO_F_IOMMU_PLATFORM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In previous patches, we have implemented IOMMU-like member functions in VIRTIO_DEVICE_PROTOCOL to translate the physical address to bus address and virtio drivers are updated to use those member functions. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioNetDxe/SnpInitialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 3d4eb70aa630..750cea10abe7 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -551,7 +551,8 @@ VirtioNetInitialize ( ASSERT (Dev->Snm.MediaPresentSupported =3D=3D !!(Features & VIRTIO_NET_F_STATUS)); =20 - Features &=3D VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_= 1; + Features &=3D VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_= 1 | + VIRTIO_F_IOMMU_PLATFORM; =20 // // In virtio-1.0, feature negotiation is expected to complete before que= ue @@ -591,7 +592,7 @@ VirtioNetInitialize ( // step 5 -- keep only the features we want // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; + Features &=3D ~(UINT64)VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto ReleaseTxRing; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel