mirror of https://github.com/acidanthera/audk.git
OvmfPkg: VirtioRngDxe: adapt feature negotiation to virtio-1.0
Relative to virtio-0.9.5, virtio-1.0 reverses the order of queue discovery and feature negotiation. In virtio-1.0, feature negotiation has to complete first, and the device can also reject a self-inconsistent feature request through the new VSTAT_FEATURES_OK status bit. (For example if the driver requests a higher level feature but clears a prerequisite feature.) Furthermore, we retain the VIRTIO_F_VERSION_1 feature bit if the VIRTIO_DEVICE_PROTOCOL provider has high enough revision. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
parent
33c6b934bf
commit
0a781bdc7f
|
@ -242,6 +242,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
|
||||
//
|
||||
|
@ -290,15 +303,15 @@ VirtioRngInit (
|
|||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// step 6 -- initialization complete
|
||||
|
|
Loading…
Reference in New Issue