]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioBlkDxe/VirtioBlk.c
OvmfPkg/QemuBootOrderLib: sort [Sources*] sections in the INF file
[mirror_edk2.git] / OvmfPkg / VirtioBlkDxe / VirtioBlk.c
index c9c42aa41243b234a66726f52391ab0993128e59..55598843455dd9165678626bf1744086dafffc2a 100644 (file)
@@ -260,6 +260,7 @@ 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
@@ -430,7 +431,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
@@ -808,7 +815,8 @@ VirtioBlkInit (
   }\r
 \r
   Features &= VIRTIO_BLK_F_BLK_SIZE | VIRTIO_BLK_F_TOPOLOGY | VIRTIO_BLK_F_RO |\r
-              VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1;\r
+              VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1 |\r
+              VIRTIO_F_IOMMU_PLATFORM;\r
 \r
   //\r
   // In virtio-1.0, feature negotiation is expected to complete before queue\r
@@ -886,7 +894,7 @@ VirtioBlkInit (
   // step 5 -- Report understood features.\r
   //\r
   if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) {\r
-    Features &= ~(UINT64)VIRTIO_F_VERSION_1;\r
+    Features &= ~(UINT64)(VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM);\r
     Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);\r
     if (EFI_ERROR (Status)) {\r
       goto UnmapQueue;\r
@@ -1011,6 +1019,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
@@ -1020,12 +1029,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