From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0051.outbound.protection.outlook.com [104.47.40.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F39612095BB62 for ; Wed, 30 Aug 2017 09:28:36 -0700 (PDT) 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=VQCOWCWAKxSN1RQuKcGT05LzDJcUx3tpBqL54VT6Yqs=; b=naqDk/e3g0Kd/Cb4ocVmfptkhQVXiZaBaoJMRWFhZ1T4FRz9SxbS8C1u6iCw9XaGOnVgF2O58cVepiz1RZ4gucgARNMiSzMdro8OQMO0CDOCTnuknvphLYEEDgdIqOo6lL9uyubSfkBi0qZgA39D3do6sqTNnn0P6AWK5kIRkfM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from brijesh-build-machine.amd.com (165.204.77.1) by CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Wed, 30 Aug 2017 16:28:39 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Brijesh Singh , Ard Biesheuvel , Jordan Justen , Tom Lendacky , Laszlo Ersek Date: Wed, 30 Aug 2017 12:28:29 -0400 Message-Id: <1504110509-2306-1-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR13CA0079.namprd13.prod.outlook.com (10.171.162.17) To CY1PR12MB0149.namprd12.prod.outlook.com (10.161.173.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca10906e-a8f6-4fb4-05d5-08d4efc42bca 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)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY1PR12MB0149; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 3:1Rq4qgvSlsfrtWag2jvZwS0Lq4mro2bxAMJhENyENLPcolKeTS6sq/0lgkZoYbxIU4skGiKWpbZ2pl6+gcU4Kf36m6sOVbNsBE7CK/KwDnVwmmDbFXOoegy9UQfbKBaM5cXOcI1TOah7mN48STQvQyEkKxRuI9+Xuy916ZARHLKsMXDToACFzrK31p05gmjlhZPRAA6yiZLJZP7yOD23KMaw29uvW/nQK7GG9c9Kg83QioDpuOq6L+lAVa4gfLGp; 25:b2P0WBnxU3i9FT+WP/kw01i+KGkkI7lPQXT/7xpTmwTK1K58vkls5vv2s/ZevItGpd1oZgsXTWuky7TY6IHtHBLIlgaD/Mc0I6C31o8Aw9rtPgcj5MBkI3DFf/0C2So5vBblqc3slsJMIZJzSryRj35BvY2LdOi9D1mQBD61lFtRAdRme84tujAuz05L4Vqqjlh+9CQLBfKZ3ZhR9cvCCqxV6rcDibaPyix7AtWd6NNKIv8xMzTqVyQnnpqIYwV2KPinLngxd+dRmyAzR2kcEhJwlzs55qO97Vtscl72Ve0gtl1kv6YW5v2+/K/2W92TDgun7zFAhSCCphOvpS6RCA==; 31:hzNAoJpBwAKr090FHtf5vWUJVTbJmRuvVOGUfTt/oYVpLDUfXuwbgAHtI0S1jat1bbuP9gQhewLKHdqMv8AaDtnLEIZdmWnINHW27074zVSWt22IQ6SER2kaL1pyWcz+7rh1E+RdnhlQNoArBgnrkjf/njr9HdR9roFp2ow3Ot2PwtrPuj3n4CtfbMkWP1R3vjbMRTT6K7GLREVRnlm0l6qGGGK6lciAlU7tmdn+Oes= X-MS-TrafficTypeDiagnostic: CY1PR12MB0149: X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 20:tAVLhUWlaP0YF1Uo3wNW+07HMoAXsAzsfaIfzVslpOKZEIU3a5mMFoN7IdAyq7X0OwOCS2ROXsbM1xr2hcqUDRTve5Wj+dfd4/XVjBqaqZPa3QGT4pP3TQGQlHOvMzjb5tmIk4klNBK7znLgOlBimFKyY3VwzTmZjuM94wEqFVSjLJmALd479g/trORfLoEKy9nT9Vm6KU8J5+hFuKtCRwfJhGAKZThcYwxxgyunEuxBdeqTHKlq4grsx8t8QQl/zoXKwHkqhjShOGpmIp2bZPKmjZmd4uGtmZrE0m21GJ+AZ3wDdu4TuGfwuRT5rpg3pPVnWxeXXKDZf/dLZdb8/lyK/OJDXzmCdPly0VVwQsXML4hyt5nIE9xZwjcgoTPoykynKfDm+zaTxkLeK1zAP6lCh667e9JdA5IXkEXpbTZRGlukt8dShPCxJeqFMN44ftYGLLtXoTS5cP8nE6HrV9GsBJf37FEraCzgFgd50kz9anpsXS22j0V/dsTeet6r; 4:FY4dNciDVXUgWeDzSkDSb6j1tYiIAuPOMHrt5Jvff+gKnDPNJiArwhaz7OMNA1LfNLvnOl0QOAoUxhcjWrpQw/O9YxFNN051llNjr9jQCdueL6OAl51fd71RUDVix8VKisMZpOKFFqLVgEIEIHuM/uRWnBymX3HILrXPhbvvV0YSBzUB/jN7kYJO7aO15alpq+rHoUE3XdpejS4OUKLZoPl7t88p8f1ThU+Glz15yO6BxhzJjW+Dh04wv2aiv6mNKx1V5oQgzSyjALm0Hcf0qFxyFh4JlYmTbG/yGpgNJD2e6sR48FOkug2EQYL67VZP8aKF8r10uX/zhXSJeQUCYQ== 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)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR12MB0149; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR12MB0149; X-Forefront-PRVS: 041517DFAB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(199003)(189002)(50226002)(5660300001)(8936002)(81156014)(81166006)(6916009)(6486002)(86362001)(97736004)(53936002)(2906002)(2361001)(50466002)(25786009)(478600001)(50986999)(33646002)(2351001)(101416001)(54906002)(48376002)(6666003)(42186005)(7736002)(68736007)(8676002)(105586002)(53416004)(106356001)(305945005)(189998001)(66066001)(47776003)(5003940100001)(4326008)(110136004)(36756003)(3846002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0149; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0149; 23:sYdzxlbqgPzh4GAa8lHYKMjTcYwiX0PBM7OcxP0MQ?= =?us-ascii?Q?GKAvQ3hqAhf0y//TUoFv5+uJm9spet4DiD6E9xw+WPuzuIMn97IP4RRQcPYE?= =?us-ascii?Q?yZmtc4UTKyLrNTFxnWLe1rfeOmRUZtiCYm8LyjFrNh5Asa8dHVQI4A/D/x9z?= =?us-ascii?Q?AgsG2WmPH8Fj1i2tO5FVYw1R4/TEipRqLgP+CX7h/aIFoez6v5NJ62CrT7eG?= =?us-ascii?Q?OV79mb7iIj4bXqeaJ+eQ2XB+JugiHPU+1XG1MxxlWz04aJeLaa2B1cKQGRcD?= =?us-ascii?Q?6SzIdT1MFEdCBlMUP9Qn0FGCHTnGLh16BC44Gcg85WoEmTBr/ji4mAeDuEil?= =?us-ascii?Q?dA0dtrRqLfO8Lsl1VXiwlkE8yRAJbc/DKXABrj/S4W3RnERbPzZHnm503lSj?= =?us-ascii?Q?KNetACQZiErDBOf5PkSlQljluDRCy6lhbD5urymHZlc1XMn9erb3ePwncL4O?= =?us-ascii?Q?2+c5YNg/JwmhS4OWU1U4GTF8vs1CNUBjGfMHozul2NfewvPpcUCqBfYYbvyt?= =?us-ascii?Q?pczdvZGXjaTP3b/TMUQZ85e0QnyjjMap9/1aUN+lCTLO4y8pI3EFdIDQsiRd?= =?us-ascii?Q?e/fsicNalQaPprrUwUIEfhgfw/QouBRH60UyfDxCzLBLe0j/tFnCxZXyapf7?= =?us-ascii?Q?g28ljabU7is7BEgam1W61FvEg/YHGHivJtV65ILCd7d/7plVAiMJzkwKYJ0c?= =?us-ascii?Q?tFwKZLbsXVZ2XGCbKtWKPAnu3PItAwDzV4Ioh/JOz3fWhTEOAra+FNUKcV4L?= =?us-ascii?Q?QPeXJygUs9NXQPhAiMX/x0phmeVUEMwIHsxsKcsQlPxQ/SNZ0iJJ7Q+zuV2J?= =?us-ascii?Q?hwjLRWPNL+rIJrJOygxsFUV6FIwzkGICWcuhPnZ9aKz6tsqRdr+XWNlxMdIF?= =?us-ascii?Q?22BgkFopIwbGVWwPkxDXg3tgqH0BZQX4KPvF7UMNP9tggt9zOMl+SK2aOS4b?= =?us-ascii?Q?msZyXVc6C2FFyWQsBAZy0G3UZ5uCGcWXYdkF83N158DsDZdK37zswyaKhd53?= =?us-ascii?Q?59rHdVyhFU6I7Lhd/y5lg85L3kE6Snz7wjp6e1ewM8iNA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 6:3K92I2leoGk1h3AxkojET0D23GCQI4oGAEosQ/jlOpYOVrvluN+oImuSb8QCKea9S8TtDoXuc1eq96qEhU5Tilk0czBvccmuMuCzpcHTUtL2GQI9psay6qnIo37zyvEL4QLL/4Ztr9CHrnO/4C4Je2pqVTGRvCM/4M8TI03cskV2xS8GkQUdj6TnbobIsYjSq5bdzO0gnVtfS/KfPhhrPsCRBxDfZH1sL9AMcEGYxYmLytr+LWDib1FKV6zqktSKRGXPzBQjhcRcupSBAaPAo+ajT32VqRDuO+OfoGJZwnlyd9VSvzVIvh/TbHnjYTji56GT3ftHAXrgE4LyZgemng==; 5:shIsY/q9USIOXByZ1sjBtHFGODv6aRuOSS/qwjIK76edqKSfzkPANXeoZ78XHdXtbIZB6egaw0OOUaLG5ivX4ObsP3mlCPOBQbiC5Lpd+YWyVID94F+hBtd6uCMQtj9iSSzXKONhymNvDRxbTzXDXg==; 24:kXGF3Z2JmnqputBptrYd077Q+Q2wnwyKA+OtwqUTqmxC0xwJvERTPvY2nVh+mdhLLrP98COO8+0snMVszsQZBMdhOLOmvsav70uZKOp5bzQ=; 7:07QpBhBt3BRT37/YPDJIZUiQQKIDjV2DypaSO9Mf1+1oxXvfFZY7VarOUwY8YYn/XBngulvgVN12ewf49siVtjOiwCiDjszfHqTBicQfrSPa/udknw3oI1h9+J64Rvh+cN6M5/gA2DafI1Npps52NNPPkGszpxY5VHId9j48vbMTvK3GrG80MSMmO69Ard0Fj4nfrT6QdKMl7241o81HkOiDOL/jRBrgHUaS+55zclQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0149; 20:yqPJCOyede1Gdb4S0Zai85qs/ceHoUFCrk4PiBPnBZWiieuAj3KSvKo6PeQwnGk81p74Ak5fzDAH1IafrISt75JrLLjKvH+1S1oW9Z5D9KYp1bIKdxiEatmnclU6mTjPiKjUEm8SawkhQngF1f7iSvZOLm4KNhPrij3PeutbjglYC1ILRi97oX/6WldnYfwTSywWmpw9KEvLAkymAJEgjEzkzx7emVoaHPPm9G8Ehmwu9Mbr3ku2LQKVA/ay5tRn X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2017 16:28:39.1027 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0149 Subject: [PATCH 1/1] OvmfPkg/VirtioBlk: Check the returns status of unmap data buffer 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: , X-List-Received-Date: Wed, 30 Aug 2017 16:28:37 -0000 Content-Type: text/plain when "RequestIsWrite" is FALSE -- i.e., the CPU wants data from the device, we map "Buffer" for VirtioOperationBusMasterWrite. In this case, checking the return status of Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping); is must. If the unmapping fails, then "Buffer" will not contain the actual data from the device, and we must fail the request with EFI_DEVICE_ERROR. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c index 6abd937f86c6..5a63986b3f39 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -260,6 +260,7 @@ SynchronousRequest ( EFI_PHYSICAL_ADDRESS HostStatusDeviceAddress; EFI_PHYSICAL_ADDRESS RequestDeviceAddress; EFI_STATUS Status; + EFI_STATUS UnmapStatus; BlockSize = Dev->BlockIoMedia.BlockSize; @@ -430,7 +431,13 @@ SynchronousRequest ( UnmapDataBuffer: if (BufferSize > 0) { - Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping); + UnmapStatus = Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping); + if (EFI_ERROR (UnmapStatus) && !RequestIsWrite && !EFI_ERROR (Status)) { + // + // Data from the bus master may not reach the caller; fail the request. + // + Status = EFI_DEVICE_ERROR; + } } UnmapRequestBuffer: -- 2.7.4