From nobody Fri Dec 27 03:04:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491016187927.9246344334318; Wed, 23 Aug 2017 05:23:36 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5E16B21E49BCC; Wed, 23 Aug 2017 05:20:34 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0052.outbound.protection.outlook.com [104.47.40.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 288F921E2DA79 for ; Wed, 23 Aug 2017 05:20:29 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:01 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lSAJzIDlPd7vYdeWubLSeHrNkbqvOpnB36BjzvfCtsk=; b=A/ed+dCQjjtMQnRaIGiTdF/PnAW0ZWT3IoSDTHR7WmL89QepQpc/heyogSiS9YjVmLCYK4jzzOoD2HfWxPclud95wES8ejF7wKdohuqF8nUV7rs1As+QGGg/B254RSSYIvFNZhvsuAG/54e9joHMw4uzDc///YbTJ/4eBnOIOwQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:33 -0400 Message-Id: <1503490967-5559-10-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc60da18-7af3-4c7b-082a-08d4ea21b2c7 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:c/Jsc9swzOhSGKTbIlbC+VQhU1nDmkzHhIDVn2ZPiEpMbnpS3QIehZCsgRbg3ctoGrZL7y3MUGcK5V4ErcH+Cy/yEe1FgkEU85YS3j0NwrIbwP8wlCXBeEZXJGBNrk7o2Bi+HGfuo7r5SSrPcryBWAPVB9sQep/VtHTt/2MrkRHRgt6JfWO34AOjXj7YKr1TJKGFLthZot+KLDGf65mpIbo+lu/C95Qer/YObtqH2qR66tAjh8L3+GB5okUs8nLK; 25:Q4st03uPS8DHaJVkGrMiIKDpggOgqv9d0nb2Hn6goCX/b0e6lvvI2j7c5K7Ba2Zh/WY0zY6KnL3Xt/ytobLW2JFC9Ruw1zVHBTDMQLdYG6s7t3hTMYbA5gyJnld3P52/5LR8X6zE1L5OHJmDyhOf8BW9K4rwZoDzJT6Lr6WIAHyhW5YcLyl6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9Gcppkiox1Km4K3momotLQggNshvWLKy2SwgmdNEuOTk1IhkfpI8qZSknL1X9KQqSMuq9PFsyQv7UjyFOXHsf2OkVOGNb98DbOSbq3EUoV/3rxcFOJBd5MRUNfGROr2MraIfNMB59VlAvAyad7dRobclpQBZrwvMYamcoqpuYuBDe+WmBGXmzf0MkuSCEhys6PuUVQUK0x1DvP+m+ZsDCHIesqTV2eU71ajchOddw+hC0eSExwrEL0oj377nB7WOKzUFNyQ== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:enune6F294V3VgY+LE4dcdWBgGWkPmhZ1UUbPHbqS?= =?us-ascii?Q?RckbH8xt4F3b6G0Rys5n5qIh7ojrlLXPNQUfb92pBprb9k9+tp5Y4TdKPndT?= =?us-ascii?Q?cGCa0mDMjZ96Im6u8FwCe0amZYLF71O86vQOnKri0BVbsPzMUxN2LwqQ0Au7?= =?us-ascii?Q?Sc0n0Ml1+imRoYn9bb+31kxFXwhP/va5FBmiitlgUhZ5wNiQpeZtLaU96fWS?= =?us-ascii?Q?rgx0xRVLW3iJc5Up3Z4ZkNrU34F4Ms9DVcozdC3EUzPhmk8aJnE0Wh67ntuT?= =?us-ascii?Q?4dbjNwWP0R0sIxmbXpMN6fD69ozOTLoPhxMXEun6CKFxpeEifUlzTpnnrye4?= =?us-ascii?Q?zOIRIRUjbH1YUmBaFuFlr3xxQuWeHN0NrGJbDoCKcfKmOffSq6JulHVq17LW?= =?us-ascii?Q?nxhR64T60TxAztXs7VPExXkQcDl5tYw8wd7DD1Gn39TPMa+K4IZ2L60aIQec?= =?us-ascii?Q?qXx4yu7FK65eoiVeOC+GGslQM/0ePyjn3e2D3H9JpG3DCnYIdEjxgNq/O9dc?= =?us-ascii?Q?Xe/Wnlo3nkYYI81RDgPBwHt/k/jB5yqSg7tiuoXe1R1FFr7InKJ87n8sWGqd?= =?us-ascii?Q?kB8pNUIduXQbPLqH3OsEcRQYIghnwQkecGcEpwjc84UKHBeUn2GxcxPw7amO?= =?us-ascii?Q?zuVfwnXZfTa/tn+WpjUQswD0QKkeMQ29GItrRLPQPQb/JE15Er/qZr7HT90U?= =?us-ascii?Q?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eQWbWB5Ws/cMg0mJnzqcz/Ofwh3XYrVoK4wwwgD4piXG2wUX23qe9wOkozdY8wLIw==; 24:i7/nKIzNQ5OsFjVlUwFKmBFViqNHy4pC7CFSVv6kwJeguK5RkoVKK/ZCcKKWeAT24ie4VhrWEHzoNpQfRUq2bH/XhXl0dtOLQQ9Mx7cfRF8=; 7:HkbqShYetftkln1EZjGu/eBhq58zRTOyyz9cmMMOFpPm2QrRVjYUm9Ad2BK24MKONfiFKLIYcTOQl77sNzzkpq+wctQEvJTfflqXjCJLtSqSVVng8q3QufXOzj7R6cHnoLv8hDEjSPcB41VHRqaTab8DYJqFBMAgtSikeW9+RkYmdjOI8NGK6E3Wsr6OYFT7WSvQ65Kuye6ZaJEwveMLa/k35An3r1O7/ideYDDpkmQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:fTGCvX4KZ57A0ejBDI5isfJTG8WWtWV/Tm5lxVXsve37EP+guf+xdhCORCP+6puIyz9BuX6mYeQKOLPqMqqCl6x4RCleoplaCPIjyVI+BjcVabtOdVUUpJsteV41Qy9eLFazYpPXw+6zFgTfYnW16KX0fBsvJzXExnyhmrVzp04zipow0XRD3IoMyCmmXFkUy+WzYGr5wnv16q9AUmO09PNjFMSYNiUdbPNOu0KkSdbYX827n5vExx3IB+luHgvs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:01.8416 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 09/23] OvmfPkg/VirtioLib: add function to map VRING X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add functions to map the ring buffer with BusMasterCommonBuffer so that ring can be accessed by both guest and hypervisor. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Library/VirtioLib.h | 26 +++++++++++ OvmfPkg/Library/VirtioLib/VirtioLib.c | 45 ++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 40c51a2b3305..3d9314b3acaf 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -62,6 +62,32 @@ VirtioRingInit ( =20 /** =20 + Map the ring buffer so that it can be accessed equally by both guest + and hypervisor. + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to map. + + @param[out] RingBaseShift A resulting translation offset, to be + passed to VirtIo->SetQueueAddress(). + + @param[out] Mapping A resulting token to pass to + VirtIo->UnmapSharedBuffer(). + + @return Status code from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT UINT64 *RingBaseShift, + OUT VOID **Mapping + ); + +/** + Tear down the internal resources of a configured virtio ring. =20 The caller is responsible to stop the host from using this ring before diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 8bc5b9aea4fc..535635ac0ba8 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -505,3 +505,48 @@ Failed: VirtIo->UnmapSharedBuffer (VirtIo, MapInfo); return EFI_OUT_OF_RESOURCES; } + +/** + + Map the ring buffer so that it can be accessed equally by both guest + and hypervisor. + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to map. + + @param[out] RingBaseShift A resulting translation offset, to be + passed to VirtIo->SetQueueAddress(). + + @param[out] Mapping A resulting token to pass to + VirtIo->UnmapSharedBuffer(). + + @return Status code from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT UINT64 *RingBaseShift, + OUT VOID **Mapping + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS DeviceAddress; + + Status =3D VirtioMapAllBytesInSharedBuffer ( + VirtIo, + VirtioOperationBusMasterCommonBuffer, + Ring->Base, + EFI_PAGES_TO_SIZE (Ring->NumPages), + &DeviceAddress, + Mapping + ); + if (EFI_ERROR (Status)) { + return Status; + } + + *RingBaseShift =3D DeviceAddress - (UINT64)(UINTN)Ring->Base; + return EFI_SUCCESS; +} --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel