]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioBlkDxe/VirtioBlk.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / OvmfPkg / VirtioBlkDxe / VirtioBlk.c
index 6abd937f86c6c2c677d04b2652b465d0568937e1..95e42ef3dcc0a5da816fe7650cfc118029dfa2b9 100644 (file)
@@ -11,7 +11,7 @@
     synchronous requests and EFI_BLOCK_IO_PROTOCOL for now.\r
 \r
   Copyright (C) 2012, Red Hat, Inc.\r
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2017, AMD Inc, All rights reserved.<BR>\r
 \r
   This program and the accompanying materials are licensed and made available\r
@@ -260,9 +260,17 @@ SynchronousRequest (
   EFI_PHYSICAL_ADDRESS    HostStatusDeviceAddress;\r
   EFI_PHYSICAL_ADDRESS    RequestDeviceAddress;\r
   EFI_STATUS              Status;\r
+  EFI_STATUS              UnmapStatus;\r
 \r
   BlockSize = Dev->BlockIoMedia.BlockSize;\r
 \r
+  //\r
+  // Set BufferMapping and BufferDeviceAddress to suppress incorrect\r
+  // compiler/analyzer warnings.\r
+  //\r
+  BufferMapping       = NULL;\r
+  BufferDeviceAddress = 0;\r
+\r
   //\r
   // ensured by VirtioBlkInit()\r
   //\r
@@ -430,7 +438,13 @@ SynchronousRequest (
 \r
 UnmapDataBuffer:\r
   if (BufferSize > 0) {\r
-    Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping);\r
+    UnmapStatus = Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping);\r
+    if (EFI_ERROR (UnmapStatus) && !RequestIsWrite && !EFI_ERROR (Status)) {\r
+      //\r
+      // Data from the bus master may not reach the caller; fail the request.\r
+      //\r
+      Status = EFI_DEVICE_ERROR;\r
+    }\r
   }\r
 \r
 UnmapRequestBuffer:\r
@@ -1012,6 +1026,7 @@ VirtioBlkExitBoot (
 {\r
   VBLK_DEV *Dev;\r
 \r
+  DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));\r
   //\r
   // Reset the device. This causes the hypervisor to forget about the virtio\r
   // ring.\r
@@ -1021,12 +1036,6 @@ VirtioBlkExitBoot (
   //\r
   Dev = Context;\r
   Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r
-\r
-  //\r
-  // Unmap the ring buffer so that hypervisor will not be able to get\r
-  // readable data after device is reset.\r
-  //\r
-  Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RingMap);\r
 }\r
 \r
 /**\r