diff options
author | Laszlo Ersek <lersek@redhat.com> | 2016-03-12 14:41:26 +0100 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2016-04-06 19:21:50 +0200 |
commit | 33c6b934bf973bd3e0f72805ad723558cfffaa7f (patch) | |
tree | 0f0c789c5228b8e66a0abb2020b7822745f005d0 /OvmfPkg/VirtioNetDxe | |
parent | cbad8e4cccf61c91932e7f091f9144448871c968 (diff) | |
download | edk2-33c6b934bf973bd3e0f72805ad723558cfffaa7f.tar.gz edk2-33c6b934bf973bd3e0f72805ad723558cfffaa7f.tar.bz2 edk2-33c6b934bf973bd3e0f72805ad723558cfffaa7f.zip |
OvmfPkg: VirtioNetDxe: 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>
Diffstat (limited to 'OvmfPkg/VirtioNetDxe')
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpInitialize.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/SnpInitialize.c index f06b0a5a57..38012a0df8 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -417,6 +417,19 @@ VirtioNetInitialize ( ASSERT (Dev->Snm.MediaPresentSupported ==
!!(Features & VIRTIO_NET_F_STATUS));
+ Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | 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 DeviceFailed;
+ }
+ }
+
//
// step 4b, 4c -- allocate and report virtqueues
//
@@ -433,10 +446,12 @@ VirtioNetInitialize ( //
// step 5 -- keep only the features we want
//
- Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS;
- Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
- if (EFI_ERROR (Status)) {
- goto ReleaseTxRing;
+ 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 ReleaseTxRing;
+ }
}
//
|