]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
OvmfPkg: VIRTIO_DEVICE_PROTOCOL: widen the Features bitmap to 64 bits
[mirror_edk2.git] / OvmfPkg / VirtioPciDeviceDxe / VirtioPciFunctions.c
index 9c40fd94a6e8ef802c27649100a1b9dada5d6acf..d8d30f9af63d6d7638928020c0e02bae462d320a 100644 (file)
@@ -101,10 +101,12 @@ EFI_STATUS
 EFIAPI\r
 VirtioPciGetDeviceFeatures (\r
   IN VIRTIO_DEVICE_PROTOCOL *This,\r
-  OUT UINT32                *DeviceFeatures\r
+  OUT UINT64                *DeviceFeatures\r
   )\r
 {\r
   VIRTIO_PCI_DEVICE         *Dev;\r
+  EFI_STATUS                Status;\r
+  UINT32                    Features32;\r
 \r
   if (DeviceFeatures == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -112,8 +114,12 @@ VirtioPciGetDeviceFeatures (
 \r
   Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);\r
 \r
-  return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES, sizeof (UINT32),\r
-      sizeof (UINT32), DeviceFeatures);\r
+  Status = VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES,\r
+             sizeof (UINT32), sizeof (UINT32), &Features32);\r
+  if (!EFI_ERROR (Status)) {\r
+    *DeviceFeatures = Features32;\r
+  }\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -177,13 +183,16 @@ EFI_STATUS
 EFIAPI\r
 VirtioPciSetGuestFeatures (\r
   IN VIRTIO_DEVICE_PROTOCOL  *This,\r
-  IN UINT32                   Features\r
+  IN UINT64                   Features\r
   )\r
 {\r
   VIRTIO_PCI_DEVICE *Dev;\r
 \r
   Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);\r
 \r
+  if (Features > MAX_UINT32) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
   return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_GUEST_FEATURES,\r
       sizeof (UINT32), Features);\r
 }\r