diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-08-27 21:44:58 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-08-30 01:05:49 +0000 |
commit | ae12188cf87bd4a5ee0ad06c5a6be5083c9c10c3 (patch) | |
tree | af3674e869c41c3c96ef31ec52ac451612847d79 | |
parent | 6a3e9576b835a766b558864d798f71b0d61136f6 (diff) | |
download | edk2-ae12188cf87bd4a5ee0ad06c5a6be5083c9c10c3.tar.gz edk2-ae12188cf87bd4a5ee0ad06c5a6be5083c9c10c3.tar.bz2 edk2-ae12188cf87bd4a5ee0ad06c5a6be5083c9c10c3.zip |
OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Adapt feature bit handling
virtio 1.0 has 64 feature bits instead of 32.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
-rw-r--r-- | OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c index 436da2a2b4..b43850e69d 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c @@ -20,6 +20,7 @@ VirtioMmioGetDeviceFeatures ( )
{
VIRTIO_MMIO_DEVICE *Device;
+ UINT32 LowBits, HighBits;
if (DeviceFeatures == NULL) {
return EFI_INVALID_PARAMETER;
@@ -27,7 +28,15 @@ VirtioMmioGetDeviceFeatures ( Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
- *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+ *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ } else {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL, 0);
+ LowBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL, 1);
+ HighBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ *DeviceFeatures = LShiftU64(HighBits, 32) | LowBits;
+ }
return EFI_SUCCESS;
}
@@ -238,11 +247,20 @@ VirtioMmioSetGuestFeatures ( Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
- if (Features > MAX_UINT32) {
- return EFI_UNSUPPORTED;
+ if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+ if (Features > MAX_UINT32) {
+ return EFI_UNSUPPORTED;
+ }
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)Features);
+ } else {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL, 0);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)Features);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL, 1);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)RShiftU64(Features, 32));
}
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
- (UINT32)Features);
return EFI_SUCCESS;
}
|