From nobody Thu Dec 26 13:43:34 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 1503919630056399.32218347739604; Mon, 28 Aug 2017 04:27:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E71932095DCA4; Mon, 28 Aug 2017 04:24:25 -0700 (PDT) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0075.outbound.protection.outlook.com [104.47.42.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 93E1021DF808E for ; Mon, 28 Aug 2017 04:24:24 -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=4nf9EgSTNhWD2VBcEq0T39BlloRrbo+i/6CpjjDSm+s=; b=dbnTh1/bmfPlB01ngvXFuplj62OJdmE/llM1dlSBKZqlanagSMUUiSJitv2/bRKCSvR/m1CDLpE+xN2m3GxtKROgP5sOcywPxSuK9P92G2r4gaOwp1TuZRPkAIouW6WZcpQKj1s7NVd5da+/jFuRUcNwJ8dbT9a9BCPu2VPHs7U= 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:48 -0400 Message-Id: <1503919610-26185-2-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: 39de1b10-23bb-4350-7d43-08d4ee07b45e 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:LeE7kxcdPv/qCDUNbx9esfMh5R39T2QvFADEeSWFMsaF1uMrNsXJcM7UYX/NVf0lFNqc8V2nimCAATawW5VBbg+gl1KBooWIBQitlD2nXPL4Cp9mJXk7xjt0xDVNFH1GsuBTP1FbR9rIOsgvBE/J2Hc6L+SveQ0TaWz/a/UrfSLpFQTDeglMQIbms+hnDN6JVHlgSFU54kzJaCS+gxSjaannb+9gYIN6coTvWGCeeMYAAS7VH6lf7iMPnDhEXo1t; 25:v4xHBjogND38aMRlhMI+ZGzVdv01prAomEC0UtA9vCcmCJTl6JQYQHQV9S5PO/PDenNWvH9MC/xSJyN8Jj1YLBp65Uaq83w8zCIvTkcnIb472Da9G9XX/tCxs+SNr6qb3wYyKFST0uSB+IRyFv8TCUC7BBUuzE3QQPD5I2zi2gGuA2FyCCj5142ZyjqyouxA82hXb8U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uLBs8y32ZmiC2SL7XrPXTLoP9qqPe0T/8VouvmUPy5Hmcq/J1qc8ZkezqfDsVapCGfvRkE/kYfwLneiofvhbrS78YD9rgHjYITNlRmOLsrPjShcKlC4Mgjp6l8cKlw1dxiKK/mHJbVPpxM5SKUNaRPnEAO6rT5tn/cDaocrO4gON/vFL51C8iwn1BUwTFGTzLaocFY2eN5ZYpzMi5G96WiJNb5YvP67++AxFw== 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)(51234002)(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:Ha5kZzno/RULlJ3tgKEFdjrVv15t5vC/PRIYRcrj1?= =?us-ascii?Q?WXfx/ZQlYT9SDjZCGT2YjJIR9PTEdfX45rQsNFjkV60ydL4R0qegLNNk5Jkd?= =?us-ascii?Q?+l4jLQzfbtEBSoeFhp/Je4avLWV7gu6OvFPGqDwY0PhEt5wMDzZKwlyUT6xJ?= =?us-ascii?Q?lbfCVxOGkVP8qd/cNpeyyeMvvQDyNZgDxg5DI7wYwX3jPDHdulNHXBl5DCK2?= =?us-ascii?Q?mbni1mA6A6hFVsNY8RZcLb0S+nFI52AZkJtPjvvYcCE6Obv7lwuEDbMouYBr?= =?us-ascii?Q?8AXYk6iY1oTT77ZBDAQY818VJGc1daEvsBQPklQluRReATnYpcwogljlsVgr?= =?us-ascii?Q?qvf8AxMkGcnb52JYlPEDEEsviAOJDoykLbCOxQvlZMwjpNt7pYWvAOMeXeTE?= =?us-ascii?Q?E4kYB9TPB/qaauKrtbhoAJhH1TOj23euS+p5+VQ3GIHRJOdF301MI4M5cBcF?= =?us-ascii?Q?zpSWKLN/gLZzMEXeoSw8z3dEn5xJKyP/dUqlmvTJznr3HB3kGaAiqLoqnVR0?= =?us-ascii?Q?xo1CSoFDuZihmJ2YyhhV2wOtvTZgBAGlZt491qeSeVvMBSvM4kpJ+NidWUqS?= =?us-ascii?Q?RJ92If1qX0yKpaLKlHjf1fOfYWXEVRqQbMx4yQgl9Ic17XT57O82RMDmjplY?= =?us-ascii?Q?CbjwSEvM014mhayPOahzPfZdwjjA6NV7rprhYsan9uLh65cNiW7+HESP+RS7?= =?us-ascii?Q?aoabP7E5HA0Q8UBbk+EsvcSL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Je4O6HbhSrf2B0NSa+dt/SPGcrGK17R0zuQhpvvKUZ3e78cvQA==; 24:J9usNBlsgyv/rJHBAYYVCbFBp2FDIe/q+ul7zilzvT3XWkPAMKhr9CFlaIqiBeOA+CKhY18tPN4YIdoTU4c6cN/330puzITg+erG51jxUWo=; 7:vFFZzUVqA0AVpdfwAHuQADe+b0BauQLsH/Tsd9UuWdMM5NG9wvZdgcz8M85r+KH/lJl1gfX/00TwjO4etKg4nHbEZueKOEvQTuGXKaxGD9lES7+mv4QMmzsvbQUIxTg3NGi3LgNf5cHK7KmAtnMx39tvvwNw2bWULtaSeZP42jclpLRARudOFmhSJXS22Be2TuNrsptjTlXw+nN+c2Jm5Usg0ovSe5tvwVveWnAoX6E= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:iS9Zh4ZAhTBNIjzbRYfqpq2IHraawhETfXFxVHSVSuJ+KVcfGqVZq+zXB8guaScDE71c8Rz69ZfiyEQFAonJwcwjgav80wBvTWzYhsc0lwwJ4De6xyrv/yun05CMCgzT8iiP/LtOyroFGnEL/9o+oR/AMztBJbAyLR+rc1nBLEQZ66VA3jp3bH5HDbY/YgqOuOwJyDvERDP7Ad8TpfgzPwp1J+kEWvJIY7Ib9jJE6NRFdiT9uA6VWQzwa8Nl+Cts X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2017 11:27:02.2636 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH 1/3] OvmfPkg/VirtioScsiDxe: map VRING using VirtioRingMap() 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 then driver need to pass the device address when programing the bus master. The patch uses VirtioRingMap() to map the VRING system physical address to device address. 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/VirtioScsiDxe/VirtioScsi.h | 1 + OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 47 +++++++++++++++----- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.h index 6d00567e8cb8..05a6bf567263 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.h @@ -60,6 +60,7 @@ typedef struct { VRING Ring; // VirtioRingInit 2 EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1 EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1 + VOID *RingMap; // VirtioRingMap 2 } VSCSI_DEV; =20 #define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \ diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index a983b3df7b9c..5e72b1a24b59 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -707,7 +707,7 @@ VirtioScsiInit ( { UINT8 NextDevStat; EFI_STATUS Status; - + UINT64 RingBaseShift; UINT64 Features; UINT16 MaxChannel; // for validation only UINT32 NumQueues; // for validation only @@ -839,25 +839,42 @@ VirtioScsiInit ( } =20 // + // If anything fails from here on, we must release the ring resources + // + Status =3D VirtioRingMap ( + Dev->VirtIo, + &Dev->Ring, + &RingBaseShift, + &Dev->RingMap + ); + if (EFI_ERROR (Status)) { + goto ReleaseQueue; + } + + // // 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. + // size. If anything fails from here on, we must unmap the ring resource= s. // Status =3D Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 Status =3D Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // // step 4c -- Report GPFN (guest-physical frame number) of queue. // - Status =3D Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0); + Status =3D Dev->VirtIo->SetQueueAddress ( + Dev->VirtIo, + &Dev->Ring, + RingBaseShift + ); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -867,7 +884,7 @@ VirtioScsiInit ( Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } } =20 @@ -877,11 +894,11 @@ VirtioScsiInit ( // Status =3D VIRTIO_CFG_WRITE (Dev, CdbSize, VIRTIO_SCSI_CDB_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } Status =3D VIRTIO_CFG_WRITE (Dev, SenseSize, VIRTIO_SCSI_SENSE_SIZE); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -890,7 +907,7 @@ VirtioScsiInit ( NextDevStat |=3D VSTAT_DRIVER_OK; Status =3D Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); if (EFI_ERROR (Status)) { - goto ReleaseQueue; + goto UnmapQueue; } =20 // @@ -926,6 +943,9 @@ VirtioScsiInit ( =20 return EFI_SUCCESS; =20 +UnmapQueue: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); + ReleaseQueue: VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 @@ -965,6 +985,7 @@ VirtioScsiUninit ( Dev->MaxLun =3D 0; Dev->MaxSectors =3D 0; =20 + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); VirtioRingUninit (Dev->VirtIo, &Dev->Ring); =20 SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00); @@ -995,6 +1016,12 @@ VirtioScsiExitBoot ( // Dev =3D Context; Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); + + // + // Unmap the ring buffer so that hypervisor will not be able to get + // readable data after device reset. + // + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap); } =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu Dec 26 13:43:34 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/s5Qw6IjTfCFWSTIOHHqjlfOG2XdubqNhyzHtgBvHqfGGEvKH0sgqYhWyY8IAryKD7MKePRf6q2ndkAzBl5hfCcXG5qvsmqJHsKfa5dzrG3Xgl4uu21tRtJJ7n+Jl6v4fGrUgPHe5x9ShoXsw/3kzXr1irBtcBv8wGp9cToGr2+wZqS7QlskC8Dclw==; 31:I5Sf5AGPlUjAUszBE6Vr+NbGRDB6BMMZPjTjgo7BffBcODYg0MQcL/V8cU+M7d2H/sAUFjXvM4nY5DOBSGJBRWBinpBL63mTzi7tP0f+lBbmQK3m+kuaA6yz02WBF68FF4HLQM4cBeIiUSwFVU+47M2QanD1kCuDtOhPq9Zh4zrgT67pgIZDFDqNQM9vm5iW0jTHVlqm4NITv4+AkwZ5gIbO96lV2Lt7VnVhyrXu/pk= X-MS-TrafficTypeDiagnostic: DM2PR12MB0155: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:Hjox1RKzczYFeM/ZeaRMnyr1PpvXI4jbUvv8CmNDp6Mzbt0e7G6XbHg7z7hADxULtKDjRyutNSH/4M6JsbhCrz2zi4ryuY5rS3ySOsjo4lOGdx0C0EDMWXrLzlehMNj8Y6XKSOlpJdkaActteo7Xux9JroeiyRur2vPkdluiaeI+h+ZnMJbDaSeJmP4uPx7A+NCQelEyaGGT+6chNJNL+DAlypKaQwzoPmG3P0KFcsw5g3vINmTsAYuocKIXBPVNJMLcNLbxtPGarCkI0++s+Js/dL8mh7ivo84g/YbJdE842US8kEiJWcGFka1OaUfyDm2CjStvxs1PyCxXwEzlcM1KHagAx+YJCZ47UHe31IuyQxrobbiqfHAwEXXidsbhUwetaFwfsPTdUyl44Opo8U9nLzTLmeN5412GcOnn/5UARg3SZL8pQpWa3ipcbqfaBGZ8vdQ5ewCobAnIO5F43lA+ey0DqHzOUqF3twziLX1jw+feQAXdjXc5W5Ngz9DF; 4:y6hfc2EC+l+l/PbrmGkzfPSrYo7w/NVv4A6eG/8gsaCmeZgNHsVjgVMAgfmJof7PTzTxp5MXZd0s7BLKZDdugEDwRwmUR23vlOd4qc2DTqcDxLvH/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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aGMPRInbOsla3eyUJ2XeFfxLe5DSTAz87XpsM+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 From nobody Thu Dec 26 13:43:34 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 1503919636212938.127992257531; Mon, 28 Aug 2017 04:27:16 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6BD722095DCAD; 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 B04152095DC9F 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:03 +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=mEXMqia8FLsEHiIgf30Sd0IDA/yKDbu8p0M/mkBzpsw=; b=zuT75ffQwj2dN6Gq24g7A+UlD0lYn+nvVKmD+ZOSgmHt6oZUw161UyoZsatjdF9U5X7IacZswhWsLCoh4rmEeaJDPY75KAdt7xdvd7BgRiroJcw5reyQ+gy+bAo/2FLUuInG2lrssL1y6C2m7LXWpvCuiCqKTO7U4i0bLGG70+I= 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:50 -0400 Message-Id: <1503919610-26185-4-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: e063a149-85b3-4c54-75e6-08d4ee07b4f9 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:n7crOJV3L5/ReUEELFyjvrZ7jDzUqja01PrJ0tpRvB+su5nfQaH4Qnxy4OEuVmtGtXu1IzbrZ72DQsIWAO1XG9QD+K7yD9rt46dAcEHEA7DaTdYPBZUhSeIbp3WrsQmSEs3B/+iyUkLkDdEL6t8tJ7MHQIhszdc2UG4qdZzuBG5crxXkw/rnglWKooXUvhRDaa9NwzzZsjwO1N25QJkDS2XmJrmR+gev+AEPGWpY2NbyZTX7l0vx6dbIZmbzWiUm; 25:ITlWQHfmabFOrr9wbd7CMjAkUyMo+tW1BwJDdl44iOHbjbFhAGwwt0q7qwsYS2+B4n3Tx1pgx9dBgyJSCJhPMXFZk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bZbVDbFz; 4:st2up/yjLXJ8yevrHhSzx1moN4PmGxDLiwAMwtok2OMa30CI3jjb2UBlOKXgL7b4vj2fSPdrHASDFWrGW52tHVDPglMxFNSj2KmCXxkh2YcxdbiWEW1Fh53UitDUOj3XtAmOzyKcQfEtG7i6uD6CLWyimCq+aPpBcHUhjJWg59XM9y/PHqqdF7Fp1hJ9Z3ZCR1Cw0JYnY/Z2Ggne6WOREEmw/u1CdvVExxrbgkWr2t3PfV6kJFbMwrXPhOUs7YU8CdTa6vMzs6F0FIdZWbVgqRFRDaOZibhB6txSYDdx1ADugJxZv5h595QB83q/3ZMPl0Tjrd/+u9rfQkv5o3jA8Q== 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)(344415003); 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:FJAiPfigiUDLUiVXIPuuaH59nDbVsnU80aWzu9NVh?= =?us-ascii?Q?46BU8Zeo6ATmu0DcRmh267eZdF1ZThr0rcqKdSWnjfkaTkIeUwWIH1qJqSx2?= =?us-ascii?Q?mg4TDbZdii9Y0LkbI4I/u3dzs1CgXfGvXoLOveB4Mef0HPIOl9hSvhImRtUb?= =?us-ascii?Q?DlfPHsNgKxAXCEIZKc5PuBhi1hYyXzcFRQkrETDegs1Dm5KmAKgYZVM6URfO?= =?us-ascii?Q?1U/7um99i1V3WUYR2EShth12ndbfwUzgnOiU6xr0ihX+10GbXvrKX71ZRs70?= =?us-ascii?Q?dY4m+pPshut8xS8/iKZJleoDPXfUVOQIIpt03Dtpz+CqsaDDJPdzf+4swsDJ?= =?us-ascii?Q?mHNc50LvNgZLps5PHkd83fbJf1Ig44MIy1JUa7EZy+35+ug3V9P02lPute+v?= =?us-ascii?Q?ccTaOmhzBWFa0a5uKWGI3gvq0a0nc4pZsdq0qGGtlmQJkCW/f6ZRwgnITZsb?= =?us-ascii?Q?KB1sz5Efz0e/U67i2nGF0rkA22tT0NhgvcpH0YUbzCzzMzvMk8xELUTdOOex?= =?us-ascii?Q?5T/+w/BqCLKmie/hdiFa+/i6f315ZbT9+lZgwhXNnPTQKxujQTyRmgZbVzTn?= =?us-ascii?Q?kBn6U5STNBcFC8q5dFXJkG84Yh62+EV7FSa46AaO33OR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TS6WSlL07G6GX5g==; 5:Af8ZcZNxw0tnrfbVTwOyF6gHqCTZT1l56SgXGVv2qIWSYpaJh78cwX4wkbgKqUvt4wV8OxePicwSnFCuJ/cMzUNbr3jmZRmrjr6qZ/iK9kXCFv5hj5f5pHnrJA8OJCfSpNV6JaEldSOT06CwYDWcaA==; 24:1iqgj/yJ1WMzk/X3Lc7Tc8FnD8ULerFfE4AZJ98GGZTEm+u6UPIxIfIZIJPVQjv1H7lT21Sq6CS/XGubfB602CY5+1Wn7Zzu1whaTSQjwMw=; 7:NS5EHEPiV6juobpTWkq7GIvIGAZhE6QmQBH/BskELyQhlIGm7w8bKdCcq3OFSNxhOzFBe9mCXYz+1NwLACJl0B2ScWaRgBQS44qyFvnw1zMFw2lbyLgDgwU+zt3IodogrbQVtIuJSQ3/3/7JxqDN/3tDt/xmMj9KZGrNrL9aXraR0l8iHv2mwh9L6AecPA0Qq2VYyR+WRFEGUr3nPYIZnuYU6wselkTZYlGCkcyQ7j0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:QJxbnpZLX54KlmZtCJAgn4YxbM+kaPGwbqc2pPMkRP/tEkutCwwn1HMgzHvbR/EQldQttKMc26TidQaWXzsDae4i7Vud+J55b2UXYujHtlCNj5HBBGPahk5YP0HlBRi5FqvQ5IHliIyMbsgtLVAdu/H1rNxKceO/kKFLAQTH8TkARQCIlJSTZRNvmh82aBDzEOMf+JpRdTzWQHwcIvfj617mxY0NhkX/5/T2oiv6iIWUT1tlbc81aRHUP+Doj9gK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2017 11:27:03.2793 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH 3/3] OvmfPkg/VirtioScsiDxe: negotiate VIRTIO_F_IOMMU_PLATFORM 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" VirtioScsiDxe driver has been updated to use IOMMU-like member functions from VIRTIO_DEVICE_PROTOCOL to translate the system physical address to device address. We do not need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present hence treat it in parallel with VIRTIO_F_VERSION_1. 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/VirtioScsiDxe/VirtioScsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index a1ee810919e4..7028d04f5165 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -937,7 +937,8 @@ VirtioScsiInit ( goto Failed; } =20 - Features &=3D VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1; + Features &=3D VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1 | + VIRTIO_F_IOMMU_PLATFORM; =20 // // In virtio-1.0, feature negotiation is expected to complete before que= ue @@ -1017,7 +1018,7 @@ VirtioScsiInit ( // step 5 -- Report understood features and guest-tuneables. // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &=3D ~(UINT64)VIRTIO_F_VERSION_1; + Features &=3D ~(UINT64)(VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM); Status =3D Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto UnmapQueue; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel