From nobody Fri Dec 27 18:43:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150271067577244.351599789325746; Mon, 14 Aug 2017 04:37:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 84BD821D0A265; Mon, 14 Aug 2017 04:34:58 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0066.outbound.protection.outlook.com [104.47.40.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DF46321D1825A for ; Mon, 14 Aug 2017 04:34:55 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1341.21; Mon, 14 Aug 2017 11:37:17 +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=s0+FDnWlwvBJm8s6W2LCBAzPSmGw+q868/dOXAVRR6w=; b=Ljc6yOUFxdIfUCoILq/JeOXliskO1B3YOIDBo+3HsuR8YUQEBptCTBY5e/YhpyQ7OyNEgcOO0DIuUqlMLjcGXpb6LIl753OGfHSCBTxDrITkRy3DpPitQFSd1wfRSi7sM1bfTgma2or/AbL7p3j8n/zyL8w20brw7pawLAtrxD8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 14 Aug 2017 07:36:34 -0400 Message-Id: <1502710605-8058-13-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502710605-8058-1-git-send-email-brijesh.singh@amd.com> References: <1502710605-8058-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR15CA0043.namprd15.prod.outlook.com (10.173.226.157) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18232cdc-117b-42cf-58b8-08d4e308d16d 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:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 3:rRJ4/jnNq8i1Wjuy+g05CEXmjhCysbNqp8gYJC8abwaizBUZC9padUhMLrdAg9w/9Vbh9i93fCx9nk0381RPzMZVa12u3Z95+h+LFk/yXzoJQUCdX1VMF/RZgTXnJUQNqvUKkKbn+AwzrPGXduc2IGrK+EXKBou3VBG8UFFb+ZCMB4Nkq8YS7ngw2E7WSvGsUPZeSnYWgbalkZIQQPMD72fTs/VpOKC3aMO7gwtAqCZPdt4piNGRnHAdhGAFKSMm; 25:0TdJ9pAGkzu0ODhYeuMB/qYIYW2YYRZYM1OM2PO6TZ+ul2T2d2v9rBT3036D8nhiVbneJadKA+22uLgEEEG+iE3Ds/DSoiMFvZXKcmesXyYS0Ul12iJ3Li+Cj0CYrWzRRrDtEpCZeee7s0tKrLCfpHc2IweGn0jRirk7ZuT3A21WfUex0iS5gyAhyU7rrPs59GgaTRGkPzguYVvSJfuTL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OPmhqIniu+BNLofHHm5HSgMKdgqDIclIibDP5vUbt4XLibekS2acgt2DcZoZxJp+/a/iawbY7E2pOPWsFHlVKdf9pd5kN0va7bzp5+3rsjxNqKtAiQYvD3Rvg5fCJKEJ1Ck4hZhFyayHmUTc8gjz5jSnWqow2BHHGzU9F2LTrvfckl9mPJDVnBR4YmIjLJkYl407Bv1EUckAg3LxFpxK7uF9e70w== 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)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR12MB0145; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR12MB0145; X-Forefront-PRVS: 039975700A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(199003)(189002)(54906002)(5003940100001)(6116002)(3846002)(53936002)(97736004)(575784001)(86362001)(36756003)(81156014)(81166006)(110136004)(8676002)(189998001)(50986999)(76176999)(5660300001)(2361001)(25786009)(2351001)(50226002)(4326008)(7350300001)(33646002)(478600001)(53416004)(42186005)(2906002)(105586002)(7736002)(305945005)(106356001)(48376002)(50466002)(47776003)(66066001)(6486002)(6916009)(2950100002)(6666003)(68736007)(101416001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0145; 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; BY2PR12MB0145; 23:NVyz2GIIsfqu+O2xoldsHADV9Krofx6XlrLBzrc9T?= =?us-ascii?Q?FQQyATQdGYnw9yIUgnt8xwimozjeRMFJFoICj5iIq1QNu+BGkX7ZEzlDUrrp?= =?us-ascii?Q?Ri+G0m/FafMBZz+i2ucexaH0+BLzOAH9dcsiOmKwr9gODcjFAi2wujsRfZiS?= =?us-ascii?Q?gbfcwZXxbLxyrkYiTVoJGYWIa5NwuvbDy2/OcK+SD3vTDc+UnTgYh5cY6eyQ?= =?us-ascii?Q?QemAFofygYMarHUTPR6x6c5LccN/5C5QhSokbJihTcsWi0aPPoryrCYT2tj7?= =?us-ascii?Q?+OFF5jXcT4JX3wPfsvgyX3c/QNg8e6ZOwhwp+bf7Po5fo7CpKBnqXnCzwRKZ?= =?us-ascii?Q?GVlMN702L657sqmy5rX3ZeOEjl821CdKSoufSW70621GN477WFev5uVM9FcC?= =?us-ascii?Q?pMPJDriQAWCeIzqPqaF5N7NVM/cjUIbvA/RmRZ8eusYRsuCrXPWdTkvddrbM?= =?us-ascii?Q?3/P7NHC2z3zRpLV8/xuOXKE+eqPLttzi9huJ/h35EvYK7hp49PbW5q7ca7ss?= =?us-ascii?Q?tKOx81bpubYnYhkX6r9BAssKl9V0pyi5h/WpQCQEuiQKMhD27CtujhsPp8/L?= =?us-ascii?Q?bOn94+uZPr+wXduGwUIkRiVgbgcYd2GEACVrelWfTnRuxveXfU5cwd0tFOcn?= =?us-ascii?Q?ovJ5v2Gtw1EYDXdUT/VAOWxhQppCg7/rJtLed5F9xtpOZfQoLAbAX/C0HGY+?= =?us-ascii?Q?/0dSa+XbL78AxZ/I3hjzQqMaoCeuOLmcOaj87vUekN+v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epym+ixmO87c+iTi8hosltt/F9sLagnqw==; 24:OSuil2VKH2akkjC+PszSnrDRx5g/4WyOpvZfCkL1eEhbfXiwxSoDuxT2RLYKsa6FxB7QFG5m8F6mbNE2973E8Wi7mkR9c8cYgWqUVT9dJN4=; 7:mOig33IX3PgwWfM35qN+YvW4kOtlnthFSuXOUMK+6FuDLIiwIUqa+UdpAoh5Gd3mzD6OBKIhp7ZVN3OPdLR6fUYhjgA0l83QvWDR60QQToIZdISQxPuoI4kTNHWEwpaGYPEbZtvIGBP4dIxmZRs56kFnSyXG/fEOI1d0AjHJN1CVoa9t4FqwbO/nrQOrAXDFgdasRlCO01z7NWi9Qqmx8jqlzAQQDgXIGiY0FrWAXkg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 20:YvoqiMpvQdDhDD97hOO5U2thhvuthmVk1IAeSGdSEyoa689HbGpa0TQxyH9uhvSk74noHxDlnjMKOL+vMprBpYQzi+rvEm/GjYL6dTzluP0QCzCPXgda/mj+QyjaTX+34h3YQikMAmSeIaCypnFoq8SPclQDJRpPrFyXvupk+ZRcgyIlqDpyHvD74vuEXXj/iwN50vyc8FXfE28H5falK1EqnXKC1909hOcNo2pFJo4wVtkRG1NulMx3Q/LphZkd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2017 11:37:17.2992 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Subject: [edk2] [PATCH v2 12/23] 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 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 --- OvmfPkg/Include/Library/VirtioLib.h | 25 +++++++++++ OvmfPkg/Library/VirtioLib/VirtioLib.c | 44 ++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index ca0b217a04eb..1efb02a68cf1 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -62,6 +62,31 @@ 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 =20 + + @param[out] Mapping A resulting token to pass to + VirtIo->UnmapSharedBuffer(). + + @return Status 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 5b64d18a8d6f..7d07dcc09d3d 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -498,3 +498,47 @@ Failed: *Mapping =3D NULL; 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 RingBaseShift + + @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; + 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