From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2DA9B2095BB90 for ; Wed, 30 Aug 2017 10:41:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7524BC058EB4; Wed, 30 Aug 2017 17:41:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7524BC058EB4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-136.rdu2.redhat.com [10.10.120.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E71E98169; Wed, 30 Aug 2017 17:41:35 +0000 (UTC) To: Brijesh Singh , edk2-devel@lists.01.org Cc: Ard Biesheuvel , Jordan Justen , Tom Lendacky References: <1504110509-2306-1-git-send-email-brijesh.singh@amd.com> From: Laszlo Ersek Message-ID: <9f1d24ab-8e40-7b9d-1d42-49a83d1d9770@redhat.com> Date: Wed, 30 Aug 2017 19:41:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1504110509-2306-1-git-send-email-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 30 Aug 2017 17:41:37 +0000 (UTC) Subject: Re: [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 17:41:34 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/30/17 18:28, Brijesh Singh wrote: > 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: > I slightly corrected the subject: -OvmfPkg/VirtioBlk: Check the returns status of unmap data buffer +OvmfPkg/VirtioBlkDxe: Check the return status of unmap data buffer I tested this patch in the following environments: - no SEV, legacy virtio, X64: PASS - no SEV, modern virtio, X64: PASS - SEV, modern virtio: PASS [lersek@redhat.com: fix typos in subject] Reviewed-by: Laszlo Ersek Tested-by: Laszlo Ersek Pushed as commit ea8314e4402f. Thanks! Laszlo