From bc8fde6f62fd038e709b4981babda0f7c7ba8418 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Sat, 12 Mar 2016 00:58:12 +0100 Subject: OvmfPkg: VIRTIO_DEVICE_PROTOCOL: widen the Features bitmap to 64 bits The virtio-1.0 spec widens the Features bitmap to 64 bits. Modify the declarations of the GetDeviceFeatures() and SetGuestFeatures() protocol member functions accordingly. Normally, a protocol cannot be changed in incompatible ways if the GUID stays the same; however, we've always been extremely clear that VIRTIO_DEVICE_PROTOCOL is internal to edk2. See for example the top of "OvmfPkg/Include/Protocol/VirtioDevice.h". In this patch, all producers and consumers of the GetDeviceFeatures() and SetGuestFeatures() protocol members are updated. The drivers that currently produce these members are "legacy" drivers (in virtio-1.0 terminology), and they cannot (and will not) handle feature bits above BIT31. Therefore their conversion is only for compatibility with the modified protocol interface. The consumers will be responsible for checking the VIRTIO_DEVICE_PROTOCOL.Revision field, and for not passing feature bits that these backends cannot handle. The VirtioMmioGetDeviceFeatures() implementation stores the result of an MmioRead32() call with normal assignment, so it needs no change beyond adapting its prototype. Cc: Ard Biesheuvel Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Tested-by: Ard Biesheuvel Reviewed-by: Jordan Justen --- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h | 4 ++-- OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'OvmfPkg/VirtioPciDeviceDxe') diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h index 6311ae849d..812061dc0c 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h @@ -83,7 +83,7 @@ EFI_STATUS EFIAPI VirtioPciGetDeviceFeatures ( IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT32 *DeviceFeatures + OUT UINT64 *DeviceFeatures ); EFI_STATUS @@ -125,7 +125,7 @@ EFI_STATUS EFIAPI VirtioPciSetGuestFeatures ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT32 Features + IN UINT64 Features ); EFI_STATUS diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c index 9c40fd94a6..d8d30f9af6 100644 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c +++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c @@ -101,10 +101,12 @@ EFI_STATUS EFIAPI VirtioPciGetDeviceFeatures ( IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT32 *DeviceFeatures + OUT UINT64 *DeviceFeatures ) { VIRTIO_PCI_DEVICE *Dev; + EFI_STATUS Status; + UINT32 Features32; if (DeviceFeatures == NULL) { return EFI_INVALID_PARAMETER; @@ -112,8 +114,12 @@ VirtioPciGetDeviceFeatures ( Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES, sizeof (UINT32), - sizeof (UINT32), DeviceFeatures); + Status = VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES, + sizeof (UINT32), sizeof (UINT32), &Features32); + if (!EFI_ERROR (Status)) { + *DeviceFeatures = Features32; + } + return Status; } EFI_STATUS @@ -177,13 +183,16 @@ EFI_STATUS EFIAPI VirtioPciSetGuestFeatures ( IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT32 Features + IN UINT64 Features ) { VIRTIO_PCI_DEVICE *Dev; Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); + if (Features > MAX_UINT32) { + return EFI_UNSUPPORTED; + } return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_GUEST_FEATURES, sizeof (UINT32), Features); } -- cgit v1.2.3