From nobody Fri Dec 27 03:04:06 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 1503919632909744.9543392596023; Mon, 28 Aug 2017 04:27:12 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2DD222095DCA9; Mon, 28 Aug 2017 04:24:29 -0700 (PDT) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0056.outbound.protection.outlook.com [104.47.42.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7C2222095AE62 for ; Mon, 28 Aug 2017 04:24:25 -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_128_CBC_SHA256_P256) id 15.1.1362.18; Mon, 28 Aug 2017 11:27:02 +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=e181StNrAtnJ8uEX34vpYgcogHBYmMPprClTPhg2Xec=; b=3n+W/YLCAxAd6h0ccV/EcPNf0gKGSJ5Gb/LjBeUXQ3hEUJ+U5ZTqYzV39KnFlwJPLtkAJxLV/3vZ+xzvyGSCb6XZ+3le8TT0KjTkEecsaZVRcekE7u9igUyyGhgIi+l65Xr7tcpmND9kwt+yenlVIIazSCJX60fL4QoutZTMNl4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Mon, 28 Aug 2017 07:26:49 -0400 Message-Id: <1503919610-26185-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503919610-26185-1-git-send-email-brijesh.singh@amd.com> References: <1503919610-26185-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR20CA0011.namprd20.prod.outlook.com (2603:10b6:3:93::21) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07b50a1a-620b-46a6-2ac5-08d4ee07b4ad 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:PFka6mejFLoskEA3EUNFswtraumYDvKmzToa+idiQ4CoC1u+h6qJuLyMw3zWKM6ECOPTWn3djvYkszJmJxK7Uemobsxz2mt5NG4YoX6LbRwnAjTXa/1nR/PpD1FKwIz8Bn0FOiZpDs0S3gsLyOBLcDxJJUe0yt7G5OIOPRebNUaNdOERsHPXCza42fsw7WIFtjDLQxRn533I1+ZRmrcs/WajoRm4t4Dwf84H2Eu6SZeOvYQGaL2mLFqYk1eVDEhn; 25:3FTFUGzg0EpRukF40E++sx/e6g+HnohMRKwwpz6V4ZldpsQx31/HfLfqL/kO4lUn6hJo+MwfZSNw+h27EQNscVY6TGZ2swMrxktVS5+SOB1TLKZ5D1xZSPwvsXnHCLP6ws7/VhW31D9Gsj/TBbLCEx6eg6+k/s5Qw6IjTfCFWSTIOHHqjlfOG2Xdub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wRwmUR23vlOd4qc2DTqcDxLvH/BXwfTlxqNPibPzcT83ctcOP8+z/TQdWIrtZJ635FsP/qyTjaQxJWYFGfjuQ1sKNK+7C8Pw2IrTYP7wUVypCWZyCChxkbkLh8yf4YC+tgu9uVszBRheIUfYdcIXXxCqKOdtU3w2SvUXuzZEQAm0Xd9IP324oSern1WmX0aNaRpGphl70XcxJuNbOkWQnrfTDxvepU3NpWtg74+SwONXYXRNwQUG6sfIGnjxriQ== 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)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123562025)(20161123560025)(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: 0413C9F1ED X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(7350300001)(478600001)(66066001)(6666003)(110136004)(86362001)(101416001)(47776003)(189998001)(54906002)(5003940100001)(305945005)(68736007)(7736002)(3846002)(97736004)(6116002)(106356001)(48376002)(50466002)(36756003)(6486002)(2950100002)(105586002)(2906002)(4326008)(33646002)(50226002)(42186005)(2351001)(6916009)(53416004)(25786009)(76176999)(8676002)(81156014)(2361001)(50986999)(5660300001)(53936002)(81166006); 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:9BrMtSzAYbsjCnV2UVUf5eTXHljs0pKT486oppAXf?= =?us-ascii?Q?L75APoTFFaugQYk+EQdgsc5zOuh7dBZfXD/NtqegGvxrsZtd03z0RDyT3NoA?= =?us-ascii?Q?p8hidEkdfrcRMxyK54arTbCmlhyQyVK6LeEWY1+8CAupSfK4urUg/iP96DVk?= =?us-ascii?Q?QPLiL+UYkhq0f/wOs2bYDrK/uBomiC4twOF+hDyi+zwpna0Jl5dePdQwlWCy?= =?us-ascii?Q?6w3tD1lBocLRYmjxCv9sxuyPZqAmE9gaa0E8d7sSCHV/G9B5nxMVVGa22t2r?= =?us-ascii?Q?omYBgIcHqR43VfT80jgtNMs6M5Gw+5QNMT2iaehAtv7PsubcN2vZWkO91for?= =?us-ascii?Q?psScxtQMHdJbkQURm2Jz0oPUYjD9fCGU9VZ43veq2l1Qudee3dDY/8KbHMEc?= =?us-ascii?Q?RXw2q0fQpXab9Z/bq00sRQzSw4qMlQr5DtiOoohTrO41lqNKVBnCL+htE3sY?= =?us-ascii?Q?Jxi888z1aLgWd7wr9nHR1KsG9INJhpmQtzKTGeM8hjbkbJd8gylPbgUTMPd7?= =?us-ascii?Q?7t6660UPDb9OzUEM9rAcv3uZzGpa9VnCFlVyMFDR5Gn0XG/WnRi8xdEDoCgA?= =?us-ascii?Q?9m4AT5OCh8v0nehm/MA+P4axbnvEgdf0iur8GTLoCuPYvDYX3eBWhaS9DOjs?= =?us-ascii?Q?GXbwoCG4pOegYZTZIVso1By4Z8r3JC2SsYxoVkpapCTh0n+/NkNloVDdfYjK?= =?us-ascii?Q?fyKJRV2gNFycnMagi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beIr2BSNp1iPXaI6m9K1dlAfMgQKXS3oIRSf+N6T1A4V7gbbMzRC1pt3CdHHWdIBsrFvzuvTONdHoF5ZbiV0qKq1l6A4qKT3YQ9g=; 7:sMzFKhxwT5b4Y262vylTbRt1Nk7JPJ72Mvfaj2mcEONsmVrTy3BtWRjvwYQ0ufvD+DO3nkQgI3HLVF0T7ONutr4V9aCsZ6L3f+Q8S3oEbIXZv0iUxNRKC1Qr7HPeVJy2qSjceHdqocI3qVnbxQTSUzPr8X6CkR6kqAey52Fu8g/21Rp7799lGL1zbRkCddf1fQ30K8CuguS/wvgpstGukmPqoeUE5RqVvnQpzwU1WNA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:3oq1/PVFPjjcmSZwO2X8awWTOeVFoKlBMPFhuXFDBXU52XaGMPRInbOsla3eyUJ2XeFfxLe5DSTAz87XpsM+kZgyZ75Xc1UioHTFjbXf1vREQit5lke59ASP3QGtMLm0zwcM/cj8j/bvrnG8DwFCR2ft/G6o8vBJfkrnEoelhXqg5Vvokn4H7HcxIqt7aL0KYE477mhzp2h3LMUitIqz2cFswFJq9paFDt+busWMj0TCdcA152oo5dAoAX2i04sQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2017 11:27:02.7793 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH 2/3] Ovmfpkg/VirtioScsiDxe: map virtio-scsi request and response buffers 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" When device is behind the IOMMU, driver is require to pass the device address of virtio request, response and any memory referenced by those request/response to the bus master. The patch uses IOMMU-like member functions from VIRTIO_DEVICE_PROTOCOL to map request and response buffers system physical address to the device address. - If the buffer need to be accessed by both the processor and a bus master then map with BusMasterCommonBuffer. - If the buffer need to be accessed for a write operation by a bus master then map with BusMasterWrite. - If the buffer need to be accessed for a read operation by a bus master then map with BusMasterRead. 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.c | 168 ++++++++++++++++++-- 1 file changed, 152 insertions(+), 16 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index 5e72b1a24b59..a1ee810919e4 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -409,11 +409,19 @@ VirtioScsiPassThru ( UINT16 TargetValue; EFI_STATUS Status; volatile VIRTIO_SCSI_REQ Request; - volatile VIRTIO_SCSI_RESP Response; + volatile VIRTIO_SCSI_RESP *Response; + VOID *ResponseBuffer; DESC_INDICES Indices; + VOID *RequestMapping; + VOID *ResponseMapping; + VOID *InDataMapping; + VOID *OutDataMapping; + EFI_PHYSICAL_ADDRESS RequestDeviceAddress; + EFI_PHYSICAL_ADDRESS ResponseDeviceAddress; + EFI_PHYSICAL_ADDRESS InDataDeviceAddress; + EFI_PHYSICAL_ADDRESS OutDataDeviceAddress; =20 ZeroMem ((VOID*) &Request, sizeof (Request)); - ZeroMem ((VOID*) &Response, sizeof (Response)); =20 Dev =3D VIRTIO_SCSI_FROM_PASS_THRU (This); CopyMem (&TargetValue, Target, sizeof TargetValue); @@ -423,12 +431,96 @@ VirtioScsiPassThru ( return Status; } =20 - VirtioPrepare (&Dev->Ring, &Indices); + // + // Map the scsi-blk Request header buffer + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) &Request, + sizeof Request, + &RequestDeviceAddress, + &RequestMapping); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + // + // Map the input buffer + // + if (Packet->InTransferLength > 0) { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterWrite, + Packet->InDataBuffer, + Packet->InTransferLength, + &InDataDeviceAddress, + &InDataMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapRequestBuffer; + } + } + + // + // Map the output buffer + // + if (Packet->OutTransferLength > 0) { + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + Packet->OutDataBuffer, + Packet->OutTransferLength, + &OutDataDeviceAddress, + &OutDataMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapInDataBuffer; + } + } + + // + // 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. + // + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *Response), + &ResponseBuffer + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto UnmapOutDataBuffer; + } + + Response =3D ResponseBuffer; =20 // // 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; + + // + // Map the response buffer with BusMasterCommonBuffer so that response + // buffer can be accessed by both host and device. + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + ResponseBuffer, + sizeof (*Response), + &ResponseDeviceAddress, + &ResponseMapping + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + goto FreeResponseBuffer; + } + + VirtioPrepare (&Dev->Ring, &Indices); =20 // // ensured by VirtioScsiInit() -- this predicate, in combination with the @@ -439,31 +531,49 @@ VirtioScsiPassThru ( // // enqueue Request // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request, - VRING_DESC_F_NEXT, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + RequestDeviceAddress, + sizeof Request, + VRING_DESC_F_NEXT, + &Indices + ); =20 // // enqueue "dataout" if any // if (Packet->OutTransferLength > 0) { - VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->OutDataBuffer, - Packet->OutTransferLength, VRING_DESC_F_NEXT, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + OutDataDeviceAddress, + Packet->OutTransferLength, + VRING_DESC_F_NEXT, + &Indices + ); } =20 // // enqueue Response, to be written by the host // - VirtioAppendDesc (&Dev->Ring, (UINTN) &Response, sizeof Response, - VRING_DESC_F_WRITE | (Packet->InTransferLength > 0 ? - VRING_DESC_F_NEXT : 0), - &Indices); + VirtioAppendDesc ( + &Dev->Ring, + ResponseDeviceAddress, + sizeof *Response, + VRING_DESC_F_WRITE | (Packet->InTransferLength > 0 ? VRING_DESC_F_NEXT= : 0), + &Indices + ); =20 // // enqueue "datain" if any, to be written by the host // if (Packet->InTransferLength > 0) { - VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->InDataBuffer, - Packet->InTransferLength, VRING_DESC_F_WRITE, &Indices); + VirtioAppendDesc ( + &Dev->Ring, + InDataDeviceAddress, + Packet->InTransferLength, + VRING_DESC_F_WRITE, + &Indices + ); } =20 // If kicking the host fails, we must fake a host adapter error. @@ -477,10 +587,36 @@ VirtioScsiPassThru ( Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER; Packet->TargetStatus =3D EFI_EXT_SCSI_STATUS_TARGET_GOOD; Packet->SenseDataLength =3D 0; - return EFI_DEVICE_ERROR; + Status =3D EFI_DEVICE_ERROR; + goto UnmapResponseBuffer; } =20 - return ParseResponse (Packet, &Response); + Status =3D ParseResponse (Packet, Response); + +UnmapResponseBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, ResponseMapping); + +FreeResponseBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *Response), + ResponseBuffer + ); + +UnmapOutDataBuffer: + if (Packet->OutTransferLength > 0) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, OutDataMapping); + } + +UnmapInDataBuffer: + if (Packet->InTransferLength > 0) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, InDataMapping); + } + +UnmapRequestBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, RequestMapping); + + return Status; } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel