summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioBlkDxe
diff options
context:
space:
mode:
authorBrijesh Singh <brijesh.singh@amd.com>2017-08-30 12:28:29 -0400
committerLaszlo Ersek <lersek@redhat.com>2017-08-30 18:53:54 +0200
commitea8314e4402f6c385b6e41e4f7803853e64e421b (patch)
treefcab649ac3466a135f2c20c7647f9468bf34e0b9 /OvmfPkg/VirtioBlkDxe
parent877f4460b3e37064f37fe85375024dce04f5e05e (diff)
downloadedk2-ea8314e4402f6c385b6e41e4f7803853e64e421b.tar.gz
edk2-ea8314e4402f6c385b6e41e4f7803853e64e421b.tar.bz2
edk2-ea8314e4402f6c385b6e41e4f7803853e64e421b.zip
OvmfPkg/VirtioBlkDxe: Check the return status of unmap data buffer
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 <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> [lersek@redhat.com: fix typos in subject] Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'OvmfPkg/VirtioBlkDxe')
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
index 6abd937f86..5a63986b3f 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: