From nobody Fri Dec 27 01:54:37 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 1502107172032490.5596212820809; Mon, 7 Aug 2017 04:59:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4806821DF37D9; Mon, 7 Aug 2017 04:57:09 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0057.outbound.protection.outlook.com [104.47.33.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 19D6021DF37CB for ; Mon, 7 Aug 2017 04:57:08 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:21 +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=WfHJ+yxa5um498Rii+ig16TWHbTYW0QZo/yHsNlCTlg=; b=GLTI6RSIHJ+qvBnUvBt65esK/CARBu/256XPoDb0fT32E/BjKXJcn3jsUGVc3SWOQYPYtrCEQrpzpyE5YBe4ofZ4uOwyC5ICeuc7tniNPU4EopF6yGhJZzuw8CatBCIfdzLedAsJHyEeleGxVJgQjCBHD2oRqoRJ04izbCRNAeA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:46 -0400 Message-Id: <1502107139-412-2-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d22e2f8-0d40-4473-fef4-08d4dd8bbe03 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:OWpXBYOc8Qhx+1hkFyEf2O2yPX0IVlthGwA32JilVazmg4RorWsl5xrqcjmkXMacqDYFyMttHA2RZG2LM8VgPljXdOy3iCW6buG5rohY3+AoSdGXUsomP4LGDW3eZD2ct/Zo8lxm9jN7eOO8rFz1fdJ7zb6/qJtkRBdBjPgoIoL9ddh7CwXmoxqQPpc2QnEG32hjQ78kTsDlqH6FyZ4zXYbOzdP68ivpTIEilvo2des+4j9mSZKN04UnZ1pje4ze; 25:BdoXlcJx+xC0J6Iu0B34czuTH+s6kIZMHTmdLmAdmkI31wSgUUKc7yua5NjfpfqiqPabaHs23YUREOUJAqVHPm0EWzaRPke26l8QvrAJO6ZXtL17pSTlN1rU9uB8ikZCqyER2HM73136XI8yWO5sp/ridxsxZZtUhPh89Snh1pVz/SvSBKOIEOhQZfKScxDQ344AycT4/F4/9wKamyA7qRsuvAGe55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XbTO2d1R8YYe9NnPKX741BNgkbsQy4VtkbI/ur6Ssj7Tkyr+VvpZRe+sPw3Joosq2A8mdMOP01qb9fbfr/ShYC922LlMhEUXbsTLwZbyNZtTbeLuqamZA4nreU1Rc9W4r3zrIu9H1Urij3C9uiV6iQ888x35WukXKK+ln0CR/VJgq0LWlDYyQl3PVjS74vJR02fLSqPtigp9pThF0QjCGrYiH3w== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:b+M81ikuAkzq/I59aqPK+N/7qhagjbBPDNl4htNMD?= =?us-ascii?Q?chDICCAZ9tlELDxXDfDfdBF1JXfY7NCpp8E2GSq/XxdiCjXhcaxWXCxkwnKF?= =?us-ascii?Q?/FYi/edXQKG0Tfd2ZIZ/itJEXOiIKym/qse9odj9tDZ60qvXYSG6WRC10A7N?= =?us-ascii?Q?HTwK5GkxwNgt27FSjwI9YEvlCILK77XMA4K/PggCZVcTmYiO858dQ1Xp2r3o?= =?us-ascii?Q?QZ9Dw7d4aWaGE+VdMptx9uhld8Df8H/LKVCd8CDOcbD5bSfo0uQVRD1pc2KT?= =?us-ascii?Q?FUPs2RKSXYLy6A293ze5ov8FVtO/wnKsfAyI1WoRqdM3rrggazhKdtStYzfL?= =?us-ascii?Q?+VjKCQ5HFII3ODznHRTcusS0AtWUZ21WrvFgAPkKzl7E62nQ4mA5XIg+9bfT?= =?us-ascii?Q?QBObmp6FoIxV6kpWjAWMHizAxkrpXQLWm0HCVlfHg/HHq1cjaTBQfuAQZzwk?= =?us-ascii?Q?AQy+eYban21dxnzQLKJMkTCtTb2evzGMcKWXmxS9zqN3mVm5o5Mc6mHD50XC?= =?us-ascii?Q?23EwI7c/1vlwcdSOzXDM2FWjdLXXLW3EiidPnmHJp3F2XIPU1LhPRXEaWQe2?= =?us-ascii?Q?Eq5ajBzl2IMsClgyJaN+NOWBcxY2oM4XzITRFiVlCzg89yhonuulWdUpBV3o?= =?us-ascii?Q?HMxRmyeTUBu7omePOLi3pRLQyQOjBn8hRM8M5bNB5RHIDsEA4R8iqx2cvyVn?= =?us-ascii?Q?IhBCksU/7s0G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QluZOKPcFFpWh4DI6gKHJ/N1ZRHhXKmkK4V3+oALe1P6P6l5MfeHvA==; 5:3pjnFcFSLEnoGNMgxyQdrZWYKgv9QVwiFs8uT/r5gyIupnjgYAd1V6YPpZYoJEPcHxtHCwB7j8FxRM5tOQyqFH0wJ7fsSYIuo+bqG5sznUbOnwk18Qga+9HDkc7/wGD9G/sMfqJQu8D8zPGP2Y4teQ==; 24:VksJ/UK6JKR6u9IWoGR+CVm3u9jGKd8eKEvQaKJkAQbkLP2B7yNj75GimOdNE9DOqnMzHm5P4rzegAvwkt/7LvHxp51RqvUzs+/lc5XQaDI=; 7:Ncu/rnml6Zyq5OOHQN0NrEcDW9D0jS4bFZhhmkbxyZv5I4O9/pKAGXhJhGfYEFn602Jvuavs9v6/AK+E380OhNr6RxF0bRQZ4POpaXVw6TVH+wOEdJEmT+eLKxDeaZv2YplgKafc4gpeTGF0Gb8zK2eymFLsxz1drKFIcDvAZLRkQGDBgIgP8ykyB+iqcbXBhSRAK9m7NaX5VDWP4obgrK9oGWsUWPdpcaLrZUVxvNc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:ub5QpxvZpKabibDsmdqFsHyfZIWbsGdTwT6luvuegyFR0GJGvL2HxyoGpWNb2r4273MS2mNwH9xq90tCjmkfUBWIQ4xAVM7milxEtHrmjuErw36mDq8hprYwLJJIjnYQer/fVoX58LtikU/+CA1Hgv2xbCE1EJAk0vIJBvmH/gOqmuwElqK3iqAV7ned1ZcLu5Xi/u34GvMR9isccTlokKXnRv+uQmZrnsRLI/UOCf/sQ8ZbjHSiDsAcsJ8/i/mV X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:21.9991 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 01/14] OvmfPkg/Virtio: Introduce new member functions in 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(). 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 --- OvmfPkg/Include/Protocol/VirtioDevice.h | 121 ++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/OvmfPkg/Include/Protocol/VirtioDevice.h b/OvmfPkg/Include/Prot= ocol/VirtioDevice.h index 910a4866e7ac..ea5272165389 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 @@ -31,6 +32,26 @@ =20 typedef struct _VIRTIO_DEVICE_PROTOCOL VIRTIO_DEVICE_PROTOCOL; =20 +// +// VIRTIO Operation for Map +// +typedef enum { + // + // A read operation from system memory by a bus master + // + EfiVirtIoOperationBusMasterRead, + // + // A write operation from system memory by a bus master + // + EfiVirtIoOperationBusMasterWrite, + // + // Provides both read and write access to system memory by both the + // processor and a bus master + // + EfiVirtIoOperationBusMasterCommonBuffer, + EfiVirtIoOperationMaximum +} VIRTIO_MAP_OPERATION; + /** =20 Read a word from the device-specific I/O region of the Virtio Header. @@ -319,6 +340,100 @@ EFI_STATUS IN UINT8 DeviceStatus ); =20 +/** + + Allocates pages that are suitable for sharing between guest and hypervis= or. + + @param This The protocol instance pointer. + @param Pages The number of pages to allocate. + @param HostAddress A pointer to store the base system memory + address of the allocated range. + + @retval EFI_SUCCESS The requested memory pages were allocated. + @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. + +**/ +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 SharedAllocateBuffer(). + + @param This The protocol instance pointer. + @param Pages The number of pages to free. + @param HostAddress The base system memory address of the allocated r= ange. + +**/ +typedef +VOID +(EFIAPI *VIRTIO_FREE_SHARED)( + IN VIRTIO_DEVICE_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress + ); + +/** + Provides the shared addresses required to access system memory from a + DMA bus master. + + @param This The protocol instance pointer. + @param Operation Indicates if the bus master is going to + read or write to system memory. + @param HostAddress The system memory address to map to shar= ed + buffer address. + @param NumberOfBytes On input the number of bytes to map. + On output the number of bytes that were + mapped. + @param DeviceAddress The resulting shared map address for the + bus master to access the hosts HostAddre= ss. + @param Mapping A resulting value to pass to Unmap(). + + + @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 Map() operation and releases any corresponding resources. + + @param This The protocol instance pointer. + @param Mapping The mapping value returned from Map(). + + @retval EFI_SUCCESS The range was unmapped. + @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned = by + Map(). + @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 @@ -353,6 +468,12 @@ struct _VIRTIO_DEVICE_PROTOCOL { // Functions to read/write Device Specific headers VIRTIO_DEVICE_WRITE WriteDevice; VIRTIO_DEVICE_READ ReadDevice; + + // Function 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 Fri Dec 27 01:54:37 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 1502107173867470.3564644376115; Mon, 7 Aug 2017 04:59:33 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 892D621DF9663; Mon, 7 Aug 2017 04:57:09 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0057.outbound.protection.outlook.com [104.47.33.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 656BE21DF37A1 for ; Mon, 7 Aug 2017 04:57:08 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:22 +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=okGeaJV2vdA7NydpaxbzPvye0pDgNMCQgkZ/tdPyNXo=; b=pwtsOKyOfLD/sMfmbQBPzT/ZIWUL3kp5wKzcyoCzzp/4dry1xnYcPFFi9+eoxBbN2OZcXYnthzNbA7DK+stKljd+ORWOManxDuIcN5BE2Y4Syby0xsgISJp8WwV17et1IUhk7PlsydFa1ZUZurhVWOHZ6G0J7qJIU5dR1/qZnUA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:47 -0400 Message-Id: <1502107139-412-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cebd8a7f-6360-4f94-9fbf-08d4dd8bbe71 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:nXWPWjoLxYgFPiw85WcLVgqMHaUB6i7LoGVl0JsEMXmmdw0+mPOg99h2Vo+G2IAjxp3q3dACx+zr8sfXa/5JGYYE2FyKppbmO7T9/Q6AJ1Oks1qjAEh926679TfKRkNtfgvl14B/qvK38ytsDPsUDo7+lwavtppV6pdHC1HU2evf/IwtPCN56SWlzYj0gBYW+ZJlKHvTR2sYuXUfnW6o3azdDx2JEEar7tB540GXlkiqTNH58mopL32133fzJlRv; 25:snQgx3nf14YgOR3Sp83s7ZvQczGmrWrH+G3ZFk8ZawFtZ8nSAs/I2fT6KwlbPIvOQWJukhJsQSqXUZLG4q98jFB09bmGLu7U6aAC5IGQSfz9iNZBoAiTFwyxoBzbaoZotNijL4Awhosr+dYd5DErkqrIGVSF4hlkZpo3/g4m8DqJAkX2gwFXKKclW28Rv47o0tDDM7QmF+p6Uf9AfCqKTQv6W0ijiQ4lVo8m+h4QVDj6tQ3bMitLpDvkd7GCOdwYEzFrda4tr9EEHith9MnJZrrZLAuz25b3iazV2VihBz7PXSBRA86oJrRqtPMCvTzpHVp8S7iY7HmK9rjJwXluQA==; 31:UNk5oO1v/tL7taXrseOe550VM7t+f8bmucltmM8nZb+yVcnmqLloiFCKsfb39GPnd9nihfD7Flnux1be78kXX1QZvjpxypfXlCcJyYeYrceYDyE5FR2BqWuNR1nM7CWLXWdV2x5Sj3LgzOrOKvPEynqiM6B3UI8eJ7GlgFy/yG5qBmPHVL+hVs7k66mx/qZqybZPPeUrUrH+gRgRtKFOn6I3Jkt7Qb6vM21Bh1oEkuM= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:JCWMyKZO0Kmsne3SdvbYU40OI8PJzhpcc371ORmHnTNk/s0dfN34LOIv25X1z3JAbTOOSoMh4NGlwr9nOWzAiqDE4ZEePkngC5LvQkqgvw4RfzPbnFm439EJ+lVISxHxzu4k1X5Ix70Pwcag1NQTBwXuhFihOxniBVd5tOZW1L58tqxbPGKKD2IUUoJMWlf40w/O9nU3feJRE3ywaUugmigDykQR7XhfJS7m83ukiQy4VGVuaNlAA9t+1P4hYlg2Ye/hmrAevwpp176AHGOaYGIz7QtlduSPHg8J4qRNbf0a1lMw7e4xh8+dVGZDbltINOF65B6HXk9wIAtKozIiDfHKZt1viLPFlN9kJa0DcckK+zrxdUpm2/l7v8JdFbphY/iGcnHod2XR5jHOxbSpBD+/OOreHzlt3/sdvZVX7ZY5pHPVh1E4O9JrW/Afv44yHVx0zg1FDa8H9npWvvk9Jpj0Zr+TCAUOLjydLlBa8sTK/h0X/Sm1XbMLnkhcSp1J; 4:0KEjdknGGJpP8rsUhPRfFpzs9batC/fdal3QqIb4KEq/J7kJ3Pal6Cdy7K4uzsRRyhB18OLBd7f0EnExx4YQtZwMtjmn6WOSTsElbrUutCTTEFdaL8nNoS69j/1U/a2eZTDNa5ebp52TGgzezUOi8i6jKV5j1B46cSYAQ0JYLZZ+Sq/FfNo5e9S7MexoylvC3G+vEHDwno8oSys+1z55dtIe2yNaIj+NvsOR26weabgfsJvcUowWpxjo5Rm86WCH62J60TxUlcH9tl02W684Iz98Eumbwjm3+OpG2LWU/07kWlD0PO2b+4itdioVf+j6KwH3bURIpZ6+rFIqTJdwzw== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:ZkbVnyqRdXYpGvNy54xpbK3LEguYa46ezSX1hRSL8?= =?us-ascii?Q?Sh3Dg78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8oD/t4euIiebPtuzuVh9fh6SHIGoKFOLcTBqNTdtMzdBzfzKTdIVlXtGzvrRL85aehzrwOE=; 7:tZlIzOKLCP/YxYnTKmR4w/Atepjv976kFoFOcIcovQQKlhxeehaaXImCy6clNkAsfLLApWbtjKfBlW4mPoGM8K48zyqbBM+KXX/13dZF6zAcCPcf3FFXrppuRs9zl4uR3ddre23CdHJyHwa/zcdMfiILye76Q4q1vVr0rdk/baZxHRJhUjIAKF6U+S5exQqCPKz8JpfW6hWiHZqbiJ4sjXKtOOyfReJV43qf1JUbJTs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:MGN/WAtAwoE/0+6xn6SMBT1icX1TGjQHb++oTQv3pvACxTFBjgBgyCBWb14cD3fsEbXClDHlKWHgIHPEIqIvGd6qAG2U0zxhU99BL9Kuf3IyrM+isK6fCohty2br9tv94w3C+7/AYjklK/rsFnuOgETjikjgpLfhRSsM2bphEALEQ6TQsT/bwRw/YfZnguVryiDWqWjMtrj27pBSWjfpbg7mvHI77D2Q7D01W9qWWewwctOahkV+Mk77mSKxANal X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:22.7175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 02/14] OvmfPkg/Virtio10Dxe: Implement new 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 member functions by respectively delegating the job to: - EFI_PCI_IO_PROTOCOL.AllocateBuffer() -- with BootServicesData - EFI_PCI_IO_PROTOCOL.FreeBuffer() - EFI_PCI_IO_PROTOCOL.Map() - 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 --- OvmfPkg/Virtio10Dxe/Virtio10.c | 114 +++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c index a8a6a58c3f1d..5bc8f1c7ee27 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 @@ -772,6 +773,113 @@ 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, + 0 + ); + 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 + // + if (Operation =3D=3D EfiVirtIoOperationBusMasterRead) { + PciIoOperation =3D EfiPciIoOperationBusMasterRead; + } else if (Operation =3D=3D EfiVirtIoOperationBusMasterWrite) { + PciIoOperation =3D EfiPciIoOperationBusMasterWrite; + } else if (Operation =3D=3D EfiVirtIoOperationBusMasterCommonBuffer) { + PciIoOperation =3D EfiPciIoOperationBusMasterCommonBuffer; + } else { + return EFI_UNSUPPORTED; + } + + 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 +896,11 @@ STATIC CONST VIRTIO_DEVICE_PROTOCOL mVirtIoTemplate = =3D { Virtio10GetDeviceStatus, Virtio10SetDeviceStatus, Virtio10WriteDevice, - Virtio10ReadDevice + Virtio10ReadDevice, + Virtio10AllocateSharedPages, + Virtio10FreeSharedPages, + Virtio10MapSharedBuffer, + Virtio10UnmapSharedBuffer }; =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 Fri Dec 27 01:54:37 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 1502107177269847.6788366870305; Mon, 7 Aug 2017 04:59:37 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CCDFF21DF9678; Mon, 7 Aug 2017 04:57:11 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0057.outbound.protection.outlook.com [104.47.33.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B0CA321DF37CB for ; Mon, 7 Aug 2017 04:57:08 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:23 +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=NU26z/guiW9xkne2GabWR8IPa/z25YxCjB6YXO+1Ugc=; b=o/Zb/EB3O+c07kGRfDsb2NGhFfvgYauaie10djgE4SmW796IlT4hLahjUx+We7xEcWLaPZ/8EaxEEXKBEHdXC7PdUC4jD7AUU0PovCT7Ouf3iX+fomgBPmynidu0Nn3VrgXH4cB/2InoV915E9vyrNtKqiTTK1699z71vFoDMbo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:48 -0400 Message-Id: <1502107139-412-4-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c06853c-5f26-4d8e-7c5b-08d4dd8bbeda 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:m4VTUrYEYshk7YZx/8MAa7pTRdtN4v8Fel5TM+UD/v/CnLjJPJlgrIypaQcY9xnHAguGcmnZZQ4kcB8cEC+BSm07Y43ozCjOz0O/Og2VKmavkN7u6UN2pnEmrdWZFSGWNYCXGIccqH5rSNOSzOrsRtbffjjSKKOAUo67MTz5BEZhTnLKax5IgO0X/+oJy6OS3urxI6ti5zSCmevjDkCDfKLIzADPftkJzPhnZStJ54/e6BgjnQo28/SYVxAD8HiR; 25:6phf8VX4LL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dpG1dNUSssl9UdpdtvLhqZfPyZ7s5Z8I8F09j1fCyxLDrILGDdLvNVQnMJCEL6W8+PQFenrclKVC9v; 4:R9MZjvZrPU9yUmZHB2AYjn7r9EUVbn7SUV8qNfr7X6buYhArOGFXLYWozGxGpeKUOCO+QEHd/WsvVfuvKGWnAB+zBl/4xzC61maxile/FFQuFUbGwJkyP+QD/wjLXpWquuxMAephY9ljmAzbOPC+Bsr59yFhsR6AL+dUv7YaVhMN2B6j1VCfb30ZtsyI8hBdIM16ZWZTek9EevH2nyc2xGnrETdR7OHppGd5rIjKjKevsnNuCulsNbv1t67nSkWoKy+9HemAMuZ9qcBpn/Ml0Kp6X8/PP8zo/R82NrgdOe0RgyWFG5jYNPPvwuLXpbmDbOAYTwYuvjJeykCjUfCBEw== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:pm26TtF5lJdK4Y3Feri9woJf4eMNweyUnXSI12UiT?= =?us-ascii?Q?yhcF2OLKmb+nPFc2EqKAemjgz426PMB8QCDhXtQXCqVK2MIV9+iXJr+/jaOT?= =?us-ascii?Q?DcOcH6cLNzWhzUIhWMwagx53yNd9TzlyrszRRwFEA95Pz6UXzjR+ckkPYBJL?= =?us-ascii?Q?YBJ4Vtiop54WYbwZA18gPFfhpAgmRENBqnJBh//OrqzEuLkK036VVx3+2QWA?= =?us-ascii?Q?FJTQTEQB+AojD6VRrKENY6HjEP3TpEBlsff9C6IcGPh5lC/r2DGp2f4OiWOE?= =?us-ascii?Q?tH63v6l3J9DvaBbWHV2tMtmjDz9XHutT1xrrkOIW3aBjDtMPNyzPml1ezoke?= =?us-ascii?Q?5cefwdXKy0dPex3oqzsKW/ClykPHBWFEq3AWzGfyhuZvWLTcUU1NXWfZU1sw?= =?us-ascii?Q?boBzfE5OfMgYVs0ArxiRx/qljZKIbbRqiOdf2vppme1hRgRw60XwIv/ucUqF?= =?us-ascii?Q?ljhuL7Bx7RZ/dzXb6vQmnJuwlScOztuE1N+UZQr66zCB1dHpK+uJiTp5e7M5?= =?us-ascii?Q?jqDlgUvHFelpjpbm3UdJa9/aMu62SWx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zlI40dhd+EkF75AGtEnXyV3FZJGCVE69nWKD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:23.4204 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 03/14] OvmfPkg/VirtioPciDeviceDxe: Implement new 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 member functions by respectively delegating the job to: - MemoryApplicationLib.AllocatePages () -- with BootServicesData - MemoryApplicationLib.FreePages () - no-op (host address is same as device DMA address) - 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 --- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h | 34 ++++++++++ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c | 7 ++- OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c | 66 ++++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioP= ciDeviceDxe/VirtioPciDevice.h index 8f17a16c88f5..da98de123000 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 ( UINT8 DeviceStatus ); =20 +EFI_STATUS +EFIAPI +VirtioPciAllocateSharedPages ( + VIRTIO_DEVICE_PROTOCOL *This, + UINTN NumPages, + VOID **HostAddress + ); + +VOID +EFIAPI +VirtioPciFreeSharedPages ( + VIRTIO_DEVICE_PROTOCOL *This, + UINTN NumPages, + VOID *HostAddress + ); + +EFI_STATUS +EFIAPI +VirtioPciMapSharedBuffer ( + VIRTIO_DEVICE_PROTOCOL *This, + VIRTIO_MAP_OPERATION Operation, + VOID *HostAddress, + UINTN *NumberOfBytes, + EFI_PHYSICAL_ADDRESS *DeviceAddress, + VOID **Mapping + ); + +EFI_STATUS +EFIAPI +VirtioPciUnmapSharedBuffer ( + VIRTIO_DEVICE_PROTOCOL *This, + VOID *Mapping + ); #endif // _VIRTIO_PCI_DEVICE_DXE_H_ diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c b/OvmfPkg/VirtioP= ciDeviceDxe/VirtioPciDevice.c index bc4f6fe8bfa3..4e4e21d9a477 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 243aa14c2421..1c587e184311 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,68 @@ VirtioPciSetDeviceStatus ( return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS, sizeof (UINT8), DeviceStatus); } + +EFI_STATUS +EFIAPI +VirtioPciAllocateSharedPages ( + VIRTIO_DEVICE_PROTOCOL *This, + UINTN NumPages, + VOID **HostAddress + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS PhysicalAddress; + + Status =3D gBS->AllocatePages ( + AllocateAnyPages, + EfiBootServicesData, + NumPages, + &PhysicalAddress + ); + if (!EFI_ERROR (Status)) { + *HostAddress =3D (VOID *) (UINTN) PhysicalAddress; + } + + return Status; +} + +VOID +EFIAPI +VirtioPciFreeSharedPages ( + VIRTIO_DEVICE_PROTOCOL *This, + UINTN NumPages, + VOID *HostAddress + ) +{ + gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN)HostAddress, NumPages); +} + +EFI_STATUS +EFIAPI +VirtioPciMapSharedBuffer ( + VIRTIO_DEVICE_PROTOCOL *This, + VIRTIO_MAP_OPERATION Operation, + VOID *HostAddress, + UINTN *NumberOfBytes, + EFI_PHYSICAL_ADDRESS *DeviceAddress, + VOID **Mapping + ) +{ + EFI_PHYSICAL_ADDRESS PhysicalAddress; + + PhysicalAddress =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; + + *DeviceAddress =3D PhysicalAddress; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +VirtioPciUnmapSharedBuffer ( + VIRTIO_DEVICE_PROTOCOL *This, + 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 Fri Dec 27 01:54:37 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 1502107180579714.046968853511; Mon, 7 Aug 2017 04:59:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 19A9A21DF967D; Mon, 7 Aug 2017 04:57:12 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0046.outbound.protection.outlook.com [104.47.33.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 81EBF21DF966A for ; Mon, 7 Aug 2017 04:57:10 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:24 +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=jys4ArBtFdkhMEDZUdTDoZ4oFtkNt/+YEahSe4AT42U=; b=UFaAw/+Rgz8cA1WNAXzcXDOEabxGeBVyFjTZ7zmmGQQidLewKTK857oBQ71kLI4FUpiBL5QN0GfwcKTUTLmmussQkwCn3D9Rt6HxnwKs3ssCI8pDxo0oTNjl8uJvMxOdZV54ZQHxj4/ALAZdwCL4lTr4Cj7XM83sA8TYrEoSWHA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:49 -0400 Message-Id: <1502107139-412-5-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf643399-54bf-4aa6-1d2c-08d4dd8bbf48 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:p7xPo4k0Ua3eTqIkLCMzeGjdTmhlJrKq9VxUM1zdjsPR/mMR9EUbir7LN3pwk+zDAd0xITRZ7T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5AARHK3TkueyRgJmSl15wHUC1UoJkZlQqOYS8r+WFVBpiEC5W8f+xd4i8argOQT1XFU4JNOWA13El1wCI6bvavqDh7oyoxXSGn4Ajv7dcO4yxYJSTv7hFQYZRx+Gd2tpcd29V31Tqg3OzP6vVUVaWQ8npWerIwD7EXmP/O7yDjIb7F8uz/VcougafXbiTUrQmeyX9XPbYmCHvsFA3v5saibqSYNOy/qqOfGG2RVuwDHGv68h7oXGSXpKWXvfozOx1Bw; 4:DQBVXJVYX7JK+X9CdJgVmemZ1mFw7VrYYWyzsasGvciTKlXZ6+yVeIIx+WRFPY7znb/y6QU0MBxwuYKdmiWlrRdq6tjLPz/U4YHtTMhtJAy0l8GRWBPzoVMjjSe7Tel95IhGWi00iUGz5D+E63EStABM/Z2xffntPDWd4N4goD2pU/Whhg6Ou8ecFEIJLlRaKHaI+CNnLpRNXjGB/TCUzN6vDKpmbvKJ17YlwfKFM2bGevOMQLpM/IF8nNAZKgksRvA3Vtb1Q4ERiJlWMMAawZ/uz2iLrTE3vevtQ+CfSDPPrLe7ip4JwHfODyH40ExKjQhVzLhY2ZOjHD+o0h/6oQ== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:Bjaulf4I1VJCw0C3ZiZfWe49ffTTvmpkZScq/fETC?= =?us-ascii?Q?4CTWVq4bpIyDIjm+AiP/VdxOH5iyd5QhKbL/uLhUnBvNV+5QeTNFo4uyvrkF?= =?us-ascii?Q?ND0/9zE5kKWDdUPia/pbK0ES8LXT0zMqBf1nw+LupuLtOnNWdiiwyTfmASbH?= =?us-ascii?Q?mT2ZgfkLq/OmXQ6lzpSLh/G3DVR8mte9EUgc7uDS9qnkYXpBXqAzoFSL/mXx?= =?us-ascii?Q?TmjOMeMP3UZMcKQmbuxyhS3a2Q9pPgU9zdrOMkq0DbiM7iJl8+ox+Kk1bqZb?= =?us-ascii?Q?NDgqyNE9nwgjxzCHs36VEzIghQYjwiFbs5EQ4CVj5Kv6SCGYZRlLkXXrVY4t?= =?us-ascii?Q?r72Vgs/0S+79GXL4060oGauwDWsmkQJ6WNIdY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SN1PR12MB0159; 20:HQZge7o2x+aeEeHgjyP26K30fd5vvgSix9wjWL4unb0Z/W6TnvZsE04ea9tyiCstS2TgPeu5adX1iUcZgz8ZYZe78U0G0V5HqzGe0OfR+hpm6kxss4Uh1k9u6vyCpY4/Rq5OdsCdpBDFFnBx1KhrWHGuwbdHHfuygEue/oGKtfzSb43VpBM3zr7UKy62YY2AF18jmnphSVGTV5yrPzU6aASzWnJuVtgLtssZNOYzvANX/Tv//lTz1oSsUoL2Fpw7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:24.1232 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 04/14] OvmfPkg/VirtioLib: Add SharedBuffer helper 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" Patch adds convenience helper functions to call VIRTIO_DEVICE_PROTOCOL AllocateSharedPages, FreeSharedPages, MapSharedBuffer and UnmapSharedBuffer member functions. 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/Include/Library/VirtioLib.h | 143 +++++++++++++ OvmfPkg/Library/VirtioLib/VirtioLib.c | 220 ++++++++++++++++++++ 2 files changed, 363 insertions(+) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 5badfb32917f..fa82734f1852 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,146 @@ Virtio10WriteFeatures ( IN OUT UINT8 *DeviceStatus ); =20 +/** + Helper function to allocate pages that is suitable for sharing with + hypervisor. + + @param[in] VirtIo The target virtio device to use. It must be valid. + + @param[in] Pages The number of pages to allocate. + + @param[out] Buffer A pointer to store the base system memory address of + the allocated range. + + return Returns error code from VirtIo->AllocateSharedPages() +**/ +EFI_STATUS +EFIAPI +VirtioAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINTN NumPages, + OUT VOID **Buffer + ); + +/** + Helper function to free pages allocated using VirtioAllocateSharedPages(= ). + + @param[in] VirtIo The target virtio device to use. It must be valid. + + @param[in] Pages The number of allocated pages. + + @param[in] Buffer System memory address allocated from + VirtioAllocateSharedPages (). +**/ +VOID +EFIAPI +VirtioFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINTN NumPages, + IN VOID *Buffer + ); + +/** + A helper function to map a system memory to a shared bus master memory f= or + read operation from DMA bus master. + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] HostAddress The system memory address to map to shared b= us + master address. + + @param[in] NumberOfBytes Number of bytes to be mapped. + + @param[out] DeviceAddress The resulting shared map address for the bus + master to access the hosts HostAddress. + + @param[out] Mapping A resulting value to pass to Unmap(). + + return Returns error code from + VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioMapSharedBufferRead ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +/** + A helper function to map a system memory to a shared bus master memory f= or + write operation from DMA bus master. + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] HostAddress The system memory address to map to shared b= us + master address. + + @param[in] NumberOfBytes Number of bytes to be mapped. + + @param[out] DeviceAddress The resulting shared map address for the bus + master to access the hosts HostAddress. + + @param[out] Mapping A resulting value to pass to Unmap(). + + return Returns error code from + VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioMapSharedBufferWrite ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ); + +/** + A helper function to map a system memory to a shared bus master memory f= or + common operation from DMA bus master. + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] HostAddress The system memory address to map to shared b= us + master address. + + @param[in] NumberOfBytes Number of bytes to be mapped. + + @param[out] Mapping A resulting value to pass to Unmap(). + + return Returns error code from + VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioMapSharedBufferCommon ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT VOID **Mapping + ); + +/** + A helper function to unmap shared bus master memory mapped using Map(). + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] Mapping A mapping value return from Map(). + + return Returns error code from + VirtIo->UnmapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *Mapping + ); #endif // _VIRTIO_LIB_H_ diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 845f206369a3..f6b464b6cdf8 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,222 @@ Virtio10WriteFeatures ( =20 return Status; } + +/** + Helper function to allocate pages that is suitable for sharing with + hypervisor. + + @param[in] VirtIo The target virtio device to use. It must be valid. + + @param[in] Pages The number of pages to allocate. + + @param[out] Buffer A pointer to store the base system memory address of + the allocated range. + + return Returns error code from VirtIo->AllocateSharedPages() +**/ +EFI_STATUS +EFIAPI +VirtioAllocateSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINTN NumPages, + OUT VOID **Buffer + ) +{ + return VirtIo->AllocateSharedPages (VirtIo, NumPages, Buffer); +} + +/** + Helper function to free pages allocated using VirtioAllocateSharedPages(= ). + + @param[in] VirtIo The target virtio device to use. It must be valid. + + @param[in] Pages The number of allocated pages. + + @param[in] Buffer System memory address allocated from + VirtioAllocateSharedPages (). +**/ +VOID +EFIAPI +VirtioFreeSharedPages ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINTN NumPages, + IN VOID *Buffer + ) +{ + VirtIo->FreeSharedPages (VirtIo, NumPages, Buffer); +} + +STATIC +EFI_STATUS +VirtioMapSharedBuffer ( + 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; +} + +/** + A helper function to map a system memory to a shared bus master memory f= or + read operation from DMA bus master. + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] HostAddress The system memory address to map to shared b= us + master address. + + @param[in] NumberOfBytes Number of bytes to be mapped. + + @param[out] DeviceAddress The resulting shared map address for the bus + master to access the hosts HostAddress. + + @param[out] Mapping A resulting value to pass to Unmap(). + + return Returns error code from + VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioMapSharedBufferRead ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + return VirtioMapSharedBuffer (VirtIo, EfiVirtIoOperationBusMasterRead, + HostAddress, NumberOfBytes, DeviceAddress, Mapping); +} + +/** + A helper function to map a system memory to a shared bus master memory f= or + write operation from DMA bus master. + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] HostAddress The system memory address to map to shared b= us + master address. + + @param[in] NumberOfBytes Number of bytes to be mapped. + + @param[out] DeviceAddress The resulting shared map address for the bus + master to access the hosts HostAddress. + + @param[out] Mapping A resulting value to pass to Unmap(). + + return Returns error code from + VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioMapSharedBufferWrite ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping + ) +{ + return VirtioMapSharedBuffer (VirtIo, EfiVirtIoOperationBusMasterWrite, + HostAddress, NumberOfBytes, DeviceAddress, Mapping); +} + +/** + A helper function to map a system memory to a shared bus master memory f= or + common operation from DMA bus master. + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] HostAddress The system memory address to map to shared b= us + master address. + + @param[in] NumberOfBytes Number of bytes to be mapped. + + @param[out] Mapping A resulting value to pass to Unmap(). + + return Returns error code from + VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioMapSharedBufferCommon ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *HostAddress, + IN UINTN NumberOfBytes, + OUT VOID **Mapping + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS DeviceAddress; + + Status =3D VirtioMapSharedBuffer (VirtIo, + EfiVirtIoOperationBusMasterCommonBuffer, HostAddress, + NumberOfBytes, &DeviceAddress, Mapping); + + // + // On Success, lets verify that DeviceAddress same as HostAddress + // + if (!EFI_ERROR (Status)) { + ASSERT (DeviceAddress =3D=3D (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddres= s); + } + + return Status; +} + +/** + A helper function to unmap shared bus master memory mapped using Map(). + + @param[in] VirtIo The target virtio device to use. It must be + valid. + + @param[in] Mapping A mapping value return from Map(). + + return Returns error code from + VirtIo->UnmapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioUnmapSharedBuffer ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VOID *Mapping + ) +{ + return VirtIo->UnmapSharedBuffer (VirtIo, Mapping); +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:54:37 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 15021071838621013.3798115508516; Mon, 7 Aug 2017 04:59:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5D99721DF9681; Mon, 7 Aug 2017 04:57:12 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0046.outbound.protection.outlook.com [104.47.33.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F14BC21DF966D for ; Mon, 7 Aug 2017 04:57:10 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:24 +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=TigpE5HBkEsakzh3H+Fym3APjqQqF962/XCtIivX0So=; b=rM3oFMI8TQmlgnijuaRI2urZx3Kb+SjBJhbtv0ASzeSC6JbenUNckX5QBliVlBe43Rmt5kLkXN2jh+2lhbdqmD8XOGoPYwL7Z962N390YxplBldF3pLd5lRawNqjlnAfVALHrMiB8bA0mLNOovbM1BTXbEqBMqa2tA7vY9BbUag= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:50 -0400 Message-Id: <1502107139-412-6-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1daaa718-abe1-4e04-2009-08d4dd8bbfb8 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:e1MPEf4Wu60+R8rvWcjXXj7LfmZ8/0jjVD9qTZzHtGJAcwknYH+D9FS57UtdjT+MDSDtrSnlkgux+My6RAnwxzCSrfpNp3kyJPIKPSRp6IoMYgaM3aE6/1lZvPq0w7uiAzD7gkGBzKQ5QWOd7gqHVyjZxd25QXTt0OZyfkI8TqeDLuo3RzxmYuzriNdUidla2RFM316/eKyow0h8nEFeXcqqkXqAnbQ0LnuzTNdtDlZWb+tCH2Fn48l1te4NsttV; 25:ARSbUBtxM1Gaj5dNVbXl+RAr/WbtpRFOBQBsXz8ma8Z/+veU4Lx3faWRhYxodre+P7wXKPk4JFZQnhTJt3Gh3ikt8u3dSm6GLZ+tqseA6n0pYXV2s7nACrWSHbbRKEomuTnfVJmLV44V1C3bSLsooK29jPJd6h16u+MqMQZ5cT0MxVopSC+5i6R7G8if29W+YN+d4Q/ZeC4qEz+NYQT+ZrtFm+fr5CluyQgC+h8XuAccNuqwC8i+DUdOOFNMJd7w3611kIu0rp38nZRXeqoSeChlwf6hTgE1ivFN43s/O2PpLVZE0sE+FCNujAZ7qjp4SdAQvbmvxYOoh45NorKVAQ==; 31:kVp3ylqdpLknVLwS558nkJhaYL/E/yjRB67JMSNgU4rr+2kpmFFEUx8OWyOwphesr79DVmWPy2gEiATYubYMezmNhIu2gyWPDSu+fvnwQKp02btFpDOyXDhQdEVt7+5fDdhUrDkeuWdyhpoMNlrDnt4xe75oo0GpzFMBIgSegZxig3cHTvG2CFOSM1Buf9FZDeD9ErdlCbWC+VrHlkUZHVg1xucr+SeCVxrzkIJpeqM= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:JwMQlkQwN5/anEpdnUe943lG7Q7Two6Pr90Ga5cvpDB115dHiz0h4WY8EPYVtRC/iHuT8tdC4XauY0BbT/tVsbFdF/V1Cx8GqZ6E6DrT4zp0uwfZPRFdotFwEXY6iyU9Ed+NrfhlanKp/BqfBrIKL/R0H52k9WgXvNSXK+Z7R+Qib3ASx6MOtQzjph5HuWqsIu+rXo/JygeLcKYmVjkb00iEnjTNf1DLpoww71VqQHevmKFnjL7Ct+5faFWGA+DDBLERWnxG2kL/NE6+nFSw6tKjq6G4Yyl80jbJq74gwcCjIbW+YXtwkS7ytctpHqxVL0AVs9WLGUlFpt6LkCwGhWorjvs1n0p+LD776zhXLpuZ342mC0xu+Znqp30xQ8YNASlC2ZmP6zFKa/aVmIXwqXTSn93V+ED+70Bjj3QPKmKq70QDNS4v0VS0RgR7og1zvRzzUEowjuCA/LOo/gF8FBfqVTkUWbdlTA43CWPoY2e+NAe5byPLgIDvjTGK7yM8; 4:NBmoja1AjTiCsx2d0XyFulhmExOu5OtopoYuhBnxgHPbyM0E99s1jACM8bgFfYA5KLvDznAmGDIrVdXSvvmd9qNwZCGINp4l6X/snM+bmwUhd+ZrVbi6392N0yLcsqUJoHGCbsNHzVeddqsySH6DIVYTE26V59V4XeleL+pCu0nlXwhRt4vGSCLIFm5eoQ2SF2jvS7cCQG0V6x6j3xURD01MHKmA+KmK4Q7hTRKzAaI3L+nUbUFOQ+CRHfpQyLQsui+SB/ItM4aVMhY4ScbA9BjcRJMBy9d9ERFXgjs/mGJeAlud+VZ0oaShH4hjTng5snRQzda42EnImw4eAMno5g== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(51234002)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(575784001)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:lgPKOSSTQBs4WJ7dv5ptrus338BoYydg0VBTgxbHO?= =?us-ascii?Q?PhcelQH7ca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bMKe4ucCUZjrBhLUPygfg==; 24:OC2vq/uxbQnPZZzmxymKaRfm0e52kdUNLy/FEVSVIFw4o/tGui6/cmLVjCLJcn2fDf0r+NYyd92zzbip1e0iJKG3AWDxR38IE2u1XyuSRUo=; 7:a7PEqCusZ3ll0JjwVE1bZSQkmP/x17o3SuvQQAHtBgZmVezp1dvhbLb4fcrcOQ2zXQwKcwUcP1sd+EkO7beWwU5WO6SYEhR9GFuI+lfSD0wuoYenxp7qgQcRWNG2T9Jpwzq0ndRvkbA9De/7b2Bh9iNjH5SGeFEWf1JLfV3o4Vf6grLQcX3i6q5Mkz84BRq5obfClq0clLoAhcmJNq8YuEAtAWyOx4duOMfblS5qT+U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:bkgK0dpnPmHY2GLY8lH2MsthnDEOlPa3tgOdC2bBiy4f3plegkqDWJas8W0zhX0igFURfTTLjteSRhJngnSx+c7RmsScvRkAJ91UE6kWS3fjqNGuheAIRRiyWXdE79JicJmyKKG1dR5rO19M/zN0ONaRxn29KOjv/AQ2p3KcvOD/2EvmmeaCZnr8VqlA2LVI/ArMXdxXUFHKIXXLg1E75XaN7J7mTWKmYsrly/0ZjHGkgP9hTFgpPXl07tMC+ql9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:24.8573 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 05/14] OvmfPkg/VirtioLib: Pass VirtIo instance in VringInit/Uinit() 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 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- 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 fa82734f1852..610654225de7 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 will 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 f6b464b6cdf8..50e5ec28ea1b 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 will 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 Fri Dec 27 01:54:37 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 1502107187701224.54519886584205; Mon, 7 Aug 2017 04:59:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A966521DF37D3; Mon, 7 Aug 2017 04:57:14 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0046.outbound.protection.outlook.com [104.47.33.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 48AC021DF966A for ; Mon, 7 Aug 2017 04:57:11 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:25 +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=8bHUs4LBDvie96kk0lfhQtM1gwsTCZlcRrBQhblXDdc=; b=vEWfC+Z46ZHUrsJzJRu7Hyh+T6vj/ElPSUHcYTJha4Dyr1Mmgw2Jq0s8C3uIB9Z0a4cnTFFJ2omCs0OdfxmInbPntaywv0r3ZWQezgGhVi2dCKavlGxhsCwER9a2yGwpsEfrSPnbNbXQS86MxY9cVFXEME9XZ9tihH4DTUz3EOk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:51 -0400 Message-Id: <1502107139-412-7-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd205571-a14d-4321-5ebc-08d4dd8bc023 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:DJlft9gWUXGhSCQ05MJGhO3GOdzuYrg41BJnwwxiVV7qRj+UugtqnphY5NEcUPZwaaO9J/gt2Ibj8l9MLdDKnRUGLRexict91c3puV2SxtTwYKeaoAevhuZNwhx71bk5whiUOHkIojbpohdD5UcGOKAbJmHrq9Beg04ml/lGlm700RT3Oo7DwbW4NLnBl8C3Kt6zZ5B26b7mm4By90iu92j/ckNTijo8kTz98vhYjoTaDKjjjdX50kHh5UnYaKOv; 25:Pc7VS3ZM+Z+G5AD+sFtreanD267xrcEoouhkAUtZRzFbBRW2anNw/7UnGTb1Knco39F8X4RTXmbG7zDgJORdvqSrI83as1AgXxCXYGE6xIwtpak/eEFhUmuO50yGjsFOXYNEF+Uk6GQKFLWrXGWtLoRFxP/Hcu1Va0yUfG4/6BC/1CngiClH9/wHjW7JAJXT1SE+hWNYhjgFNARZXwn/vaazrpObeIHRC+juYUEoncLeIQIOf0Y0fBdqSAAGbtOtLk1nWVqK/iZJhvHZEKlK5eXMplpIvIkHrt/ml/atKkZ8rHP32iGJCw9BPYvqLxPLachA7Pqu74ZjPMhy26V9pA==; 31:8PBAIP+RZ4DMVUI6MipSkjNRq0Q042QrQOCC+C6hljchoTU9/qt2UB7iUnagTeSDQbspLuPpmQb4/Ggo4CbWpjyKwQcI4OuH/5znKlg/kF7uzLEFz/6PWpHGpmeGKRoNS7pJpD3nwIg6nFWMS4wjSj4nz5XHY8EG148Micmke7ARizq4/vMvLOujAi1utvUVs0VRItJV1pXWp/AT/SItCdXSWd5pe4lb5PJ5O28JNY4= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:D+9i/RYjPunaJG6Gp+XsNmAuMto/rYP1QQb+/khSqUOmjHy6zYK3s4ENHdCjIYD46vMrNNgxjlEu7OajTNcWfo7D4qVkynsigQMXJOaPAhFnSJYCb3mDnSVrwj9SI/CxxxFJHMTesagd9YugGo5GLy7rNQsJt6xkc8VSn+usoWh2SfG9Ymlq9ujkV56v7/yBgCrBB/MyfK5Rez3K63QItXE3+G82wRdk0e25HWfsMP3HwdsiGsyedYA64sS+UIlZGC2PJ3U9lfii7ufKYi+RQjEEIoyQxIe7qi5cLV4YcgFNJUjOUj+s/8FL8UbFuQUK4cCu07q4icC8f2LTrS9UviBV+0s4iPRJC+RKeXR2zCF3JZCzbwoShTdJsRv/8t8bZOf+O/0Hkg5wxCyYAjQxTdWsvMPWQDApn3mqHFZi2mskcCgqwlF73lkBwWH/K5Myxnu0JCjGbe+0p0aEBoPDDdeRRx3p6c6/KqtWMHhkETWmREreDR1vq/yxWcjWUJT3; 4:taUvHvga5KcKwibdpam4ydAPZlfuvBRGZ7sRgyYU0c0XVo97qqNIRmEIvb40v4N1AvWHqoFjzbgQn6egvFC3fqiGf4V16K+ZdLyioaSbvjkx76jjgXgjUmk63RNaCTobtJlNuW4SajSj7gbqpoEIbkVi5pvK1O76MeOeKw3DMMm1Af/0AOw46fd1AAbdWXNdkUTRoKu5yWm+blB+lLgDe7meliOhKvOYMG/jIYaCmbVmEukZ4AHYcG+410v38L/GTT65skuI1A635wCGYTXd/TnGlr8uqGAK8casGowKIYjqBdFve8iOGhHqKQIBFK/2zpGIWaqLIW8hFP9oevlTNQ== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:U1nnF4JHI2x/8138iYymYa3kau1EaTJu1X1JbN1Q8?= =?us-ascii?Q?YeJnzt4aFqt+ZloQLVKA9KUFr5u/1gqSiTGKE5E+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c5Zefxpz3//K8InV2lgg=; 7:a0SX/4zTlUg/uPD2x6HSKw3w4h0hq75q4qZsjz6UA37+3wWvjOjN681fcxJHbVtZVk9ozRJkdOTkkhXn4YjIxgvXgk2NiF+Wm5JbIC7eekSyywGP07stAmSNQ93+w5Ap4AQylt6H2f8Oix0I0zts1ntWzxsFHICPWwNx/vTCPQzx/9VFOaxlQCCzvf7+u1R6e2MSYyp3fiO4uBJ/fvechsEGdeeOeAzeQbPYwLK13VM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:oDrTSu40KDHkUVUhQOgdv661tyGghutW1RIZfoGFtL+ruvRoFFcMOZwqVaPYg1J/zCyjh9wnpATvGW9uYfeJuGW92a7zaxuFy2uQiKOrQqduAuAiCMqAHvRRsjysqFQG6I8tewLEAmF3QriEGH6oDxiD5ISXs5eJr5eutkwetqwjzgM+5Bg+meoDidN7eRf+fhnamWbUfGRf14ucf0rSk/4HzScJEP0Y0mxCLx1LxgyTwIqTFVjMQUbEi41V1qci X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:25.5601 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 06/14] OvmfPkg/VirtioLib: Add functions to map/unmap 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 and unmap the ring buffer with BusMasterCommonBuffer. 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/Include/Library/VirtioLib.h | 41 +++++++++++++++ OvmfPkg/Library/VirtioLib/VirtioLib.c | 52 ++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 610654225de7..877961af0514 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -62,6 +62,47 @@ 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] Mapping A resulting value to pass to Unmap(). + + @retval Value returned from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT VOID **Mapping + ); + +/** + + Unmap the ring buffer mapped using VirtioRingMap() + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to unmap. + + @param[in] Mapping A value obtained through Map(). + + @retval Value returned from VirtIo->UnmapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingUnmap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + IN 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 50e5ec28ea1b..09a3f9b7f2e5 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -640,3 +640,55 @@ VirtioUnmapSharedBuffer ( { return VirtIo->UnmapSharedBuffer (VirtIo, Mapping); } + +/** + + 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] Mapping A resulting value to pass to Unmap(). + + @retval Value returned from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT VOID **Mapping + ) +{ + UINTN NumberOfBytes; + + NumberOfBytes =3D Ring->NumPages * EFI_PAGE_SIZE; + + return VirtioMapSharedBufferCommon (VirtIo, Ring->Base, + NumberOfBytes, Mapping); +} + +/** + + Unmap the ring buffer mapped using VirtioRingMap() + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to unmap. + + @param[in] Mapping A value obtained through Map(). + + @retval Value returned from VirtIo->UnmapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingUnmap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + IN VOID *Mapping + ) +{ + return VirtioUnmapSharedBuffer (VirtIo, Mapping); +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:54:37 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 1502107190635198.43137612969133; Mon, 7 Aug 2017 04:59:50 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E6D0F21DF9688; Mon, 7 Aug 2017 04:57:14 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0046.outbound.protection.outlook.com [104.47.33.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A6DED21DF9676 for ; Mon, 7 Aug 2017 04:57:11 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:26 +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=t2GtFiToHhVThfqghzZh+nWQY8PuD3PdbJrOUCjx+0E=; b=UUx3vB+TgTciOc3++5Owqwhx2dOTxDnlph2T8dXnSuFYsuWhHpnVvQIBQjfkCrplbXB5BLaZaHgUteNbJwAJ7RMhqR/RM0ppnsoFhesf0kkiTlGet2cVVwnDp30U1ibAEDEUTx4SseH92g2FwIFv+5XUSPa8VC2bcyBGso4NuzA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:52 -0400 Message-Id: <1502107139-412-8-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fab4c3f0-168d-49f0-3b4c-08d4dd8bc08c 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:bnsu3UDrmLA+vFogBW+jSc4yKVhmxQWrOSSwsPZs+DudU1V9G4rH/QjRGeGNtdAdiefObnAo2BwHH52lG1dKytp1UlQb7KJRhafyiMReUzlOIniVshWyOteyhJkN0GSTO38mZI/70IzX0EELuss0vz7r0QNtsclVVMij6H1HQCuyAIyaxc6rJDS9JQya4v6WBU66lV8eSQlZoXl8rlWKidpovt2oZPClaUKqf1dZYV8coiQrRksvLOlOr5ne73ru; 25:iu/CTrSbTQF1/E43S6sBsAdqaB76LfmkUOMOKqP+UschguTzK6aMBBfWT4xrZvp1KoTkc6eay3yADVh2shv+topN1+Y6BBfHqZpDD9xBDEIl8UESmJpyge8JmMxKdMOmYUP+LUQN9I2pAR5BSyCE4ieKQvwzpuvfr5S+bfD3N1QgwNaybAuY3cXpM1ETHo6SawTB862wh7LykdeBQJ8Wp+zV7F4dk42lhxz0xkm6wVzQG02qZPJBRMJvtu55Qes6BJ3R4CUZ55mrciBCZO5m2t6z6+Ry8Vl0E80FN8jylCIjmAu1cwMFnkBQz1w+H3EXaOUNjqh3BwqLEXs9iNu5HA==; 31:k9Qr6hReIiuYuKtuWY/Y7CG++lrXZFK/IyDXvOHfDgVppqr+c4fQ/rDWuxbxG3YMLfGDyGFGzG3hbVscwUSFM2mo41/64Efk7t+21XAOP0CAXGq7QETnff9U+FTUCQeNufZfOYytYFiSJNbAnakH/LaQl5JQ27ySe6Qm+fD5xMXDtZAQeAFADdLf1XELnP15dJEWiByQvYXcEQ52E1nc6A2WCeEIa7Z8tqBNE6y03cE= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:s7YmUMow8GpGdO/PIa+BtDWlOrkjCZtM8HCVt6/OXxG6mWa/E8QTLMvJ0wbr+ZD+Ibj5HI0BTbxRr5WoDo/vSfzqPjPnDa57FanR1EcMSKAMcvaM5I+TtgpNjXb/BZIw34aeEY/eqNi+CUgMRLWfmwqf/VgKyHdJ18PClKlteVDfYr6x/Cq0oEBjQQtKHPSSGWAoyHIyQjQnT8wgyTtbzB3P3WWK6w37CgtTHjF7ymtk9KgGNnbqWXRKMsNvkOhhGYtgCEIk9rtHYaYatMDtUXwEQesrabWbxPMHKRF0AxJ1u8aoFN8rPE34VeXDxDcbk6Grc+K3y+CJB073uf9oVwRKbQ4SI0XcVbqpAG2XTBbDt7TA9BvOWCH4nD3NJbv9xLf0t16KHI7PMxCDsxHYHI7eVkxS9esBjHKUPdpO0NaoPBqgkQoE5OXlZX0zjYWouw1IBXo5mDSrgHb3cYGhPRNPU/q4b7oYv88nKsKVDhe/MAHLm9pvbjg1Or2zdO01; 4:BYQ1YqfBhYbfIS1bh/wVrEpxufOcrJQQHfCeURO9X5wWtMCqRVX7eV6TxGhMy6EJAzwOgX7vWPFgPKD9wbbKf37UPapq+DzQDDHReFJXETnbNpOQTJ8i3tqN3PPdeOGVogt2gDIv2+QbVPnyab7z+MKYY/wVbd12w4AivROb6jdLJPUwpwjAy64cwN0ptow2rTSG15GGfN0k65oW6p9ft5KNvOWtcabCNn5Q/MK+a7wO9JWfL89/6nEwvMagdbc5aI8A1gMtNAYaXnfMyDlWZVTzonsblEBEgqitOX7lskmRqXijeCBlIqpodjHahZGpOU082F6Ykzjs35I1PsyrUw== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:UPo13BshLeTcX0AQtkTTCACr+WO+Yx+rB+mV6CkCR?= =?us-ascii?Q?Njtwe4cI1MEBXc+msc0FLtx8JtZiirThsOK4jQulhk0e5c5/ajQphzCwkdRl?= =?us-ascii?Q?DMn8tMHbaX5q5FzFUl7YwutmA8Ww76Uhk7wqF3N2E8ngRBcwnvOa7SwUrgb5?= =?us-ascii?Q?8LSs1RlV72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7FV9WJlIh57h2nrBtwOYEfV9pNMSMYliQrvfssAQ6jRxPNJi77C9fzRiP80mezmCNNRyNbr4CCGZgu76fOf9TVzPviGwzGAhyF7qNLVkwDOs5w9crffAFVHoAIfs42pPKcXmJLcO/0N0NqyfVmBMl+ia9eXrbTvr4v9DRFebi0wtY4z+7b7W5YSE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:0ihQiPymlBf5KoQUeEzF4cW7y5p6tf+Xe9a5n2dMpV1yBwj4rWk/9pM8fTtlfhOfwlv6U1CzMWe2/47JGaHXA4XqGMPvvsuB10zIot0TSFcEqgFdfFwlACZZukHsbSFtp15LJylGOwuIcPjBJiZ9ydNCvJECGJX/4BwSfcbrmDWfaBWaeWW51/oxZmJCVG0HRq3gJufWdkvQgDFam4mLeZyWvNaUq1TcaXVLzDxzPTttncIZn7BHDYP/Tx3ifpr1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:26.2473 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 07/14] OvmfPkg/VirtioLib: Use AllocateShared() to allocate vring buffer 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 communication block between guest and hypervisor, allocate the vring buffer using AllocateSharedPages() so that it can be Map() with BusMasterCommonBufer 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 --- OvmfPkg/Library/VirtioLib/VirtioLib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 09a3f9b7f2e5..9ba64204326f 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -61,6 +61,7 @@ VirtioRingInit ( OUT VRING *Ring ) { + EFI_STATUS Status; UINTN RingSize; volatile UINT8 *RingPagesPtr; =20 @@ -79,9 +80,12 @@ 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) { + Status =3D VirtioAllocateSharedPages (VirtIo, Ring->NumPages, &Ring->Bas= e); + if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } SetMem (Ring->Base, RingSize, 0x00); @@ -143,7 +147,7 @@ VirtioRingUninit ( IN OUT VRING *Ring ) { - FreePages (Ring->Base, Ring->NumPages); + VirtioFreeSharedPages (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 Fri Dec 27 01:54:37 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 1502107193848104.12795203142275; Mon, 7 Aug 2017 04:59:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2CBB421DF9692; Mon, 7 Aug 2017 04:57:15 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0049.outbound.protection.outlook.com [104.47.33.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 68D1621DF9670 for ; Mon, 7 Aug 2017 04:57:13 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:26 +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=AUMDH8+1UU55FCtaQNMygQNLdlyoymPO9J6UQjB19Sc=; b=xfNfgDkLzKgNqKeezu+ehhzAOzjaCSduwa8xKoHmNWJs/+XjytcrvsfKNZqBQWTeE7+zwGlng8Ck5rVIFb87U6R4QV9Z88KgbOnWK3Flvs4Vf3XYIPT7C0DlN/Eip5NMMB7G2TNiHB73PLHS5euBZp7FDKFNSSI44h4pmXvZtTs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:53 -0400 Message-Id: <1502107139-412-9-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34426490-8698-4fc6-b5d0-08d4dd8bc0f2 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:WOEHf19m9vHZ4Wxr3wY9p+YbmPjcfl/I58boIsB21nLYLZm3cC3rJlo4MuRabMwWPgBrOAyLZQP8ug1eBKDrcKL5NeXTeaKoTR+0fcfYFsnLmQija2SRsjdcou98jtwo/bqf4pESr6WqjR8qB60sEw9jOvgM089Yk1ldJLL8bI5zgwWWS12yJ5OaWzm69egMe7NtZ2K4v4y0LGo+Bg3gHD1+fLDculiBLVSVflDa7gA8acX/HG6XrNLze5utBnZj; 25:teSr1FlnDbrQ0DW4AVKNrZHkBQLvkOmXHQipCHLEf9Lwgw+Ar/RmRKd0Rru2PXHaRo1acD404/wb/KbXOPFS5CiNSImQIPe6K377qhCmgQ6xoL8Yfb/EEKWKCfMBm/kaU6DHJZrfzmsgoq+3NW+x71zc3EhWVlBIlpu4cSKOY1D/6a8JfWL2z3tZytlEMlfp3G5Q675hYOxIa4/KtoYlrGFFSzfEoR9oQkeC6nTg/YFNEq2fYq6xIcmXavQxJb6EIm9CChCrsVoysR7tGkDch+ocPrPfiadPp9guxNHDspU3CcKYR0gSza94+f3kHviftJTkUCz1DnwOSwdTYC36kQ==; 31:SSmddKVoQc9NOIZ0xPOPu3Vh1apEWc1+YWZHl04Ru/a1cUGRVs6ALf99ZEMphTX80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R//lMjnsfe0Jq8/H8D3MSetelBd4AVqAFMWTU= 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(51234002)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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-Diag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KSxCJf6HJ/G1rkATPNCs/mZiK90x3nOmNndoJnXm0PMpkhkIZuQi/fF1FylhfBRBolDVe0gPbCwIe8nNiY8xiAZXjoAQ==; 24:PVmtxho2SOZ8Fcsvu9zzgkoIv4fIduGvqhcYIE0iitoKcGysC4B0Bjuc6nBmS/mOM1bSxgYFD5DFJfereZs4QuGHDcfPWjBPW/USWHv/PPc=; 7:3reOfJm2+8wd5urKUzVZKHooKgAmsxzKdxuCi6cSAEBmNlifJdyGhxI3RmrJgM9QP5OFJ4BjtB3JfDiIxG2VhpRp68WJgZ5TljgYEgx+bDLgG/w+1XMeYZBwUQbneuhj5XQcftjnDXhNMcfi4nporWvcarQ8vXs+XoauBJADB1Myy/Yd3eCbBuUd6GVIMksHMOr5GwYAkxzg5apBNfad5lvP7boLEobn9LkNRQ/tzp8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:IxqNxMI2hxUjN/yC9P9JIMvzNqzr4Eu6x2tWnPeoYyeksc/TtM1nGhdgdo8OmC5ZbzKex3kTbc+n6qkKdATAgdJUJ5KhOnXxG59SIULuSRCWmqVBOKtNuhwYknH0zkANWGu8A3o64YWIJcl+AB+EHAiZks2DNaE/CVSV/KPnMIFGBiAK4MwlSyXazQAsq11tuIg6C048F6FeJ0eQEFC8mOaIegj3vuWRp9qUObt2JiaS5akBBxKGeE6SggmgWk1u X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:26.9189 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 08/14] OvmfPkg/VirtioBlkDxe: Use DeviceAddresses in vring descriptors 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(), 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 newly introduced VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() function to map system memory 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 | 97 ++++++++++++++++++-- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.h index 6c402ca88ea4..612994d261bc 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 *RingMapping; // VirtioBlkInit 1 } VBLK_DEV; =20 #define VIRTIO_BLK_FROM_BLOCK_IO(BlockIoPointer) \ diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/Virtio= Blk.c index 61b9cab4ff02..324403543f24 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -251,6 +251,11 @@ SynchronousRequest ( volatile VIRTIO_BLK_REQ Request; volatile UINT8 HostStatus; DESC_INDICES Indices; + VOID *RequestMapping; + VOID *StatusMapping; + VOID *BufferMapping; + EFI_PHYSICAL_ADDRESS DeviceAddress; + EFI_STATUS Status; =20 BlockSize =3D Dev->BlockIoMedia.BlockSize; =20 @@ -289,14 +294,24 @@ SynchronousRequest ( ASSERT (Dev->Ring.QueueSize >=3D 3); =20 // + // Map virtio-blk request header + // + Status =3D VirtioMapSharedBufferRead (Dev->VirtIo, (VOID *) &Request, + sizeof Request, &DeviceAddress, &RequestMapping); + if (EFI_ERROR (Status)) { + return Status; + } + + // // virtio-blk header in first desc // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request, + VirtioAppendDesc (&Dev->Ring, (UINTN) DeviceAddress, sizeof Request, VRING_DESC_F_NEXT, &Indices); =20 // // data buffer for read/write in second desc // + BufferMapping =3D NULL; if (BufferSize > 0) { // // From virtio-0.9.5, 2.3.2 Descriptor Table: @@ -309,29 +324,70 @@ SynchronousRequest ( ASSERT (BufferSize <=3D SIZE_1GB); =20 // + // Map data buffer + // + if (RequestIsWrite) { + Status =3D VirtioMapSharedBufferRead (Dev->VirtIo, (VOID *) Buffer, + BufferSize, &DeviceAddress, &BufferMapping); + } else { + Status =3D VirtioMapSharedBufferWrite (Dev->VirtIo, (VOID *) Buffer, + BufferSize, &DeviceAddress, &BufferMapping); + } + + if (EFI_ERROR (Status)) { + goto Mapping_Failed; + } + + // // VRING_DESC_F_WRITE is interpreted from the host's point of view. // - VirtioAppendDesc (&Dev->Ring, (UINTN) Buffer, (UINT32) BufferSize, + VirtioAppendDesc (&Dev->Ring, (UINTN) DeviceAddress, (UINT32) BufferSi= ze, VRING_DESC_F_NEXT | (RequestIsWrite ? 0 : VRING_DESC_F_WRITE), &Indices); } =20 // + // Map virtio-blk status header + // + Status =3D VirtioMapSharedBufferWrite (Dev->VirtIo, (VOID *) &HostStatus, + sizeof HostStatus, &DeviceAddress, &StatusMapping); + if (EFI_ERROR (Status)) { + goto Mapping_Failed; + } + + // // host status in last (second or third) desc // - VirtioAppendDesc (&Dev->Ring, (UINTN) &HostStatus, sizeof HostStatus, + VirtioAppendDesc (&Dev->Ring, (UINTN) DeviceAddress, 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 && + if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, NULL) !=3D EFI_SU= CCESS) { + Status =3D EFI_DEVICE_ERROR; + } + + // + // Unmap the HostStatus buffer before accessing it + // + VirtioUnmapSharedBuffer (Dev->VirtIo, StatusMapping); + + if (Status !=3D EFI_DEVICE_ERROR && HostStatus =3D=3D VIRTIO_BLK_S_OK) { - return EFI_SUCCESS; + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_DEVICE_ERROR; } =20 - return EFI_DEVICE_ERROR; +Mapping_Failed: + VirtioUnmapSharedBuffer (Dev->VirtIo, RequestMapping); + + if (BufferMapping !=3D NULL) { + VirtioUnmapSharedBuffer (Dev->VirtIo, BufferMapping); + } + + return Status; } =20 =20 @@ -728,6 +784,11 @@ VirtioBlkInit ( goto Failed; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->Ring, &Dev->RingMapping); + if (EFI_ERROR (Status)) { + goto Failed; + } + // // 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. @@ -812,6 +873,11 @@ VirtioBlkInit ( return EFI_SUCCESS; =20 ReleaseQueue: + if (Dev->RingMapping !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingMapping); + Dev->RingMapping =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 Failed: @@ -849,6 +915,14 @@ VirtioBlkUninit ( // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 + // + // If ring buffer is mapped then Umap() it before uninitializing it. + // + if (Dev->RingMapping !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingMapping); + Dev->RingMapping =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00); @@ -885,6 +959,15 @@ VirtioBlkExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // Unmap the ring buffer so that hypervisor can not get a readable data + // after device is reset. + // + if (Dev->RingMapping !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingMapping); + Dev->RingMapping =3D NULL; + } } =20 /** --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:54:37 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 15021071973131004.6996766794184; Mon, 7 Aug 2017 04:59:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 619F221DF9695; Mon, 7 Aug 2017 04:57:15 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0049.outbound.protection.outlook.com [104.47.33.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C676D21DF37D3 for ; Mon, 7 Aug 2017 04:57:13 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:27 +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=smnO8r/DQzf/9O2/ne7B1EZfPDeZ6qipX19/BT5SjpA=; b=V51l6TAnN0mvfEP0jbeM4sLFS3hO/zwFGuFyPxfo1mkkwe7f9BUoQtEBF/SIhX6SfpXJuf3Yep/PAJadtjPs3EOhsClORvuCWxTrNEA6bNmCFhcJ3ABiJyynUt5emvgfHWjJRko5BVzzwgP98Fsm3u0/F76yJTlXektOh5YIhGs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:54 -0400 Message-Id: <1502107139-412-10-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7696ff2c-d891-48a7-9260-08d4dd8bc15b 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:MqmRL5NIql5Yog/JelXXoIacT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2y2oAevN9oQA/8WpSEat36kd1ySKHAP7jrOLXi++EHor2OmGTgpKlmHHdCUF5MTDYtXBYjlUA4GbcTcCpXXrf8G/ne8ibkHi0y3W+NkeofOaYx4tGSk0Y0MO0sFAwhDj9ZnYOZ/mDJr0Knyw+K+RECfk8mtqV3RF+8TqbZ0h+DMSiTCGtU9SNT16P1gYeAYB+5rwwhBWWLPXUF814i20tWhkXxRiPPOf8tB1hSQ70LGO10heqmm/9sdNN4s4IKeTMbNt8Jhk4B1YnwhFjyAKQ+ESlkJdQjQK2bNeNLeJLHGg0Uq4AATvsBhIRmXZ; 4:0uoC8Bd2216G9y+dJtIGwlHa/iDcgrzSSgqWOvegNjtSPFHOhlkyAo9BFIdSAJzlIpQADEiCM0wPPMskufz8P20yHg25v2nkhRa815A/FAeA+I72GJtadQ0Ks/yB5nJQdNAdOxHZVOja9BMPpMFLPKXM0Sz7AENGlkj8MhWQUZ+yx2A+DPbbJocyxxsHcjnBXgpIhIaJ+jTx1JQqHftPe4oejQjqePy+SN/vyzUxLWJ4sgEF/Iwze7IsG7LvDl4ULGg9k0Ld7byAmCtJuf105C0KUFR7kztHJYmfSct+mo+mUeET3LcvvyX/Nnc4oYQJznhMmAnaAfFjb/AzEqg5mml0knwS5lzNJhZIBREBQYc= 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(51234002)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:FlF5Uv7uQC1KI8Ysv1f2wI0x+KfF+aSMlqiO2IGr9?= =?us-ascii?Q?apzzH2R6OCSy8XPA1LBENf9nsuO5v+l3eNdiQ7O8YdF5ziOs5F84wtjlN7/x?= =?us-ascii?Q?vzJzCYYu7GTV88QQihRLJSXvAn9S2uAQoxOoDpHp6URPNLAOwE9yqkJnjHTD?= =?us-ascii?Q?eG4H47m04rPP9jfQDnlejUwUzjdi7ZI7YbI5mjVyHPFytbDtDGcsWmacjpXq?= =?us-ascii?Q?80sieStpe/KEgIn421mFdAcQdiiIQcYyQQqSYCnMWHBg5WW9Sq8WnHoFi9M8?= =?us-ascii?Q?lhIskCCUlEbBMWeQcPevd2BUzKLB4nhE3ENqI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Output: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:fQ3ViRWkf/JB9QG/YAtm7o3ZW/vRfXbtNZmSoGXgZmh2rN7fF6oPimYoUw94sZ+cRFqA3Ns2frOXHGx30K1IZI86QJdazatStqv/ia1Pzd5EQ7ZfFtRNUC8VHb2pEJ52iUpeAr2LDQ0ThaWN9G7g+2Iyc/eVSwm/vmhIfdrPtUigWV+90Ojr9IGC6JgKGX3LTTy2QcMjzoaNWbp2DKo2H1zK3a/GUQIU0lj2dG+yxWDXS0XEh774hFSjZWCf9CE/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:27.6062 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 09/14] OvmfPkg/VirtioScsiDxe: Use DeviceAddresses in vring descriptors 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(), 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 | 114 ++++++++++++++++++-- 2 files changed, 107 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.h index 6d00567e8cb8..bb1c5c70ef74 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 *RingBufMapping;// VirtioScsiInit 1 } VSCSI_DEV; =20 #define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \ diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index c2f6f412ff40..779104567694 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -409,8 +409,14 @@ VirtioScsiPassThru ( UINT16 TargetValue; EFI_STATUS Status; volatile VIRTIO_SCSI_REQ Request; - volatile VIRTIO_SCSI_RESP Response; + VIRTIO_SCSI_RESP *Response; DESC_INDICES Indices; + VOID *RequestMapping; + VOID *ResponseMapping; + VOID *InDataMapping; + VOID *OutDataMapping; + EFI_PHYSICAL_ADDRESS DeviceAddress; + UINTN NumPages; =20 ZeroMem ((VOID*) &Request, sizeof (Request)); ZeroMem ((VOID*) &Response, sizeof (Response)); @@ -418,9 +424,33 @@ VirtioScsiPassThru ( Dev =3D VIRTIO_SCSI_FROM_PASS_THRU (This); CopyMem (&TargetValue, Target, sizeof TargetValue); =20 + Response =3D NULL; + ResponseMapping =3D NULL; + RequestMapping =3D NULL; + InDataMapping =3D NULL; + OutDataMapping =3D NULL; + + // + // 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. + // + NumPages =3D EFI_SIZE_TO_PAGES (sizeof (*Response)); + Status =3D VirtioAllocateSharedPages (Dev->VirtIo, NumPages, + (VOID *) &Response); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D VirtioMapSharedBufferCommon (Dev->VirtIo, (VOID *) Response, + sizeof (*Response), &ResponseMapping); + if (EFI_ERROR (Status)) { + goto Failed; + } + Status =3D PopulateRequest (Dev, TargetValue, Lun, Packet, &Request); if (EFI_ERROR (Status)) { - return Status; + goto Failed; } =20 VirtioPrepare (&Dev->Ring, &Indices); @@ -428,7 +458,7 @@ VirtioScsiPassThru ( // // 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 @@ -437,23 +467,37 @@ VirtioScsiPassThru ( ASSERT (Dev->Ring.QueueSize >=3D 4); =20 // + // Map the scsi-blk request header HostAddress to DeviceAddress + // + Status =3D VirtioMapSharedBufferRead (Dev->VirtIo, (VOID *) &Request, + sizeof Request, &DeviceAddress, &RequestMapping); + if (EFI_ERROR (Status)) { + goto Failed; + } + + // // enqueue Request // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request, + VirtioAppendDesc (&Dev->Ring, (UINTN) DeviceAddress, sizeof Request, VRING_DESC_F_NEXT, &Indices); =20 // // enqueue "dataout" if any // if (Packet->OutTransferLength > 0) { - VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->OutDataBuffer, + Status =3D VirtioMapSharedBufferRead (Dev->VirtIo, Packet->OutDataBuff= er, + Packet->OutTransferLength, &DeviceAddress, &OutDataMapping); + if (EFI_ERROR (Status)) { + goto Failed; + } + VirtioAppendDesc (&Dev->Ring, (UINTN) DeviceAddress, Packet->OutTransferLength, VRING_DESC_F_NEXT, &Indices); } =20 // // enqueue Response, to be written by the host // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Response, sizeof Response, + VirtioAppendDesc (&Dev->Ring, (UINTN) Response, sizeof *Response, VRING_DESC_F_WRITE | (Packet->InTransferLength > 0 ? VRING_DESC_F_NEXT : 0), &Indices); @@ -462,7 +506,13 @@ VirtioScsiPassThru ( // enqueue "datain" if any, to be written by the host // if (Packet->InTransferLength > 0) { - VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->InDataBuffer, + Status =3D VirtioMapSharedBufferWrite (Dev->VirtIo, Packet->InDataBuff= er, + Packet->InTransferLength, &DeviceAddress, &InDataMapping); + if (EFI_ERROR (Status)) { + goto Failed; + } + + VirtioAppendDesc (&Dev->Ring, (UINTN) DeviceAddress, Packet->InTransferLength, VRING_DESC_F_WRITE, &Indices); } =20 @@ -480,7 +530,28 @@ VirtioScsiPassThru ( return EFI_DEVICE_ERROR; } =20 - return ParseResponse (Packet, &Response); + Status =3D ParseResponse (Packet, Response); + +Failed: + if (RequestMapping) { + VirtioUnmapSharedBuffer (Dev->VirtIo, RequestMapping); + } + + if (InDataMapping) { + VirtioUnmapSharedBuffer (Dev->VirtIo, InDataMapping); + } + + if (OutDataMapping) { + VirtioUnmapSharedBuffer (Dev->VirtIo, OutDataMapping); + } + + if (ResponseMapping) { + VirtioUnmapSharedBuffer (Dev->VirtIo, ResponseMapping); + } + + VirtioFreeSharedPages (Dev->VirtIo, NumPages, (VOID *) Response); + + return Status; } =20 =20 @@ -838,6 +909,11 @@ VirtioScsiInit ( goto Failed; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->Ring, &Dev->RingBufMapping); + 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. @@ -927,6 +1003,11 @@ VirtioScsiInit ( return EFI_SUCCESS; =20 ReleaseQueue: + if (Dev->RingBufMapping !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, &Dev->RingBufMapping); + Dev->RingBufMapping =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 Failed: @@ -965,6 +1046,14 @@ VirtioScsiUninit ( Dev->MaxLun =3D 0; Dev->MaxSectors =3D 0; =20 + // + // If Ring buffer is mapped then unmap it. + // + if (Dev->RingBufMapping !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, &Dev->RingBufMapping); + Dev->RingBufMapping =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00); @@ -995,6 +1084,15 @@ VirtioScsiExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // If Ring buffer mapping exist then unmap it so that hypervisor can + // not get readable data after device reset. + // + if (Dev->RingBufMapping !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingBufMapping); + Dev->RingBufMapping =3D NULL; + } } =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 Fri Dec 27 01:54:37 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 1502107200387684.3930758747869; Mon, 7 Aug 2017 05:00:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9BDD621DF9699; Mon, 7 Aug 2017 04:57:15 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0049.outbound.protection.outlook.com [104.47.33.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1E8B621DF37A1 for ; Mon, 7 Aug 2017 04:57:14 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:28 +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=CjS4f3zzSWFd+uyFLlubNRrMRJQSjPkECnaJTA6On80=; b=2HTIgU2V207vYNVNbaBClUv5b6O+L2DCjHeq5OKIE3x0Qm9CnWbbEMfk5+7UNZm7lowwKSLP3Kq/iUJTkI3P4Ahwyl/7WF2L17Qz+MdPMLKYFsPORgyTd3u1zKriBROeLGDEHUzM6m5EuSw/sdDvPiHf7YiI2G8XhgyJXMOCCq8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:55 -0400 Message-Id: <1502107139-412-11-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e7127d0-6ffd-40b8-9542-08d4dd8bc1cb 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:NHUxOPtWOyjjnKWfnR6Hp+5c9NnjrBRCMB16IkZjeP+uLMy6CXnB/QxBKohAnK832smuBEOT1BUo5xwabYcw6GYbel/Vz/BRt4SmJmCudbC++8BXKrUZsDAInh46dYcTsJ/mq7SYxrhn10DPeHUgszoSKzD6NdV00ynjdiJqKXk+S2e1h1u/q5rXa5ZvWOSYXuxcGn5O+m/Z5aniDF4VVWd442L7UdxPHC7ihKA+aQqOu+Jmmbx554jJLwQCsU2n; 25:MkX7mVyRCk/IR/FpZgcdyiyd4/itR2shlUoQk/tNpxT8mRv3dAtvS0aq+rdx1gICILK0hKFMcaJL2EGrWdcW3uDy8N0ObBfZKw3eMNcF0xY16XvjQcHESZVuqFm0/+hueUAt9kHnqE3zYPDu62TnvWr++bldb1DFfFm3lNhNOUoqHMtxRL6Rvn2s4aenc8BB8ce+HrigS6EJXpCI6QQquAKPIMukwfJCmdkGe2dAls4QWodWF5oYcJWWvcLiLbbs/N1sVCgGTTikZdRQotGBwrpYY/hZbeEwTDgZxJQ+PlUktf8ikCNS5iMqShmHCjyPfvuAEaOXpfXtioL332ZHGA==; 31:ZkJ3LunqSTawPB/hQObSG2hcaKe5WJnTCSJDE3ho5xpQotyzPWHCbLP5/3JKcZPAhkEzlq/3y2uVeMrBvN13Mm3r2pe9Rm6qcMm2hpApqrCdAptxOB7oKxUV9MfoAVQYK+vcjwOx5xPjEDaE1WdHRkgdJfIQRZJFig9QACXSF4uyjYs117v+Lcw8BRcMY3ynMGwLCOSfHPQ1zLEa8e60md/Sl1JzBEAROpSdYBNL8vg= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:TufGazYW1OTC1bp4hH4dA47fPrNU3gjHairEGfzwmmyGWiuA4KrWz7LuIFN7fG9vHkqeP4s9fE7nxYsXCVBrdOoO6Fz0YELxYe1jSmzx6Chlh6Q2jH2W30L97yJDJbeENL3THP/ESRJg/iB3h7NqoZ2ZHEPyo2+42+21MTMYWe+cI6aWg3vY4XSc/yTwxmcDEd2+6d8NArGpzrGhPrPaDyjWhYjIuk/VwTeGRkx9C6ZtipTHzI77jf7ejD2IFdwk+sgaBnRvdWoQiRbXCm4xYsNGTPetb2Vq3K2+UB8B/nTewC0lw/Zs86XcAcVjGaSE/DBMbdBFc7CQSgU28k6wqdmUUJigcYToRWC6/aUUYsu6HFhvxfEXll72NVSYV4F5EEjepFHLUt+lV/d1DuHMBooera+H/f97IeGknI/u8ShrVwACtyZIHUMoZDaAUto6fTNOR3rPVVSYumTRdIzchlh8Y4OxE4IkJDKPUvJoUGZfW+fXiN8BrZ1SIkOEk8cs; 4:6GRSMbAUdMu39/0Ric1mHosORS9WVr6/I4uK9Bi2QwdpNqyOtpYdtMJZPDrCvYRG+P3TM6OFkJQYlRICQjgGayFUwexTQ+k1HQHD1IqmcwVdEKYkrsDQCMix84c3zorfoXhFkeG3AnXRsGyGRMkFQuALYRfhCUx11gIWpaDR0TMdiqsYvyCM7Rht9uVtpcP5RTQK6JTUYjXKIsQfPWcI/xL7cqosTRCHU3pm2+CVRfqCODRq9ohj9SXs4HBijbcbgMA94e7UhdL2reMmaNx9f8sH8n197PkhQDwiD2t8xTAw0bjFZAboG1OtjSazLAKr20t/Y2brqjVYni7cpDmSDg== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:QmgKzY3yXQB53IIQPevNzCuGhRssnDdt18vwjB1F3?= =?us-ascii?Q?KFKOwlEhZN8eJudPP9G0Ihd7cZeDKID9ahCXSEr1k5MZzTI2c1ldyOHKxLUK?= =?us-ascii?Q?E6vAuaeXp/w2d4OOYSUygZ4VnKFTHu+eTjpaQlEvX6a7Tv1cetMgWHQKyHWq?= =?us-ascii?Q?J6Fk0tgu7NX+16cLNiGzbPLr4ZE3CNY4p2MjQh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hif6Uas5VSy9Ga/4Pwx5CIxkKrrMPqCYA5y9tFBwnajyoSPlwrM0oKljnkkPz4NZwD8pBG/2BJB2N8YxnpGlS/EM1Ozh4xrrqqusn7IsxQL+c2M3ThU7Cb+E9BJ49V3H3I6qgM4hjS6ya5EYKDBI03YE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:fRSyTGxUFlw6PpafRaM5EI6Gq+QiHkNrjaVE80mLqgJcHzfkTzjo+KjgMu+qNhq9QqPTLZSngGxetTdCz5v29ZQS+RgBakJrmdPiaQ9o5ehyHMdM8BZcTxAxJHqb/vDFqIeZk84q22eAuvhtlKXAnYFGRnFqfFcTDnykcJWp5TzQuU+dSWOJ+qz0m//kym2BERGKqXJG3Qcj3SSmf+J+uEwpgk/2S0lMrI6M64tb2KPKOtvm/T49QTDFk1rcAvde X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:28.3402 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 10/14] OvmfPkg/VirtioNetDxe: Allocate Tx and Rx ring 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 | 14 ++++++++++++++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 19 +++++++++++++++++++ OvmfPkg/VirtioNetDxe/SnpShutdown.c | 11 +++++++++++ 4 files changed, 46 insertions(+) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 710859bc6115..2964c946e26e 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; // VirtioNetInitRing UINT8 *RxBuf; // VirtioNetInitRx UINT16 RxLastUsed; // VirtioNetInitRx =20 VRING TxRing; // VirtioNetInitRing + VOID *TxRingMap; // VirtioNetInitRing UINT16 TxMaxPending; // VirtioNetInitTx UINT16 TxCurPending; // VirtioNetInitTx UINT16 *TxFreeStack; // VirtioNetInitTx diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 5be1af6ffbee..9eb129ca2006 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -88,4 +88,18 @@ VirtioNetExitBoot ( if (Dev->Snm.State =3D=3D EfiSimpleNetworkInitialized) { Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); } + + // + // If Rx and Tx Ring exist then unmap it so that hypervisor is not able = to + // get readable data after device is reset. + // + if (Dev->TxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->TxRingMap); + Dev->TxRingMap =3D NULL; + } + + if (Dev->RxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->RxRing, Dev->RxRingMap); + Dev->RxRingMap =3D NULL; + } } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 6d9b81a9f939..cbc9c51cb643 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -461,11 +461,21 @@ VirtioNetInitialize ( goto DeviceFailed; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->RxRing, &Dev->RxRingMap); + if (EFI_ERROR (Status)) { + goto ReleaseRxRing; + } + Status =3D VirtioNetInitRing (Dev, VIRTIO_NET_Q_TX, &Dev->TxRing); if (EFI_ERROR (Status)) { goto ReleaseRxRing; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->TxRing, &Dev->TxRingMap); + if (EFI_ERROR (Status)) { + goto ReleaseTxRing; + } + // // step 5 -- keep only the features we want // @@ -510,9 +520,18 @@ AbortDevice: Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); =20 ReleaseTxRing: + if (Dev->TxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->TxRingMap); + Dev->TxRingMap =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); =20 ReleaseRxRing: + if (Dev->RxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->RxRingMap); + Dev->TxRingMap =3D NULL; + } VirtioRingUninit (Dev->VirtIo, &Dev->RxRing); =20 DeviceFailed: diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpS= hutdown.c index 5e84191fbbdd..08524ab94006 100644 --- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c +++ b/OvmfPkg/VirtioNetDxe/SnpShutdown.c @@ -65,6 +65,17 @@ VirtioNetShutdown ( } =20 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + if (Dev->RxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->RxRing, Dev->RxRingMap); + Dev->RxRingMap =3D NULL; + } + + if (Dev->TxRingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->TxRing, Dev->TxRingMap); + Dev->TxRingMap =3D NULL; + } + VirtioNetShutdownRx (Dev); VirtioNetShutdownTx (Dev); VirtioRingUninit (Dev->VirtIo, &Dev->TxRing); --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:54:37 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 1502107204452123.21641837956736; Mon, 7 Aug 2017 05:00:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DF14521DF969B; Mon, 7 Aug 2017 04:57:15 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0049.outbound.protection.outlook.com [104.47.33.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7BEED21DF37D1 for ; Mon, 7 Aug 2017 04:57:14 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:29 +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=BC7x//gN5dw039pcx0lrefFsWkItYFUbUa0ZBS9zfeA=; b=aIY1P12JmeCrAQZOFnz/dwDe19P+vXqN8uIg+kVOJtRSJajBxo+uV7wLiXZtW5M7Rjst7iVfoxlmanSayEJQaJliipEL4INhEVsJzQJC9botDJZJ5dTyNh+zBJGc2gNJnqOgA/P6MXNn5w/aEjPyg8q01HT01kGbfxH0/QsTntE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:56 -0400 Message-Id: <1502107139-412-12-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8df906e0-af13-4000-71de-08d4dd8bc234 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:Oqkb+E/k+SmLcjyVel0ab3v6H6JX4WBRNE612/Bn0wQsrjk5xL9iauTPSckCy6LRA3a9iwpMimie4ll8jpiDauff/ftB2VU59U3KkelJgFfieTptOF4BD1gy1w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RARAe82pAqZpV3xeEEKcUnzHbsHvRe+c76cXsAjEFO8gxVhYkiv0RFeh5hWB2SSkB/9s6uBZQv+VgasxirPefn9Ld/L4ZkaGec3je/neko3RPxmfUojML03O6dr18WoIeG9Dh96+dTuObIH0NpbihSvkzu0ix1X06MN/ViPsQNvgQXEUQvz3COnt1VQK/U/DzYQm5iahZ6fyyTO/RrVKG/qNVV6SoLSfRl; 4:m2n8SlOXMf1oiPhyuWzfuCNQU9anV9DxvI3fO3IrKIxw2+rTrXZUhx4vjnyyGj3m4vilTbMXb9qTz4pS1wL5pk5s6C/CebbdfM6IAt8xw2INgkIS1H83TiVxbKi+21mA5ZLTvfXzQ0Uqe+4lawhxjpU+6estjOCMaS1VNAFJL8FAPsM/utnZ4i4jQbPv1173YnUhFoB4cd+Jx0tv9KEjJMfSetPst5RU/hC0aobwfS8z1Ee8AF4F/euniX/svDHkO5G34y7NUInqo/PZ50m1vkcSo/qi+BXKKKoKLJ5KpvFZqjF00VmC+IqhhEdKX5O6n38lKo9V8gLrhoRO39+M3A== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(6029001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:NTSBD7GR54NfF02sSNqHV35P3wgSEnNSdrmr2VDJF?= =?us-ascii?Q?9M5z7FV7KDgG60i6CzPbhMqsDt5qqzyFIAMHhIU6e0PoSG1ftriyBXaNHz0e?= =?us-ascii?Q?qBzbLj196cE4sgtfv06GD93B8D98opm97bRbaFq5wNgr8XZDzWbqiJFU/vaq?= =?us-ascii?Q?e8/MPGNXNxD8XP2VzKvHg1CiJeiNSl2VzZBTXM+JYzosrVNEnltvAYJm3h64?= =?us-ascii?Q?TgBDEO336dvs7LNUkDoLM/2nZCe/zmBbaJFuBijYX0al86W0hDiL2OGdWjOF?= =?us-ascii?Q?l04+nNF+XFhGGJYv6TZY0nFa7+xQWp/rw8w3ZXxf1J3p85aDVsWupKCfWUTk?= =?us-ascii?Q?Ry7U/EdywFTjjJJ9G2L72zNhxm2SIccUdgXPbMCirJ8s8eNwFnLMiQIMULvM?= =?us-ascii?Q?cN+Nt3j0uy0uQ6x/it7k37DWoWu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98q?= =?us-ascii?Q?HXrWDSTUkjIZTago5OUZcvGTXjZJ5boleqB+4wIazye?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 6:RA2QPbWpt98eNpPBgJCWAXZhSqA7wEB8fAkWHdzEXvXamje+kClV5xdEX+bZWlA99Ps8vKt3kbjwWlEz8uxiT0jVFg4ansLB51H1BQ+f6Po/5bWIEzqbcjiaMnjzPZo90vGzkA/2z4nPneNdS4z4SId5MJ9xBzC61uUSEqivYXeDFopzDFxmEdgYl+CJdDox3DZG4NHx75ig3lYLFWep1aqdrL7q4EaydndodAzIVWbYzaGha4fQ8VG8314SgQNpUmGvlHUZAEdL7/oc+pZfDrT6SUUH7wLjWO9fN20Gvbt/wk3lY73keopnQhWKr0LmhamCfrbdn8+WVoYglaGPtQ==; 5:B+4OMl7O0+w9ld3VhMFf5J3iWBaHjZVxxMQkBiI5eS7uwDrD7eJbTatWDY1jhfp9Pj7jgS+/gGkb5E+YacA8GZ55KEK5Xfn+CjK4mERgE1/SrEYpBAyIUc56cRO4/z2FW0Pl6UtsQP9+qMcKw/ZP5Q==; 24:st8FJ4hLsuEu0Q0VtHMAFK0XoExRD0vcsdvIblGivEvw226+RvJYrxU9n+l1FiDO3QMwuXwnccUJFD/7Cpq6vF/65kZe3FHzJywVzafqnoM=; 7:QGZwGfMoNhRUzkzXnsQQpL7UmFuqQ/e4hcYrELboJbf80jSYgD2BudIik3YvxMKPVDToKKKCSDRJqhWQvtS2y0YmAszgPg7bItAz7byxPecoWf+sEcfVEX/tk3XyH0foooLru1GG/Hx2ljCRlKdic4bpzUhnSsEaWx0+rDzxMdNCA3EaAKmTJ5VfkAf5RhtnEOCpr2YLVnLlbAcf0oxAgeft1oGK3EJMsKkCTKZZ7i0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:f3MmoO1s+5FqF2QGC5L/g0AVoCOAU0ROpMZtwX1MLY3xvhs4Ies2rkhoE6Gm4jqekuoQOUHq+9amVZrTMsBCLikdrs+b8/fx2DrQnbbSXpTSyKPBqt7uTdfGXn2lUzdxQK5Gwgm3RGoMVHHKzLiD8ZGuDjZ9vaOpUApHhtj3EY6tosTO6Gz2WrfmD34a5eMVD72NpIz4J3Fl4XLvIT2PcrutbMHyGE3ICQvSp2HeAVNdfMlNem8vP1mH0U1G0f4V X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:29.0275 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 11/14] OvmfPkg/VirtioNetDxe: Allocate 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 AllocateSharedPages() to allocate this memory region and Map() it with BusMasterCommonBuffer operation so that it can be accessed by 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 | 5 +++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 33 +++++++++++++++++--- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 10 +++++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 2964c946e26e..a4661bd5d2fe 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; // VirtioNetInitRing UINT8 *RxBuf; // VirtioNetInitRx UINT16 RxLastUsed; // VirtioNetInitRx + UINTN RxBufNoPages; // VirtioNetInitRx + VOID *RxBufMap; // VirtioNetInitRx =20 VRING TxRing; // VirtioNetInitRing VOID *TxRingMap; // VirtioNetInitRing diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 9eb129ca2006..171b144518a9 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -102,4 +102,9 @@ VirtioNetExitBoot ( VirtioRingUnmap (Dev->VirtIo, &Dev->RxRing, Dev->RxRingMap); Dev->RxRingMap =3D NULL; } + + if (Dev->RxBufMap !=3D NULL) { + VirtioUnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + Dev->RxBufMap =3D NULL; + } } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index cbc9c51cb643..59c9f1ed3516 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -244,6 +244,7 @@ VirtioNetInitRx ( UINTN PktIdx; UINT16 DescIdx; UINT8 *RxPtr; + UINTN NumBytes; =20 // // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depend= s on @@ -268,9 +269,24 @@ 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 using 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 VirtioAllocateSharedPages (Dev->VirtIo, Dev->RxBufNoPages, + (VOID *) &Dev->RxBuf); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D VirtioMapSharedBufferCommon (Dev->VirtIo, Dev->RxBuf, NumByte= s, + &Dev->RxBufMap); + if (EFI_ERROR (Status)) { + goto Failed; } =20 // @@ -333,10 +349,19 @@ 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 Failed; } =20 return Status; + +Failed: + if (Dev->RxBufMap !=3D NULL) { + VirtioUnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + Dev->RxBufMap =3D NULL; + } + + VirtioFreeSharedPages (Dev->VirtIo, Dev->RxBufNoPages, (VOID *) Dev->RxB= uf); + return Status; } =20 =20 diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index 9fedb72fdbd4..48cd4900911c 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -39,7 +39,15 @@ VirtioNetShutdownRx ( IN OUT VNET_DEV *Dev ) { - FreePool (Dev->RxBuf); + // + // If RxBuf mapping exist then unmap it. + // + if (Dev->RxBufMap !=3D NULL) { + VirtioUnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); + Dev->RxBufMap =3D NULL; + } + + VirtioFreeSharedPages (Dev->VirtIo, Dev->RxBufNoPages, (VOID *) Dev->RxB= uf); } =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 Fri Dec 27 01:54:37 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 1502107210319795.3911368990869; Mon, 7 Aug 2017 05:00:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3C4E621DFE900; Mon, 7 Aug 2017 04:57:17 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0085.outbound.protection.outlook.com [104.47.33.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 1DB7921DF969F for ; Mon, 7 Aug 2017 04:57:16 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:29 +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=1h1RLOuEB3SdUkAR7BnSPoXHYqbdS4tUg0ZDcOu8kng=; b=KtzSRfoKBkubz/e/yInexrGcfHiVKaLYJnKXwZtGX5jKh/EmIhPJYYf4Gd3VxF2cid1MKYDly43AKas6bIw8awSE4GbqsKuBcPFpyHMyprz89rKbRCZn186gM5VpZiOPlAxra5jpVzlUEOcrmm9CxDLfNiVxe2Ewnznb3A2Amqk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:57 -0400 Message-Id: <1502107139-412-13-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5758ce0-4720-48bf-b08b-08d4dd8bc29f 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:GLM7PJ+Kl6McBuUE1s3exBA6v5XcI1Um2W4fAL6K6EyPOBbyosN/c0TQBRcMNDATqKPWWoDR0lPx0bd2VscxUu2q5jX9ZR5QNPw+MAX7wnGMlpgyHGz9cgxSlrrgfuzk6qEAs+3TDpJkSjQQkPer7oCqfmnekuDOo3IxUuy47nEP8fUgOPMJj5eqMM7tVu6Eu3LbayHIwFSXwcI/1hoUTiMn/uHOUG34iJHPTNe8BkJ9lztJaesH5N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CWytb14K/cP0tqWE/gTtHe6BqWwo52zYItILx+GMcXeM2oIhcd6V4B9/LvDzSMRfWFzP/Za+yIpWvW5cdEB1aXAvW0yau; 4:BjVUe4x9Dj400p8ckPRpDZhjGoo5knuLZkGpkDj5CQ0iZAP2Ux0QFT2HNJIJopexEDvAAS3Bz0F1SHnqyp7bTJkWakh+X+LVEy+O2LCJa03nqnJlhasCx5vlElzW9hGUivjHNnEmaNO4II8R4UEAC/GIiWepqmEFze3NHawpEZUVeOP2bFo2U/2mhDoeKjnpMMa+Qp71TGigPjqPwww6ZWuo2N6ElTY0+OWkU0XlUMvAnoIGeSOCsmV5R+FbEv/ovqyGYB1plGVrd5Rdvqv4jo1Iz1mSUUSJ8UIduvBuaWzwh90imk7ehxQ3PWLWnO2Mbr4GJ8nxwxz8K+KobeInSw== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:VgsFtWesqNKY5+yrAGtw/NFzJOOHbA2IFQU8x7rtT?= =?us-ascii?Q?3MoIPJLHfx+5XLljUBTo5KtB6wvvA27cGL6E27KK+UBaLjqquhFtlzSreWXQ?= =?us-ascii?Q?2WcfWTAP7hG5kDL3m9TLyfUseD+ASILqcvXsfNVFuB6bneNKhHDMi2ZbARAk?= =?us-ascii?Q?mJHhIGyZfRygLdp5VR0AEDrg0EACvwjgXHYthpMSfvaSwaUvJ3hxZGa+O0q+?= =?us-ascii?Q?Rs4S5ujJyIgi/KNcJa9VIeTf5EGVsQIm/FisqagU0A/j4hS15FI+8jxYNhK0?= =?us-ascii?Q?YngZOqSEcK1aXaa44DPsqilsi5yS5ftNE/SxpaMBUTg9HCLByP5W1rh+VnIf?= =?us-ascii?Q?qkmveeyKUf2pe+8D3KTzXqgcrxZgy8E5d/6WWRPzTsn/auG6h037ocBVEVR3?= =?us-ascii?Q?TQN8EnhtdENxjjirpKxHG1PKtwsuATycPFW074AZ2noNu+9ISPdwWyiLTKLe?= =?us-ascii?Q?8I3WFPZS2xpi6N82AeoBAPmiuEuEf7U5Jq1YeL324TuIWiN8LwRepny3opjs?= =?us-ascii?Q?ok9wJ5VXVO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X4IOP3RX0Sr7bvjVKIGBLNlngq9XBfBTlRonq5D0UxrEaao0vyBSt7h5LGx X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:29.7303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 12/14] OvmfPkg/VirtioNetDxe: Dynamically allocate 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 then 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 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 | 5 +++ OvmfPkg/VirtioNetDxe/SnpInitialize.c | 41 ++++++++++++++++---- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 9 +++++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index a4661bd5d2fe..873069e9de82 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; // VirtioNetInitTx UINT16 TxLastUsed; // VirtioNetInitTx } VNET_DEV; =20 diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 171b144518a9..0004898eab6e 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -107,4 +107,9 @@ VirtioNetExitBoot ( VirtioUnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap); Dev->RxBufMap =3D NULL; } + + if (Dev->TxSharedReqMap !=3D NULL) { + VirtioUnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap); + Dev->TxSharedReqMap =3D NULL; + } } diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/Sn= pInitialize.c index 59c9f1ed3516..9df9f7af32cc 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -18,6 +18,7 @@ **/ =20 #include +#include #include #include =20 @@ -139,8 +140,10 @@ VirtioNetInitTx ( IN OUT VNET_DEV *Dev ) { - UINTN TxSharedReqSize; - UINTN PktIdx; + UINTN TxSharedReqSize; + UINTN PktIdx; + UINTN NumPages; + EFI_STATUS Status; =20 Dev->TxMaxPending =3D (UINT16) MIN (Dev->TxRing.QueueSize / 2, VNET_MAX_PENDING); @@ -152,12 +155,34 @@ VirtioNetInitTx ( } =20 // + // Allocate TxSharedReq header and map with BusMasterCommonBuffer so tha= t it + // can be accessed equally by both processor and device. + // + NumPages =3D EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)); + Status =3D VirtioAllocateSharedPages (Dev->VirtIo, NumPages, + (VOID *) &Dev->TxSharedReq); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D VirtioMapSharedBufferCommon (Dev->VirtIo, + (VOID *) Dev->TxSharedReq, sizeof *(Dev->TxSharedReq), + &Dev->TxSharedReqMap); + if (EFI_ERROR (Status)) { + VirtioFreeSharedPages (Dev->VirtIo, NumPages, + (VOID *) Dev->TxSharedReqMap); + return Status; + } + + 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; @@ -169,7 +194,7 @@ VirtioNetInitTx ( // 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 (UINTN) Dev->TxSharedReq; 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); @@ -184,13 +209,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 diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe= /SnpSharedHelpers.c index 48cd4900911c..3ed7132be531 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -57,5 +57,14 @@ VirtioNetShutdownTx ( IN OUT VNET_DEV *Dev ) { + if (Dev->TxSharedReqMap !=3D NULL) { + VirtioUnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap); + Dev->TxSharedReqMap =3D NULL; + } + + VirtioFreeSharedPages (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 Fri Dec 27 01:54:37 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 1502107215582819.3625016819801; Mon, 7 Aug 2017 05:00:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8135121DF968F; Mon, 7 Aug 2017 04:57:17 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0085.outbound.protection.outlook.com [104.47.33.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 7C48F21DFE900 for ; Mon, 7 Aug 2017 04:57:16 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:30 +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=OysvvNApQbVbtXntT2/zVZ7IrSS5FxJkMd7jjasGnA8=; b=0UFoBaqf3zRDsxLFJOxpFxSYdyAxMB91CV1zPfV61YCDGi5vNrVSiMwQp62fTEl1tEE0Ukf1YGw/m07UN7EHWPC/5s2hNmQlE+ivP/Yz16SUkIdjs11aeO0HWuWuCZienZ89k1uOmrCrUd0fou6hhhPB4kGn80A8VYS9inn5MMo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:58 -0400 Message-Id: <1502107139-412-14-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9077e851-7c08-4399-1591-08d4dd8bc312 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:4/DK4j1ZMd5yXQX8I1krlHhLT/pyjn0GqAEOm/RHkPTxbRX6TlLXDelJiGKMZCD7IB49CSSkGn7n/6Zhv3lwXbMH9YLokt7y+mmexWpsU5LjBexEuTtZ++z3fSZHhqMyK3uxMJK/ryBDtBn1BL7GarbXEBYaZYapPfNRTw/LAzpZwKP+cmu44XzP1u3BReWIuVU9NhsBlWsGk9UMt+byEwbiPJvJ11ekg7p7Y+W+6N5IwH7t5uA2dqCUkYlmcaBx; 25:nNGvBKCIdpIz7P1SIGq5dDW2uUY4S1XFK6M9dpYReiKPlcvCvaW+xhSRRrLdyRC/ofdDx/Dba5t9exINNysvTyARzgWJ/xA+PUqb62NUkj9BoIYs1BAGKT9WWwINTCWOLXppBtOTiQPuV7j9gbGASO51wIa02BNOzo1TQSFTSWjV6mlGdGWB2O+SHvDVZIP+dPEAuMeHKLjSqL1L4fBFtKixXnNq8r/wAFGjti6dRYWzi1nCGVyhaqGSxtzj4FUpWKoylHjtiYprmMRLr9jRnpawxJuTL+ATMGJfkX6aHpXYp95liR/c2Dkb/vL06RPGroTr1XtOR5hJWmu0YdrqwQ==; 31:bxDIh7SgdU0J0BI1F4i9KUtaXsi9lAmbU0uzRYiPC31z3Un4oG4dqclq2eJJOGtzN6ZJfgHkKxiEsSpzFv06iHKPKehPiwfIa7ALXpFYEDCjxW5IcdkW56pecFWiNz5CPNxdeZKygcLOmYZ+0z7y7JhTSTxNXvKwhfvnXVPeUS1KAytEof1Z/Wl82JHLJbi0dAfeZgE0P9RWuN5FwnAyr5DMoElekgkX8w11SPODUZM= X-MS-TrafficTypeDiagnostic: SN1PR12MB0159: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:pP5JjwBczwu7bSF1lolrRlmmCd0Jl7E5hQfX3BMSkRF7i83ds8bIV4Dhi9TkZ2ypa8/QilEUHl61hpHZJ347EjudVe13WtfUqu/YVwHWb0r191tB9ROqvaYvzhAizb3qFk9+t/PND6GC17b9BtZ2iZJorqVBjix43GlsrvtJAXOHg32GXFkp1S4kcz4hMc6BoF2J5NGHnfijjObZg2vUr5aOwymJSlW4mBaFJXVH2m8xmrtxQAjhOmAkLZ045aELcrNYPO5Keca1/gDq/WQZ0jZPSwmOTTnDcMr+P3WUqyUhr8NSnmP+bDxwUlEl2cUxAYinBCnsgxm/Q+ddtcbY+G2DYKdvUGf/c3lNMI4pJYblJWOYJJB9cyGx38ZfGw/TKOKYD94kdPFTuykh8l1OPFxZfe/Fl/PgStikvHgFiZlNxpy7lHO/dJUVcCafHcKkIfSvW1zLAuyOtkhRS/NVEAFXzMxbJojIsWOD2K5I5W7zuQErGiwDWvg6kZBjzO0F; 4:akEtWLHNYSHxWPIEn72Z/+aZ4q/hxjutl/Bkv/S94PprPmxHeQc6uDBoa30f17EVKzVWZj9woiRvA877DYJQ4+xlhWSZlPJpeujANd0PdQ0NSSe6KQF6aMbZGihTuMk1bemdPyjTJ+FRFuVfFp6fPabwRDielPwi11Y8zcUjevNwVtNCICetkjfkEgHUojhcFW7qCiQvMPR2QOdBOLy2TQikOycZMcgn3d1VdBH9p7t1ykI1W+be0KDvW/K7a4xa1UvKcWlSz/se8FT/yw09DdOOT7mNc7J88rZpRQ5h50lpCMklSVJ/nUN0oFmHiinhAN7yzPtwnFdD+psaOCNv9ZS+jRP2QswpSay5Ya3Ft2o= 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:J8YsHVCp7SBUXlSBPcxQvSGm9/qIFiq4QoC38rieX?= =?us-ascii?Q?h8Hw7OJsTutUSnmjbE+oCPrVuU4ib47ZSHOok9RFc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RJQ38muQtApFjtPrzg45Xg=; 7:8eiYCFTK/jhVbWYArwRdTEyVpSRFTMW9PEFZTFa4gIlMwJ194Jx0oD9SH2xVXroq8bBZKzv0nlqNqjgbKNHuxbLmsVY2XF+vLLrgBbGiisihN4DbtNlqCABCfiq4xmSYRHpOlKkOCtYZIzIubOj4374wM5OPxxWZD0r9vT93cSWPWgXcYh900jOgSCPCiGkZVq+v8051UgtDo9Z7fl8EZyzeb6ZRtSo0Umhm+Yejih0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:WPMyGvy0+YkFcXQNk/Iww9v+8ODWRxTkkqtpyNwoiWVCla7b652HxYLQpLmUTNkz5DXc4J7EQsi7FhJI8n9it1zrimYcDKvmvufNHzxJC9Wgj19l0kq7FiXMKCvZHRzLToM/9T5smpcypvlTIsMY8P0F9RC6z1iDpB5AxmWlGs/BCCSpavF+YXqBmb+qsz91FiesfE9yzMKwmKm9gauplvLfpJ8vb0a3oMdFrkQ7vrR5TtgHWiFVQ7scrb9UqRvK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:30.4800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 13/14] OvmfPkg/VirtioNetDxe: Use DeviceAddress in transmit vring descriptors 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() to map the callers transmit buffer to a device DMA address and use the DeviceAddress in vring descriptors. Since the transmit buffers are returned back to caller in VirtioNetGetStatus() hence we maintain a list to map DeviceAddress to HostAddress. The list is consulted to find the correct HostAddress upon transmit completion interruption. 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 | 19 +++- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 100 ++++++++++++++++++++ OvmfPkg/VirtioNetDxe/SnpTransmit.c | 22 +++-- 4 files changed, 149 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/Virtio= Net.h index 873069e9de82..6c5129f178cd 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..ddea29e65d57 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 @@ -126,8 +127,10 @@ VirtioNetGetStatus ( *TxBuf =3D NULL; } else { - UINT16 UsedElemIdx; - UINT32 DescIdx; + UINT16 UsedElemIdx; + UINT32 DescIdx; + EFI_PHYSICAL_ADDRESS DeviceAddress; + EFI_PHYSICAL_ADDRESS HostAddress; =20 // // fetch the first descriptor among those that the hypervisor reports @@ -141,9 +144,19 @@ VirtioNetGetStatus ( ASSERT (DescIdx < (UINT32) (2 * Dev->TxMaxPending - 1)); =20 // + // Unmap the DeviceAddress + // + DeviceAddress =3D Dev->TxRing.Desc[DescIdx + 1].Addr; + Status =3D VirtioUnmapTxBuf (Dev, &HostAddress, DeviceAddress); + if (EFI_ERROR (Status)) { + 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) HostAddress; =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 3ed7132be531..6a6866e65b5f 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -14,10 +14,25 @@ =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) + +STATIC LIST_ENTRY mTxBufMapList =3D INITIALIZE_LIST_HEAD_VARIABLE (mTxBufM= apList); + + /** Release RX and TX resources on the boundary of the EfiSimpleNetworkInitialized state. @@ -68,3 +83,88 @@ 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 VirtioMapSharedBufferRead (Dev->VirtIo, + (VOID *) (UINTN) Private->HostAddress, NumberOfBytes, + &Private->DeviceAddress, &Private->Mapping); + if (EFI_ERROR (Status)) { + FreePool (Private); + return Status; + } + + *DeviceAddress =3D Private->DeviceAddress; + + // + // Add the mapping information into internal list so that we can retrieve + // the HostAddress upon Unmap(). + // + InsertTailList (&mTxBufMapList, &Private->Link); + + return EFI_SUCCESS; +} + +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; + + Found =3D FALSE; + + // + // Iterate through internal txbuf list to find mapping for a given + // DeviceAddress. + // + 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 VirtioUnmapSharedBuffer (Dev->VirtIo, Private->Mapping); + if (EFI_ERROR (Status)) { + return Status; + } + + *HostAddress =3D Private->HostAddress; + + return EFI_SUCCESS; +} diff --git a/OvmfPkg/VirtioNetDxe/SnpTransmit.c b/OvmfPkg/VirtioNetDxe/SnpT= ransmit.c index 7ca40d5d0650..20c56c12df04 100644 --- a/OvmfPkg/VirtioNetDxe/SnpTransmit.c +++ b/OvmfPkg/VirtioNetDxe/SnpTransmit.c @@ -73,11 +73,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 +145,19 @@ 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)) { + 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 Fri Dec 27 01:54:37 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 1502107219871155.48202644456626; Mon, 7 Aug 2017 05:00:19 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BC3F821DF9670; Mon, 7 Aug 2017 04:57:19 -0700 (PDT) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0063.outbound.protection.outlook.com [104.47.33.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9B37F21DFE904 for ; Mon, 7 Aug 2017 04:57:17 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Mon, 7 Aug 2017 11:59:31 +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=IlLH7kBjNSe5tVQOXkNUYIhQJonIrxySuj7VBYQSEF8=; b=m5dL4rSxWcMe6Yhd07NWJFKzxO5KgIMj59upIZ+yg28vMWvHLU279IPbm3M5nS9QV7ltPo8k4J3pr2iQBbZWO7iZWIh5VTsYAYzq9vx0D5U21UnPHyHLEgZzfniGcuAFrlugzfvJ2doygOiJGqt2nVf2uYYxjhq+hY4srLMqwHo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 7 Aug 2017 07:58:59 -0400 Message-Id: <1502107139-412-15-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> References: <1502107139-412-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0033.namprd04.prod.outlook.com (10.172.133.19) To SN1PR12MB0159.namprd12.prod.outlook.com (10.162.3.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c97f3f5-a9fa-47f7-294a-08d4dd8bc395 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:SN1PR12MB0159; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 3:l22PuZtPsOSPq3iYWEnUWuLbmLajMYAH7EZPtjiZN0kugdlc05fjbvvXXRW05CRWx/okbY8UU61jkM3nRXApXxAJyjMXMiz3JhUAOEb9v+4dxYWv7AC0HlLmTzJaf+hlpskF6B0TmSikfRTO81mvhOqfX1c/D3pZ0wkOAinH6vYJ4iflkP08Toer/3XVAF5AV0kYULZ9E3OfUTM2VK+kSVHpargbClD9uM0KYMcypF+zjXRdnax/q+QlQHwi8xWK; 25:qxlGYFi1139ZowYjN1X7ANCPm8/uRZEjPocWxrdev/iGO08HudivCtmK9wC/ZdWlb3a4OoAF9nkQ/k3hMA0TKJrfQP6mSSQ6wKalWgnIMHusJx0ws0tz1i3VTn1WuDWpy3md0a+puUmGxKgcyF1/3UoIYBOtIVvdc9L2k1tRg53+Gx+Gjrh62BwCwQjiNMbiIOWgUsBz2yVESTg/Drwccd/JrIfCJXBs30nCOEKhy172pvUhWej7Iy1mM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pEo1TkCHc2+DkHP37egW3z3z6UQdCd0+X/vKyFDlwSrIE27RKE52zmHC/iAFKA+/8wwWPU+MEjOQP4S6ZXa3y734ylXOJ23Lg8Osd2ihTX2uNVVX63pZscSUPjnZfpa5lBnG6Q1q9rxz590tVdQOGNRkhcO7Ya06BgpIzkMil8v1TtfAQ== 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)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0159; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0159; X-Forefront-PRVS: 0392679D18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39400400002)(39850400002)(39450400003)(39410400002)(39840400002)(39860400002)(199003)(51234002)(189002)(3846002)(6116002)(5660300001)(81156014)(81166006)(54906002)(8676002)(68736007)(50466002)(53936002)(53416004)(106356001)(2950100002)(105586002)(2351001)(42186005)(86362001)(6666003)(5003940100001)(36756003)(189998001)(33646002)(6916009)(97736004)(25786009)(2906002)(478600001)(110136004)(47776003)(38730400002)(76176999)(50986999)(66066001)(4326008)(2361001)(305945005)(50226002)(48376002)(7350300001)(101416001)(6486002)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0159; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SN1PR12MB0159; 23:VY7+V5bEuXv5lXe2yADgRWh8jTxCyeNq0GluZMNnR?= =?us-ascii?Q?k2EfFY5ezEHhmEMSOBAP2YvZLXbNUZ2/5rI8aYaYoZdOJJCHHUQ8FC7B/50v?= =?us-ascii?Q?qGKdsZPhayM80m2IZ1VpnlQkbopsiodGWOPOxHMzm+ABOTHNcCH7vyp44pDQ?= =?us-ascii?Q?ibsFolxMtdcl1x0Tleegj4yLyvZYwie/rHA3EyPkZ3rBSyimrZVAiRT6D1eB?= =?us-ascii?Q?/1D4jtpZWSkTU4N4xBTQRIjwqionJfWnLPRyCfej0rDiek99rvpRdcTO9KRn?= =?us-ascii?Q?G7lUKDkk8mGmsxBf++7KH5YvGcgo14QInkcO8Vlb1eYxCrBFGXzsZaOFep/V?= =?us-ascii?Q?wJpzlc5ah4LE84ZF+mS9Qck5iYy5++9bjwHcvreGIBBkMK+VIXiUw5CuoLbI?= =?us-ascii?Q?uOtEpMavc7esNQB2SIUIwVoPLdgqUmzyFsm075cod98kttntM6RHriCMfVCq?= =?us-ascii?Q?XqKLAOzlLfGw6uoBPkkoajZfrT8DQUAPIOozGxNQvdmWggygMWIzqelbaDhr?= =?us-ascii?Q?+OuhsLqKgS+JeGWLibnTsax5EywiUro3WBOj0xx6HQBcrHKqeVISYWLgb16n?= =?us-ascii?Q?ZA7+O2XlEpiaW3P+rToLG4mTgKGSbMhvcNAlqa/NxjW3LMR38K0KhUX5Z0av?= =?us-ascii?Q?BHJXdrh8FazdT+KkE+4UYfzF+GHBPL62HUzJyn21YjF9RpDoONZyKvwjB2LJ?= =?us-ascii?Q?8JQrKCyRQNEPFFGvpioVKWwB6iarW9G3dYu54Zd9BVPGF13eihW6E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7B29ztAh38uIc8nZmNcabT/Gj0ionPJSNk1w==; 5:AM9kj8D4SzykY2t85+kHDML8G/eyuhHA8tTNgYKZvdpiwL0NRnnMzrfN5m6aeoSi/3ZzJrtue81GnnTozYqF/0yQDtCb0CwtvoSc9j8hfMwUBW7m+nVk+9AmaEqlxtCTcWyY6pqfkiJH7pSVi1knVg==; 24:TKn4ANHNe3nZWJsZZVWigVjYCZjqdLfNwB+WTbYrnYeHqY+QU9wbtEdZ+kl+PM9RPbOvD2V2SxGgNIyqOEnSt7znM7wxU3CFFpY65YLlFq0=; 7:ZKQ6X3Lq3+N9xPv8ChLGp1hQBSGlNE6mdW90sYQpDh7aq2W/VMLv+hfBjY2DinLMNZwvLUPLmtp5ASqRECjiaD/ScLvbV4B7KU0LJ4MND9oyltf3BleF9AyENl4wE315Q4NZS10O8QBIUNhaf4SV0HmYHj8vWuNprTDSW/kv1eiiHyOUA7VaBJEhA+b8WoAlHfGoKvU2kpD+hlDRVuRKtQk6h1mwB84eZa7loWZ72DM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0159; 20:aZGy5e7Z6WblstVoPv+jvkHdPpWGclbkADM3n5W2acEt4lk+O+IgPAl9u0iSUg8iVjNTM3nRvZ2XDMxcQpVlKw91XmfunqiR1OgYqETvTgfvaHFwtwtjBCXaE7ron6I+4e9hSWLq871imqsoSY+WLlAPDliYHNaQdzn5ffPWkDZyoFP3YfO/UiuNjUo2SERlwczLY0CfhAvgeYwmseY8RdY8e+QimW1LDotSR+rbeK3EPIwPTzKLSSkrb6YU8gsB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2017 11:59:31.2609 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0159 Subject: [edk2] [PATCH v1 14/14] OvmfPkg/VirtioRngDxe: Use DeviceAddresses in vring descriptors 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 uses newly introduced VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer() 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/VirtioRngDxe/VirtioRng.h | 1 + OvmfPkg/VirtioRngDxe/VirtioRng.c | 47 +++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.h b/OvmfPkg/VirtioRngDxe/Virtio= Rng.h index 998f9fae48c2..b372d84c1ebc 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; // VirtioRngInit 1 } 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 e20602ac7225..5ff54867616a 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -140,11 +140,15 @@ VirtioRngGetRNG ( UINT32 Len; UINT32 BufferSize; EFI_STATUS Status; + UINTN NumPages; + EFI_PHYSICAL_ADDRESS DeviceAddress; + VOID *Mapping; =20 if (This =3D=3D NULL || RNGValueLength =3D=3D 0 || RNGValue =3D=3D NULL)= { return EFI_INVALID_PARAMETER; } =20 + Dev =3D VIRTIO_ENTROPY_SOURCE_FROM_RNG (This); // // We only support the raw algorithm, so reject requests for anything el= se // @@ -153,12 +157,18 @@ VirtioRngGetRNG ( return EFI_UNSUPPORTED; } =20 - Buffer =3D (volatile UINT8 *)AllocatePool (RNGValueLength); - if (Buffer =3D=3D NULL) { + NumPages =3D EFI_SIZE_TO_PAGES (RNGValueLength); + Status =3D VirtioAllocateSharedPages (Dev->VirtIo, NumPages, (VOID *)&Bu= ffer); + if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } =20 - Dev =3D VIRTIO_ENTROPY_SOURCE_FROM_RNG (This); + Status =3D VirtioMapSharedBufferWrite (Dev->VirtIo, (VOID *)Buffer, + RNGValueLength, &DeviceAddress, &Mapping); + if (EFI_ERROR (Status)) { + VirtioFreeSharedPages (Dev->VirtIo, NumPages, (VOID *)Buffer); + return EFI_DEVICE_ERROR; + } =20 // // The Virtio RNG device may return less data than we asked it to, and c= an @@ -170,7 +180,7 @@ VirtioRngGetRNG ( =20 VirtioPrepare (&Dev->Ring, &Indices); VirtioAppendDesc (&Dev->Ring, - (UINTN)Buffer + Index, + (UINTN)DeviceAddress + Index, BufferSize, VRING_DESC_F_WRITE, &Indices); @@ -178,19 +188,22 @@ VirtioRngGetRNG ( if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, &Len) !=3D EFI_SUCCESS) { Status =3D EFI_DEVICE_ERROR; + VirtioUnmapSharedBuffer (Dev->VirtIo, Mapping); goto FreeBuffer; } ASSERT (Len > 0); ASSERT (Len <=3D BufferSize); } =20 + VirtioUnmapSharedBuffer (Dev->VirtIo, Mapping); + for (Index =3D 0; Index < RNGValueLength; Index++) { RNGValue[Index] =3D Buffer[Index]; } Status =3D EFI_SUCCESS; =20 FreeBuffer: - FreePool ((VOID *)Buffer); + VirtioFreeSharedPages (Dev->VirtIo, NumPages, (VOID *)Buffer); return Status; } =20 @@ -281,6 +294,11 @@ VirtioRngInit ( goto Failed; } =20 + Status =3D VirtioRingMap (Dev->VirtIo, &Dev->Ring, &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. @@ -332,6 +350,11 @@ VirtioRngInit ( return EFI_SUCCESS; =20 ReleaseQueue: + if (Dev->RingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingMap); + Dev->RingMap =3D NULL; + } + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 Failed: @@ -359,6 +382,11 @@ VirtioRngUninit ( // the old comms area. // Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + if (Dev->RingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingMap); + } + VirtioRingUninit (Dev->VirtIo, &Dev->Ring); } =20 @@ -385,6 +413,15 @@ VirtioRngExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // If Ring mapping exist then umap it so that hypervisor will not able to + // get readable data after device reset. + // + if (Dev->RingMap !=3D NULL) { + VirtioRingUnmap (Dev->VirtIo, &Dev->Ring, Dev->RingMap); + Dev->RingMap =3D NULL; + } } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel