Skip to content

Commit a834f9d

Browse files
committed
Accept VIRTIO_F_VERSION_1 if offered
Currently, when we initialize a device, we do not conform to section 6.1 of the VIRTIO spec. It says: > 6.1 Driver Requirements: Reserved Feature Bits > A driver MUST accept VIRTIO_F_VERSION_1 if it is offered. To fix conformance, check for presence of the VIRTIO_F_VERSION_1 and accept it if it's offered, always. Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
1 parent 3fc66fa commit a834f9d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/transport/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,22 @@ pub trait Transport {
8080
&mut self,
8181
supported_features: F,
8282
) -> F {
83+
use crate::device::common::Feature;
84+
8385
self.set_status(DeviceStatus::empty());
8486
self.set_status(DeviceStatus::ACKNOWLEDGE | DeviceStatus::DRIVER);
8587

86-
let device_features = F::from_bits_truncate(self.read_device_features());
88+
let device_feature_bits = self.read_device_features();
89+
let device_features = F::from_bits_truncate(device_feature_bits);
8790
debug!("Device features: {:?}", device_features);
8891
let negotiated_features = device_features & supported_features;
89-
self.write_driver_features(negotiated_features.bits());
92+
if device_feature_bits & Feature::VERSION_1.bits() > 0 {
93+
// > 6.1 Driver Requirements: Reserved Feature Bits
94+
// > A driver MUST accept VIRTIO_F_VERSION_1 if it is offered.
95+
self.write_driver_features(negotiated_features.bits() | Feature::VERSION_1.bits());
96+
} else {
97+
self.write_driver_features(negotiated_features.bits());
98+
}
9099

91100
self.set_status(
92101
DeviceStatus::ACKNOWLEDGE | DeviceStatus::DRIVER | DeviceStatus::FEATURES_OK,

0 commit comments

Comments
 (0)