diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-08-27 21:44:56 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-08-30 01:05:49 +0000 |
commit | 537a724421393191f8a47eae6653b071e970016e (patch) | |
tree | e9f206ddd223db1eb83fc2923da7aa480bf56e86 /OvmfPkg | |
parent | 212a2b9bb82738f9b87fdb13b96823ab57fc7ad9 (diff) | |
download | edk2-537a724421393191f8a47eae6653b071e970016e.zip edk2-537a724421393191f8a47eae6653b071e970016e.tar.gz edk2-537a724421393191f8a47eae6653b071e970016e.tar.bz2 |
OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetQueueAddress
Virtio 1.0 allows a more flexible virtio ring layout, so we have to set
addresses for descriptors avail flags and use flags separately. We
continue to use a ring layout compatible with virtio 0.9.5 though, so no
other changes are needed to setup the virtio queues.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c index 50a4fd2..cb1f935 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c @@ -183,13 +183,36 @@ VirtioMmioSetQueueAddress ( )
{
VIRTIO_MMIO_DEVICE *Device;
+ UINT64 Address;
ASSERT (RingBaseShift == 0);
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
- (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
+ if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
+ (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
+ } else {
+ Address = (UINTN)Ring->Base;
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
+ (UINT32)Address);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_HI,
+ (UINT32)RShiftU64(Address, 32));
+
+ Address = (UINTN)Ring->Avail.Flags;
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_LO,
+ (UINT32)Address);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_AVAIL_HI,
+ (UINT32)RShiftU64(Address, 32));
+
+ Address = (UINTN)Ring->Used.Flags;
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_USED_LO,
+ (UINT32)Address);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_USED_HI,
+ (UINT32)RShiftU64(Address, 32));
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_READY, 1);
+ }
return EFI_SUCCESS;
}
|