X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=OvmfPkg%2FVirtioRngDxe%2FVirtioRng.c;h=0abca488e6cdd6614d4443c90c5c80d570bbe554;hp=d916534aac63f3f27d7ea0ac5c59181971e75826;hb=53a4c6047f3ce2ece7bb8db5b9815a1c9227dddb;hpb=28daafe0add87f9857a4881d0d644a4b033f2168
diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/VirtioRng.c
index d916534aac..0abca488e6 100644
--- a/OvmfPkg/VirtioRngDxe/VirtioRng.c
+++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c
@@ -6,6 +6,7 @@
Copyright (C) 2012, Red Hat, Inc.
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc, All rights reserved.
This driver:
@@ -242,6 +243,19 @@ VirtioRngInit (
goto Failed;
}
+ Features &= VIRTIO_F_VERSION_1;
+
+ //
+ // In virtio-1.0, feature negotiation is expected to complete before queue
+ // discovery, and the device can also reject the selected set of features.
+ //
+ if (Dev->VirtIo->Revision >= VIRTIO_SPEC_REVISION (1, 0, 0)) {
+ Status = Virtio10WriteFeatures (Dev->VirtIo, Features, &NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ }
+
//
// step 4b -- allocate request virtqueue, just use #0
//
@@ -262,7 +276,7 @@ VirtioRngInit (
goto Failed;
}
- Status = VirtioRingInit (QueueSize, &Dev->Ring);
+ Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -284,20 +298,20 @@ VirtioRngInit (
//
// step 4c -- Report GPFN (guest-physical frame number) of queue.
//
- Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring);
+ Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring, 0);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
//
- // step 5 -- Report understood features and guest-tuneables. None are
- // currently defined for VirtioRng, and no generic features are needed by
- // this driver.
+ // step 5 -- Report understood features and guest-tuneables.
//
- Features &= 0;
- Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
- if (EFI_ERROR (Status)) {
- goto ReleaseQueue;
+ if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) {
+ Features &= ~(UINT64)VIRTIO_F_VERSION_1;
+ Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
}
//
@@ -318,7 +332,7 @@ VirtioRngInit (
return EFI_SUCCESS;
ReleaseQueue:
- VirtioRingUninit (&Dev->Ring);
+ VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
Failed:
//
@@ -345,7 +359,7 @@ VirtioRngUninit (
// the old comms area.
//
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
- VirtioRingUninit (&Dev->Ring);
+ VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
}
//