From nobody Fri Dec 27 18:56:27 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/vaazrpObe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W4SajSj7gbqpoEIbkVi5pvK1O76MeOeKw3DMMm1Af/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+n2OJRdDUa48CdBjwECf5?= =?us-ascii?Q?krbL6jHAoQqZPLttPbiK+AqTOgmql+NxURpfmjsXRuQDhpT3UIbFiqtLJ9Jr?= =?us-ascii?Q?T4t+XCwCimgEDMLP5Aj+U18cebfVLhuw6at+MvcKstfe0eKW173vvnksirsR?= =?us-ascii?Q?xzBSpDy2tu6YcjnUaKgz7LPS0BtPygwxOpE6zS41iM8nNPUbVgDk/Z+A7cA9?= =?us-ascii?Q?XpDsGT7fY7Vtui2HQo5Zyk3egm2TRCDdu0UFCux/hFuv/CKV714p27IwusO9?= =?us-ascii?Q?HiJV3CodSEsYMn+12/FDPwUGw2JlgkaiQ3WcXD9Jd1pB/Q6gX1f0RUX3bjoW?= =?us-ascii?Q?5a17lNJOg02nA8eNhswbugOPioaeRH/gA0qthmNywOiapMJUCwDrBZBVJrNO?= =?us-ascii?Q?O2Y4mgfTxL50/txIjoW2nKrTwvhIgp0V08j3EFncPyMaG58vmtutNJHf7pHT?= =?us-ascii?Q?VTu1rO96/SxN9N+mEfqrF8ZnDg90PCAN4fqinTNjzqkBX/mF2BhDekFHpxXp?= =?us-ascii?Q?K0V0RI2pH4G1EeFsCZlNy2VLY0Uo5t9ccW1nsXzK0ggZCxFG1QBPvha/6Osj?= =?us-ascii?Q?auYzpL0qH7Em6Bpfis88NxKUmER08qvDjtpBT5NSRtApJCklPRBoN3Y46IkH?= =?us-ascii?Q?c4ypgL7ygaqVhbg0MFwJ59XTd0AQU2xqX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T0m/M3zgePiM29q2+aUrIq/W5lrqcOQ==; 5:em9M4ze/j55zXPivww+yHk3DTbv0th81BTwUEHkqbdaDNa0MgC2YL1JtrzV9w98TW3Jzf4yRcukDvpRYlpJtF/vJ9JgeBLos5li0veHbC4Q9nO2zfNWQNZB6qJBiyk9m817sYkZjvQKg+ZRTggTXqg==; 24:Alrqm/ZCY6NnoBucjx37OWAAPyMqrHb3KD0k+QHUM2sRRNsxVV9oPSiWN8UlL4fEUSGnaS/Ywkgs+PwUQt4EdRhc5Zefxpz3//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