From nobody Fri Dec 27 18:49:22 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/K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EPurV3pp54GL0rqYUJa8m/IqZAVAJ/z1kC8HNI/tRrrHG0WTz6NAzb9pvqW4WSZ1g5SjtLKFH03NsrxUnGxXYX1FYJ1S9qXlD3+4AGPi/84yXgDJMSLaqT5kV35XK5BJs9GWNWSwboViPFhRPxl0RilrFvUVsPgtzzaM1DbcCS7CZQSqYccJV731lMMAptX/CSAU/QdmDR//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-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0159; 23:yUm9EzZhG2wi0trkw0ZeHu18SNQwGum5+7lKKFqUg?= =?us-ascii?Q?n/HBmT34F4B54PRXI0q8h1E+a1PGbEg19XHwQVWxb3kCeTfH1WLdBuaMAd9/?= =?us-ascii?Q?OL9SVid6BtTIGtJYAgqxk5eeX96efVlExRQ0N2XBAYJMivcNUb/Wm1YXo7zt?= =?us-ascii?Q?Rtk3DsE8Tefw9rXCXoxMn4mWFLNFSQEfY/S8FxYqnrJ8wwdTpc9FcYCnXAlK?= =?us-ascii?Q?AE+4Lau+h5S8ZQ0FX7gCCkHH6H0FQ8aPkuTvNdH6Pzohc0fbR50o35cFOumi?= =?us-ascii?Q?cSejYEgtqI5fGkXboD6kwxP/qSye9TqittSwMEebg2ZM4pTeALE51M+CpMXY?= =?us-ascii?Q?GI9W8Nsfc8JZLiKMV/5BR8gEsP6wbfgg8/hRJwgwmB+yOY2yxjwVX5VubBar?= =?us-ascii?Q?TO9PI9j1RVCL4GZsABnSrDTG02Pd4MALpdv5m1Xhd+1klWSQrLNiC5e+uGg2?= =?us-ascii?Q?OIfk7ig5t60IKDIpQ+1R4AJ/5KhlSYAz6qBqSt7y6LdH4DGod2eJPpa6oLEC?= =?us-ascii?Q?VmuG7Xx+ln3uu3K+OG4J0MSp4Ti+i8Wrj8pQJ/K4xDd6BFWjk9m3JO3bv4HJ?= =?us-ascii?Q?tYP+qPhFP2xZnRcsiWgcFKhQ2Q+AvyAcrLyAKj9cs5NnW8VdUEXf+4I1Sej0?= =?us-ascii?Q?VA6K3/ReUGO1RJsdQlJLbxR22n7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dozLIkwU3DAn6ifVJqHBO3ZETu8XdjXh9ucTyMwdJm+nqvMUDfEI4h1K7/1dUsG0oJhNmUjLfyWFNsrbDPMqS86uF1ZUmvmy6qlAOkbg2UFae2KO7EQaFnoQelnj615+PEx5gTbsRA==; 5:UgiW2UJAtjQAurwsNfq7IK+llR5HSuuhsKjon0wOq6b/INE2KZ5Gst/FakKSxCJf6HJ/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