VirtioGpuDxe is now IOMMU-clean; it translates system memory addresses to
bus master device addresses. Negotiate VIRTIO_F_IOMMU_PLATFORM in parallel
with VIRTIO_F_VERSION_1. (Note: the VirtIo GPU device, and this driver,
are virtio-1.0 only (a.k.a. "modern-only").)

Cc: Ard Biesheuvel <[email protected]>
Cc: Brijesh Singh <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Tom Lendacky <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <[email protected]>
---
 OvmfPkg/VirtioGpuDxe/Commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c
index db5bdbca4bee..6e70b1c33f65 100644
--- a/OvmfPkg/VirtioGpuDxe/Commands.c
+++ b/OvmfPkg/VirtioGpuDxe/Commands.c
@@ -39,131 +39,131 @@ EFI_STATUS
 VirtioGpuInit (
   IN OUT VGPU_DEV *VgpuDev
   )
 {
   UINT8      NextDevStat;
   EFI_STATUS Status;
   UINT64     Features;
   UINT16     QueueSize;
   UINT64     RingBaseShift;
 
   //
   // Execute virtio-v1.0-cs04, 3.1.1 Driver Requirements: Device
   // Initialization.
   //
   // 1. Reset the device.
   //
   NextDevStat = 0;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 2. Set the ACKNOWLEDGE status bit [...]
   //
   NextDevStat |= VSTAT_ACK;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 3. Set the DRIVER status bit [...]
   //
   NextDevStat |= VSTAT_DRIVER;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 4. Read device feature bits...
   //
   Status = VgpuDev->VirtIo->GetDeviceFeatures (VgpuDev->VirtIo, &Features);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
   if ((Features & VIRTIO_F_VERSION_1) == 0) {
     Status = EFI_UNSUPPORTED;
     goto Failed;
   }
   //
   // We only want the most basic 2D features.
   //
-  Features &= VIRTIO_F_VERSION_1;
+  Features &= VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM;
 
   //
   // ... and write the subset of feature bits understood by the [...] driver to
   // the device. [...]
   // 5. Set the FEATURES_OK status bit.
   // 6. Re-read device status to ensure the FEATURES_OK bit is still set [...]
   //
   Status = Virtio10WriteFeatures (VgpuDev->VirtIo, Features, &NextDevStat);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // 7. Perform device-specific setup, including discovery of virtqueues for
   // the device [...]
   //
   Status = VgpuDev->VirtIo->SetQueueSel (VgpuDev->VirtIo,
                               VIRTIO_GPU_CONTROL_QUEUE);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
   Status = VgpuDev->VirtIo->GetQueueNumMax (VgpuDev->VirtIo, &QueueSize);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
 
   //
   // We implement each VirtIo GPU command that we use with two descriptors:
   // request, response.
   //
   if (QueueSize < 2) {
     Status = EFI_UNSUPPORTED;
     goto Failed;
   }
 
   //
   // [...] population of virtqueues [...]
   //
   Status = VirtioRingInit (VgpuDev->VirtIo, QueueSize, &VgpuDev->Ring);
   if (EFI_ERROR (Status)) {
     goto Failed;
   }
   //
   // If anything fails from here on, we have to release the ring.
   //
   Status = VirtioRingMap (
              VgpuDev->VirtIo,
              &VgpuDev->Ring,
              &RingBaseShift,
              &VgpuDev->RingMap
              );
   if (EFI_ERROR (Status)) {
     goto ReleaseQueue;
   }
   //
   // If anything fails from here on, we have to unmap the ring.
   //
   Status = VgpuDev->VirtIo->SetQueueAddress (
                               VgpuDev->VirtIo,
                               &VgpuDev->Ring,
                               RingBaseShift
                               );
   if (EFI_ERROR (Status)) {
     goto UnmapQueue;
   }
 
   //
   // 8. Set the DRIVER_OK status bit.
   //
   NextDevStat |= VSTAT_DRIVER_OK;
   Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat);
   if (EFI_ERROR (Status)) {
     goto UnmapQueue;
   }
 
   return EFI_SUCCESS;
-- 
2.14.1.3.gb7cf6e02401b

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to