From nobody Thu Dec 26 12:13:26 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 1504191695165986.6717731880572; Thu, 31 Aug 2017 08:01:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 729662095BB8C; Thu, 31 Aug 2017 07:58:49 -0700 (PDT) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0072.outbound.protection.outlook.com [104.47.37.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C0FB521EB529A for ; Thu, 31 Aug 2017 07:58:46 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Thu, 31 Aug 2017 15:01:27 +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=8TPLJy9hunbfVjG8Dln5pVSIVO4TxqJb1NwqWSMnVYM=; b=vKRWaPCPqqItzdZFwUYWiXEGPzdilWAcMd42EPekSMkia7p9EgGGV5cE5UWEI2UKT5wJEyg0HB0vNVPrl6qTvt3LWSz0WYUCpzoOsaAYNW/pTcFACWWK0k/+HCVK5WSzNX3mvaU+VlYY3R1PHxXKs8wryISNC7ddT4zM94GbVIk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Thu, 31 Aug 2017 11:01:11 -0400 Message-Id: <1504191674-3949-2-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> References: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR08CA0056.namprd08.prod.outlook.com (10.173.236.30) To SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 672ecd67-b034-4fdf-62e8-08d4f0812861 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:92gGUaE1de+9WZTnuk6R1GWeXLHtBV4JRpJbSQHoXaEy8HfeDtNorsX7zlBb/KmZ1oXiQLb8URLvBgpm+g2r/QpEQaScaF84HoKqIYr6OBNKUHU2wbJtQoQO0ih99Hm0YfEyrPFXEzmUZx3MI85Er2v1UsZi1jUUEbFIeam7LSExFdCJR/VNSQytLTXhtPmLVKSZzszqcZezHDrxEAXMrVmwMsgoj4xONqzpDjk2lS2NtM26F1gzj8zhl2KM+mm1; 25:sxS+bq4LfbzGVUehEyGcuAOJXh+NdlAgOSRj7/MSR04AucUK76v+plDt5IUm5vTOl0mixek5XZ6tYAmndZ4Nza1jFYmnZk0fLkw+rWIkpDKbeUxsPBMMUqEF6pLN6pPdWIV6H4JBZTguin6CRdVeD31KWJk47tcQ/BEuxDRquDzqNrVR3MaFnXtdDHXSQZRWe3bDPLwVkHL48sY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WhE6LTXlEnALBiovTLQLJEu/skL9TLgQCV2+DiBu0F/h3BbE+RZC0o7z4zxxOZ9OTDHXH6U4iWTihbf2fcvXSdbtxQvvA5+fCI/GjblVFxoEAMvalrN+jK58cC9yCdNTcgR9ZtSR+/diicLy8G4sN2+S2yPKe4lTrDbp+NsR/RXWS/iuDOyp1bJaV19WirA2W/TkVghgaFPXWTSAA== 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)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0158; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(51234002)(199003)(189002)(81156014)(8676002)(478600001)(81166006)(5003940100001)(50226002)(76176999)(8936002)(4326008)(50986999)(2361001)(110136004)(2906002)(2351001)(189998001)(66066001)(106356001)(105586002)(7736002)(42186005)(53416004)(54906002)(47776003)(25786009)(97736004)(53936002)(33646002)(101416001)(305945005)(6486002)(6916009)(2950100002)(48376002)(3846002)(6116002)(36756003)(6666003)(5660300001)(86362001)(50466002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; 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; SN1PR12MB0158; 23:P4E4t/5idi9vt/Y1Ab/3KOy1WDqEp1g0uZTz7l2He?= =?us-ascii?Q?nb/bpjnwgxFGoTgV3YWvLEbAtjE6qrNR4+X46AjogSgodOOmGCpU+QwlBlF3?= =?us-ascii?Q?aEB8qe61Am2r509KLOVmrF+C8ZnfL+JiWOaH79fE7LRfkzsJRFlNgKgGGrc8?= =?us-ascii?Q?ebBgL3NiETXs7QGUU+HQtr/5e+gGEHs2JIcVHMOGDX4lGm5vzN00BJRi0oOC?= =?us-ascii?Q?ROKE7HU6hFjD5cHxDMS7vu+AWS6Q1+QxAsvrzXU1jI/yDeA+MgSDcxFl+ZEN?= =?us-ascii?Q?6xO3QnTjvfbYw1BuP5SQp9lF0qyhnbIh5fwy0bHrnrJLNmoJJuymyGORtp7x?= =?us-ascii?Q?3fMvP3EZMxEctNe16/gxJjWEIfAY1FhOn/I4U1yRR5EAEFlYmvMsfV5sU51S?= =?us-ascii?Q?Tu3Xy/KxUreUcCT/SFB0HbHLL9uSIB03O61/4SX/q+v4vVsytogFRfFZeTgR?= =?us-ascii?Q?D80zfa3LUn6k3b/c1DrqgGBrHMIB5D/GMnXLkvBqvmxBSB4lBfBcAm4OrLAJ?= =?us-ascii?Q?7Nz2hSNSpd+ziCFhviR/5IrqFAVhhMNseYpaSxOHbUx0qm4qJVkB9ruQ3p22?= =?us-ascii?Q?ynyjVAwqHsAEdPu7fLYOJ9r4KX1zObx5mN5yMIqNiOpjsHyYeBg+TnlC9GUa?= =?us-ascii?Q?XpXw+zFg9ov+taKztzTkdTFrhQ6aqCuarfG7r6n1ier5G/2fTXO/FMYglrAb?= =?us-ascii?Q?EMtPZ7xT6rYcN48j0gfuDeoN66Dy8u1fERKuqW8b2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ZuNeU9nzbTHnK4mYpNybMbW2jv5FfLlceqk04qe+Z5TrYWb1rHTZsRNCdWak42lQyvik=; 7:u3hDJfitqwakYZn07MWLWlYfuVedS4HZx1xvXzf5Wi0K9mVWjhIXXxpqgRevMIE/2hrUXuDSrO04sRHZXfN5pfWrSA4aW2y/GOc1n6CUoJ4RNJL90q2jg0X9AGSGrqCaQ4TkF8HekuJNDc3OEtQxZuSLliQl12+s2TwmyuLyzsincakwGK2nSTC/Ax49J22wBVzzjZHrS62k0CxMXeRkK3nEHvDJRckK2iflMYMt6AM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:fxhi6EImPdMKpVWKBQG9Xlz8X2mLe0Ao42SnqI6lrPMOjrp+MGrr3bcjCj7ybbWSQwzKs3Fubu0NjI6H5EwQfJuHCcjl5hCCQysT1ictLd6hoYhulcw01gE2ZtWfjH24tD6LMEPGTyJvNs5riczaub///G6si6GWSvj7HavDc7uyW3JUpSxQpX2NkaEvUwHvGotvPw2AOuS2EHGPKMVTItcbXhXNYAwnsbZ8KNe2uZnkAqZMTXeRk2Q3YfksyUdo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 15:01:27.7188 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 Subject: [edk2] [PATCH v3 1/4] 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 Reviewed-by: Laszlo Ersek Signed-off-by: Brijesh Singh Tested-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 12:13:26 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 1504191698112227.44331013999988; Thu, 31 Aug 2017 08:01:38 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B4C922095BB94; Thu, 31 Aug 2017 07:58:51 -0700 (PDT) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0069.outbound.protection.outlook.com [104.47.37.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA0F42095BB8A for ; Thu, 31 Aug 2017 07:58:48 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Thu, 31 Aug 2017 15:01:28 +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=dL22XaQWiPEyUhgQFndyDcxZhhiRESs2ro9h2wiFfe4=; b=uv6+ja4KRRW2vmZsfaNEg7IZgTz4nokam8eD0QYjj2vw7NsmPcB60rlw+xU6y3Cl8gnIfSf+oydeMxxkAOJ/CVFwAUHRizUiLxylMi45xa5y2QHA00hryvkdfWfshjBcU8Wec7QSrrmJ46xjnCV6SpCGoIVvPbjLa7GooumY3r8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Thu, 31 Aug 2017 11:01:12 -0400 Message-Id: <1504191674-3949-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> References: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR08CA0056.namprd08.prod.outlook.com (10.173.236.30) To SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afdf0e72-27b4-49c7-e305-08d4f0812924 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:8/JG/ROgUqW3Es+pkZpwYOLzC0+tKgbe+ff7dNdES6UPi6pIKRfCv6Nv2QBCkvxLlYMoTfk0qxbZ5XVtVts4Co5TWufgQvECGTHqPTmcPJQhtqbN9SkvdfiCvwOBqQ7t1VY++cvXcpCIuWnREP8bzH/TJjXMBDmmTRcYWKWNbwlMw67uyG3RflxAgWWrVrAseZE2q0DZYVno2odJUtZ+AWqWAf3yl8LwCnK5rz+EpAiOrkadVsFBtWrYILdvouhb; 25:bPUmHlT/0kTn7g31Ufa+aczfqLr2L6W2ZkeXPAXQztLVYGt9Hjk3mnKO58PftNIfON671yNR0aAl9OrxUj5OZ4CflUmqE3d4fi8mOxCpcP8tg8HkwPxFJgG1T6decDW8Kj9Z/7I/gLFxDf7YDvGxdnUgX1HHgn5mKswHFXeAihAGyRoOBqsl2gdnVLEBmpF5pZNx4jfUk69mbh5s2bkZGskEy+jZAbTaU9V9jV3u7PvZrngftLti5H4uASxYYjdyK04H66nl7njgvQSB26AoKvqsmtPmzsapwYuRoLV9nxGeOJPKL7iOm45I++qoftRUkeVRAHq7K9MkafcaRD6YgA==; 31:B81b6s5gzP19Lt9/u+fkFPd7rf1rsT2eFDCy11iT15UF/MH/gqEWFau6JyFmzADi/7ZYycqXPGhuLyfSPymOL2/fnLnkX6+sjrSY0IcKilqRc0VDtjkZaHIO29R8T++l9Iby4W5k4Vib0Mb2jrNls8TADWYqCVutlr15lO/DQgCiBwC/yeZ/A2VL2ab0TsrTp3nfP4/v1deM6LCy0QjSgUiBoEiYSMO/zyUo6qXet78= X-MS-TrafficTypeDiagnostic: SN1PR12MB0158: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:L5phPXtMee1rEWA6l0XncaxJkOCGOvXIlS0kPIfIHXj7FnxoVfYKpKVVYAt3t6bqyyOAAgBUssk5VsDJsjdt576/sKRcyX+QsZubVVpWPi9JUzluqRKGjJ/SUfOtmHyr2hvv1Qfce0UH2X4dN+BtYcUjcjidKWe5WDONFPwRA7f21vECH+PUN+TUYhxW/jqlacEblQnKt21JEJadqUAr5HYNOi6utrINYIX1C/ztPBNeL+wjqay8iwfNpeDXLItFby3PwEGbSvN0Yz8G482/No2x5i5uCedHsQF5p516mwaa/sk18kavSKDTa6tz2vUBCP7Y76UmiUY4DJxcJcSBQGV23t8B9PgTCF2mkZ3u3pSYNp7pAKfIDiSSKVo2SGW+n3D5VgS22CdZ06JEyarent7UDtcCIuz0Hk/r73SgFHEwvRWs9Oq+GxNM8ebdyZ5Gxs06LS4weFooaoz4J3F6JT9+8XSRdelWDNfm/bUUZqMlotuEydKkBw13xkBkbo8Y; 4:J3HX26Rz5pM4Axs46pKgXGg53cBsgTqhts2GpWupgGcBUncFG04brm28iVXJRpyuWdGotfqlbuji5JdoTClT1x6vi9iacE4et2tPDlN5O4nH90niKTW00il/eKLGa9l3RK4GSZ0d5lmz9rdmErQyDtpbmsx5chw8MEqdqFmdv4/IZCZ52kTqowV0ccVKTMkkE/X9UFCQrPQqXZGTpjFzE7Eszi4J8Jl1w1pJd55tqp3dJ32aECyHZP6b7TNkZTHbA8qWOULLg0wMFbkP1eIreOmnHhgL5nAUd25gHbt0Tad19RfFGBcQrzEfWPAGiTH0LXKaBS96K3ucIg0yv+55lw== 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)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0158; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(199003)(189002)(81156014)(8676002)(478600001)(81166006)(5003940100001)(50226002)(76176999)(8936002)(4326008)(50986999)(2361001)(110136004)(2906002)(2351001)(189998001)(66066001)(106356001)(105586002)(7736002)(42186005)(53416004)(54906002)(47776003)(25786009)(97736004)(53936002)(33646002)(101416001)(305945005)(6486002)(6916009)(2950100002)(48376002)(3846002)(6116002)(36756003)(6666003)(575784001)(5660300001)(86362001)(50466002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; 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; SN1PR12MB0158; 23:gKEGoUtNcSlkRMwL6DARRMpicLfFogZr2H+UEK4LX?= =?us-ascii?Q?7zajMp+TU+5muNe3E4W+Tb/sBkkNz0JowOc6wITOK2LiWDcEBKDUKqes9AIq?= =?us-ascii?Q?5uEEpS1DqEeS8awzqOjqlPV4QdZLqJu9QJNwp3Jn2xXzhBphlIs0zy3vDNUQ?= =?us-ascii?Q?kl3xQ2rZrWS5CTEvNTVhamZ+nWQKOZ5Lj9vJrf0xbE3pGJIRS3HuhCdA9kYk?= =?us-ascii?Q?3ehg8eLvKCIACBo2gflRO9Y5UxVfxRUpCnkmYU+tfJ2Vr+pTAObiuJELW2tn?= =?us-ascii?Q?Tp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6SmViiRnIpzBTjrg3B8XDjIxeFDlnYeV94mkBQlh89tA853aBnLlOEeFAd1+d6K2VUbybbMS+zdZ1avOb98mgzPIxifg2r3VS7wEG/RdS0GxhuDh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 15:01:28.8438 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 Subject: [edk2] [PATCH v3 2/4] OvmfPkg/VirtioScsiDxe: add helper to create a fake host adapter error 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 virtio request fails we return EFI_DEVICE_ERROR, as per the spec EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() member function is required to implement elaborated error reporting. The patch refactors out entire block of the code that creates the host adapter error into a separate helper function (ReportHostAdapterError). Suggested-by: Laszlo Ersek Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Laszlo Ersek Signed-off-by: Brijesh Singh Tested-by: Laszlo Ersek --- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 36 ++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index 5e72b1a24b59..5e977c636a0a 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -97,7 +97,7 @@ // set some fields in the EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET in/out // parameter on return. The following is a full list of those fields, for // easier validation of PopulateRequest(), ParseResponse(), and -// VirtioScsiPassThru() below. +// ReportHostAdapterError() below. // // - InTransferLength // - OutTransferLength @@ -387,6 +387,33 @@ ParseResponse ( return EFI_DEVICE_ERROR; } =20 +/** + * The function can be used to create a fake host adapter error. + * + * When VirtioScsiPassThru is failed due to some reasons then this function + * can be called to contstruct a host adapter error. + * + * @param[out] Packet The Extended SCSI Pass Thru Protocol packet = that + * the host adapter error shall be placed in. + * + * @retval EFI_DEVICE_ERROR The function returns this status code + * unconditionally, to be propagated by + * VirtioScsiPassThru(). + */ +STATIC +EFI_STATUS +ReportHostAdapterError ( + OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet + ) +{ + Packet->InTransferLength =3D 0; + Packet->OutTransferLength =3D 0; + 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; +} + =20 // // The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL @@ -472,12 +499,7 @@ VirtioScsiPassThru ( // if (VirtioFlush (Dev->VirtIo, VIRTIO_SCSI_REQUEST_QUEUE, &Dev->Ring, &Indices, NULL) !=3D EFI_SUCCESS) { - Packet->InTransferLength =3D 0; - Packet->OutTransferLength =3D 0; - 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; + return ReportHostAdapterError (Packet); } =20 return ParseResponse (Packet, &Response); --=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 12:13:26 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 1504191701412568.8448758938365; Thu, 31 Aug 2017 08:01:41 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F2F622095E01F; Thu, 31 Aug 2017 07:58:51 -0700 (PDT) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0079.outbound.protection.outlook.com [104.47.37.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 015D821EB5269 for ; Thu, 31 Aug 2017 07:58:50 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Thu, 31 Aug 2017 15:01:30 +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=hx/31elm9bY1rZZAKeiMTYLSitOBtCjCftpU0TXkUHY=; b=4gcApEsipwRecJzMHElk35E1KVELAcnE/0NTWSZRG/4KpHqLTk7TjO7S9RM45eix6WNoa0xtoCUE0HPsamiKkWeVYun7Yh+7XDkw8obCJC2DLWzGdDtxOFmvoP39PtvND+rFGJro0iHIV3SdsvdicaQHzddoov2HAyYuLXOLnpg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Thu, 31 Aug 2017 11:01:13 -0400 Message-Id: <1504191674-3949-4-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> References: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR08CA0056.namprd08.prod.outlook.com (10.173.236.30) To SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0cb09188-65b9-4e1a-c583-08d4f08129ea X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:0T9wtlaW5E975wmjX42XG4FtnYH0+THIK/onSjaeJvZK8i7sz5h26V/MG3YuHTcTTMppSPdxC1zt+xNq+uYpXugq9+jGNZZ1WQV6mwM7YO899ljrVcSF4kc4hRuizPUBFLNndQuDJxeuBfejoIFz/WUplO1VyH+xqp7LUZhQ6f2U15mYx8AJXEbWVLU+svMksW+eJQ9ZcujC7lFx4WbEvhzIntW3wFTMDCveLod7sGCRx8UYFYp7FT5b0+tWe05x; 25:2f0L8BsL3/PWqG6DqSOkLLxdlhIa2N3+MB5EYv5o+HOPH8Wde9Y2puA+8bzPhUMTf3DZDPY1h+Cc1jFdXUQmKKbophM5zNoLyKbJwVFxIb8Q7AoMj1UQuqgcZUt7YI2us+siGwOh69ModfKV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tOsJXDg6/aQ5NitIrKhw2EQIxu4bIEhFJWIiqRGCJw8JgAxHDFydmlpx3ftqqHuebpYlfBTRRNpsteUVLW2x/HvF1fB6WIN/GfhkckPiDrzeMuKr283FSS61pn6nL5mjeqaOiM3NgN9DmUhCECLiiW9WrhaO16NK3JkSDqTtFOseYQnF50TUBwQ2FdL38pa+5TNmCQ2xZF0TQrg9Yx9T45DPgbIRGUEusPyDH/ptAw6rMfNgOjzTQxMvTt5U5qnEQAJBWVvaA7iabPmNaiZnq+7W1m2cQdkO66ClKmPzZtIZNUJt+cn9pqTmDfsZEEs2E= X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(211171220733660)(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)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0158; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(199003)(189002)(81156014)(8676002)(478600001)(81166006)(5003940100001)(50226002)(76176999)(8936002)(4326008)(50986999)(2361001)(110136004)(2906002)(2351001)(189998001)(66066001)(106356001)(105586002)(7736002)(42186005)(53416004)(54906002)(47776003)(25786009)(97736004)(53936002)(33646002)(101416001)(305945005)(6486002)(6916009)(2950100002)(48376002)(3846002)(6116002)(36756003)(6666003)(575784001)(5660300001)(86362001)(50466002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; 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; SN1PR12MB0158; 23:xIgEkszQJh2AJHyfkdVmKdyWlj1lzqeYyj+E/eEZF?= =?us-ascii?Q?CjKUcYjimNu39uGam1M4W//oX9gF4NP+/TjKyrIGCuReru3Z/2HcXFN5QJGr?= =?us-ascii?Q?IJqNYX8wJwgAdfBaOHzbrV9owMFRe7oks38do0t6agDPG7fNTlMpm8Gbclvf?= =?us-ascii?Q?St7blN0ZYi1glfY5OqxEFOaMB5SsZpUDyI0OMb/t74rXxIspE/BuFyFNiXZY?= =?us-ascii?Q?lMofHW5BUYjRVzPRp8+epaPi0H/qrHEx+XNW7Xzus1lcnc1XNDB+zcnS6r6R?= =?us-ascii?Q?9xN9iGvAVdISYKaJwn4/JCFp0G4seklsAH5P/y/5HRj4StfJzG5tQB16Qjxx?= =?us-ascii?Q?fL8dMOlX7yY9S9vTku88XykiCJV2Qm+TAF3KHTqOfmbLq5NlWPN2/VmFwwqb?= =?us-ascii?Q?7P1ftDubzHvkILN4DGG82ccf0FyL0NDr9IwpxEVIxvOhA5x9u1GghInA26gP?= =?us-ascii?Q?Jc2aC6UD/G6v1te2spAZLg+u2YvkKr2Ozpws9txzKrrD1Gu9d7L7iqpFN2PH?= =?us-ascii?Q?EOYok0u2iXgGCKB6Pj70aGgkjCR1v8xsVBGcGN/lw+3RngvBJWXZIP0c4FE/?= =?us-ascii?Q?I5G6HC4PlmENxwGtPKNhv4Qi9zc95hFKdCA/mWyecgjDB2BP7D8fyfpiwBaa?= =?us-ascii?Q?8v6UJ/7hZWn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RP5diqhNnCdCNgIwJ/JOqDQOvHaI8AHVNx6nlLTebWIg==; 24:8msblz4WULyzOJiwHwYGji40FrGCu7lTMnpXcOj7afLX1okv93Jgxjgma9hP+igdOf3ojtliJpmjmPqTkWGzVebDEMiL368i9mUL2GpHkpI=; 7:CNYWxo8zzansKWqI3obwor5GCL1zdBziGiRd8lIpu2TqpZkjw2n+ew0URiw6XhPyYGxt2WLQxG8tqniDbQ+/MtelyxADlcNx02s8bnFa6M4eZWe13eZz60jvXqET/ZoE51ieabGMtGSDBfhrtF6QNuIt8MdJVAR2Q8oZhaNJNKGIc2SYoLvVCydDdeCMz9xv4VpSh9gNkWHROTRjUZziZ307IvxS5ENWV5vxo+USQ6E= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:vURlG0RvnmpD/8lziWl4g7PyLt9xZxnd7bpJ6MsV4uaBd4bOPrCflY24fMKUzc9/17QTxRvNzG0pze4HXb9aEgtRt2uTq+hwY8nWuRBkSPviVcCWyNCFTRGItrG3JlfJYYHN9eexYKdRhfU46MMGzQOACw59npZHv20wLcoZKHFi4avX6SiKwxLeEXTBFiwAlqcjf8RjoStPaCpcgsqAShQ1NprlWnNdZVXbD7XxX5EIKiKRHxBp1Zpr7119XIlL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 15:01:30.2813 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 Subject: [edk2] [PATCH v3 3/4] 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. However, after a BusMasterWrite Unmap() failure, error reporting via EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET would be very complex, therefore we map such buffers too with BusMasterCommonBuffer. - 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 Reviewed-by: Laszlo Ersek Tested-by: Laszlo Ersek --- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 220 ++++++++++++++++++-- 1 file changed, 204 insertions(+), 16 deletions(-) diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/Vir= tioScsi.c index 5e977c636a0a..337fb4b2f1e0 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -436,26 +436,156 @@ 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; + VOID *InDataBuffer; + UINTN InDataNumPages; + BOOLEAN OutDataBufferIsMapped; =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); =20 + InDataBuffer =3D NULL; + OutDataBufferIsMapped =3D FALSE; + InDataNumPages =3D 0; + Status =3D PopulateRequest (Dev, TargetValue, Lun, Packet, &Request); if (EFI_ERROR (Status)) { return Status; } =20 - VirtioPrepare (&Dev->Ring, &Indices); + // + // Map the virtio-scsi Request header buffer + // + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterRead, + (VOID *) &Request, + sizeof Request, + &RequestDeviceAddress, + &RequestMapping); + if (EFI_ERROR (Status)) { + return ReportHostAdapterError (Packet); + } + + // + // Map the input buffer + // + if (Packet->InTransferLength > 0) { + // + // Allocate a intermediate input buffer. This is mainly to handle the + // following case: + // * caller submits a bi-directional request + // * we perform the request fine + // * but we fail to unmap the "InDataMapping" + // + // In that case simply returing the EFI_DEVICE_ERROR is not sufficien= t. + // In addition to the error code we also need to update Packet fields + // accordingly so that we report the full loss of the incoming transf= er. + // We allocate a temporary buffer and map it with BusMasterCommonBuff= er. + // If the Virtio request is successful then we copy the data from + // temporary buffer into Packet->InDataBuffer. + // + InDataNumPages =3D (UINTN)EFI_SIZE_TO_PAGES (Packet->InTransferLength); + Status =3D Dev->VirtIo->AllocateSharedPages ( + Dev->VirtIo, + InDataNumPages, + &InDataBuffer + ); + if (EFI_ERROR (Status)) { + Status =3D ReportHostAdapterError (Packet); + goto UnmapRequestBuffer; + } + + ZeroMem (InDataBuffer, Packet->InTransferLength); + + Status =3D VirtioMapAllBytesInSharedBuffer ( + Dev->VirtIo, + VirtioOperationBusMasterCommonBuffer, + InDataBuffer, + Packet->InTransferLength, + &InDataDeviceAddress, + &InDataMapping + ); + if (EFI_ERROR (Status)) { + Status =3D ReportHostAdapterError (Packet); + goto FreeInDataBuffer; + } + } + + // + // 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 ReportHostAdapterError (Packet); + goto UnmapInDataBuffer; + } + + OutDataBufferIsMapped =3D TRUE; + } + + // + // Response header is bi-direction (we preset with host status and expect + // the device to update it). Allocate a response buffer which can be map= ped + // 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 ReportHostAdapterError (Packet); + goto UnmapOutDataBuffer; + } + + Response =3D ResponseBuffer; + + ZeroMem ((VOID *)Response, sizeof (*Response)); =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 ReportHostAdapterError (Packet); + goto FreeResponseBuffer; + } + + VirtioPrepare (&Dev->Ring, &Indices); =20 // // ensured by VirtioScsiInit() -- this predicate, in combination with the @@ -466,31 +596,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. @@ -499,10 +647,50 @@ VirtioScsiPassThru ( // if (VirtioFlush (Dev->VirtIo, VIRTIO_SCSI_REQUEST_QUEUE, &Dev->Ring, &Indices, NULL) !=3D EFI_SUCCESS) { - return ReportHostAdapterError (Packet); + Status =3D ReportHostAdapterError (Packet); + goto UnmapResponseBuffer; } =20 - return ParseResponse (Packet, &Response); + Status =3D ParseResponse (Packet, Response); + + // + // If virtio request was successful and it was a CPU read request then we + // have used an intermediate buffer. Copy the data from intermediate buf= fer + // to the final buffer. + // + if (InDataBuffer !=3D NULL) { + CopyMem (Packet->InDataBuffer, InDataBuffer, Packet->InTransferLength); + } + +UnmapResponseBuffer: + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, ResponseMapping); + +FreeResponseBuffer: + Dev->VirtIo->FreeSharedPages ( + Dev->VirtIo, + EFI_SIZE_TO_PAGES (sizeof *Response), + ResponseBuffer + ); + +UnmapOutDataBuffer: + if (OutDataBufferIsMapped) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, OutDataMapping); + } + +UnmapInDataBuffer: + if (InDataBuffer !=3D NULL) { + Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, InDataMapping); + } + +FreeInDataBuffer: + if (InDataBuffer !=3D NULL) { + Dev->VirtIo->FreeSharedPages (Dev->VirtIo, InDataNumPages, InDataBuffe= r); + } + +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 12:13:26 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 1504191705678480.7747138121272; Thu, 31 Aug 2017 08:01:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3357221D1E2E7; Thu, 31 Aug 2017 07:58:52 -0700 (PDT) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0079.outbound.protection.outlook.com [104.47.37.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3D67E21EB529A for ; Thu, 31 Aug 2017 07:58:50 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Thu, 31 Aug 2017 15:01:31 +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=Ca+7RmUpSEsluXJB6g9EgxLR6kHdyI9Bw9K8sAtzFZg=; b=TxDHQJvdKW9kxhU+SviYF0cM15Q0ZdIghmGqHdllLCKBQFvBgytc4I4heWhmRPIQd1ePRO2rX22Ia359BNIjxHO2zIheKo2s9i1z9NLIBpH2PFKzCIelx7oEXwipq45lqmoLNyni/vQWuM12nq9tSuGqfTAiYKzHsYCOG+XJ4ws= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Thu, 31 Aug 2017 11:01:14 -0400 Message-Id: <1504191674-3949-5-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> References: <1504191674-3949-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR08CA0056.namprd08.prod.outlook.com (10.173.236.30) To SN1PR12MB0158.namprd12.prod.outlook.com (10.162.3.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 679ed136-5761-4a6d-80eb-08d4f0812aa9 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1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KIODXsa0YScPz3Jvk7xPwMWvW3tJIb0YyToxIgCbWS5EMZijFCD6t5uQlX3DJ0faFj8WJGdEHlkf1e4ZDz2nQuSWmI/ULY0Ocg9hO4oD0zdnoE/JBjU7SJzFqP/ff7pEFxNYghNFvF535r2tvtEagOi0KOfhXc7lEgYlEW78A6NNVqD6btL1LMp4w6eNn2jRU1sIC9ZLlacHW6pNX5zPz4A8pnj0+3eIvqs/DcK6p6WV3zf8V330IFJVl6dxNe9SmidQQbevJ2NHRN1AgEfNd7ieHb1aQi0H+k81IsOM5t0PnmOZ0LAQuRmfI0PW+3ivND0mHMVbPgtO/MaVDzPtHC7R/DagVHXLAJP6PeNw; 4:Eaq7Fjp/OidlITkt6lvTldSmaUxrjv1/O0myrKWhUaSJ8zxguJHq53+xQMSSJz3aB8vKAFAdSCsvibO/UFHMKDSGTcf/9gSNLNLFHKUNmuyeqdyIQKo+ax1IGSb3A3GFjgZ/2X9le+CvkO+VoKEiD7ANeaCp35KMYvvfbN6U8z1ZtspRkBHlQA27n5QavmiGVREAsJQ51aeHzEtH3XeT5iRAXef8VLm8TinzZadrKppUHMiuu+O5vkRukA0DQJzwSEgnnlF/w4N7kx4DV7Idk5CfviGjtKkMYmIqqDyUGhk8P75fCJzijPb03OSSVP6dhVcBUW+TESq6e+6ogj1bHg== 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)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR12MB0158; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(199003)(189002)(81156014)(8676002)(478600001)(81166006)(5003940100001)(50226002)(76176999)(8936002)(4326008)(50986999)(2361001)(110136004)(2906002)(2351001)(189998001)(66066001)(106356001)(105586002)(7736002)(42186005)(53416004)(54906002)(47776003)(25786009)(97736004)(53936002)(33646002)(101416001)(305945005)(6486002)(6916009)(2950100002)(48376002)(3846002)(6116002)(36756003)(6666003)(5660300001)(86362001)(50466002)(68736007)(344415003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; 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; SN1PR12MB0158; 23:PFendrRAKWpfw931T2FOPxZYStXfsNzJBF2M9QVvM?= =?us-ascii?Q?/wnHqrtOxvoh4OFf2wTIk3gHTJ6i/yG7wwkV80QpoQCSHU3duEo6Neu+MmuS?= =?us-ascii?Q?p+KxHWHLsyzRGQotl82RUONgkQxAuDGgFJHuhztr2yedSf/GABhE1Sk1p8tn?= =?us-ascii?Q?Bqh1B5Hclz6NN42DDg5VZqG1bxX5mn+wIwxYwKFXJrgKjXiV/xmW5dLDugbx?= =?us-ascii?Q?yqVTuIXM9bjFCbyAkxMe8KmTgXidxEuK3XQVR3GFOuvXQ9WpMtuIDEf+Q5C6?= =?us-ascii?Q?OxYIw0Er6RjSfoJe+4b+JT6XuI/raw3GncC6onKjyqEP/h14Aylj+zktLO9G?= =?us-ascii?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meVkNH30KCTXBmiBAwvqPqnyWHNi2Zhe5oag8aIuHg/P X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 15:01:31.5469 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 Subject: [edk2] [PATCH v3 4/4] 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 Reviewed-by: Laszlo Ersek Signed-off-by: Brijesh Singh Tested-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 337fb4b2f1e0..313b4f66c7f8 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -1011,7 +1011,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 @@ -1091,7 +1092,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