virtio: acknowledge all features before access
authorMichael S. Tsirkin <mst@redhat.com>
Fri, 14 Jan 2022 19:58:41 +0000 (14:58 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 14 Jan 2022 23:50:54 +0000 (18:50 -0500)
commit7b0130f69045067c7f63ca7ed02be79c03b088b0
treebdbf587fefcc5674649068ba2a9f40ca08e82fba
parente3c4b211dd305c37a30025753035e93dd67be8e9
virtio: acknowledge all features before access

The feature negotiation was designed in a way that
makes it possible for devices to know which config
fields will be accessed by drivers.

This is broken since commit 404123c2db79 ("virtio: allow drivers to
validate features") with fallout in at least block and net.
We have a partial work-around in commit 2f9a174f918e ("virtio: write
back F_VERSION_1 before validate") which at least lets devices
find out which format should config space have, but this
is a partial fix: guests should not access config space
without acknowledging features since otherwise we'll never
be able to change the config space format.

As a side effect, this also reduces the amount of hypervisor accesses -
we now only acknowledge features once unless we are clearing any
features when validating.

Cc: stable@vger.kernel.org
Fixes: 404123c2db79 ("virtio: allow drivers to validate features")
Fixes: 2f9a174f918e ("virtio: write back F_VERSION_1 before validate")
Cc: "Halil Pasic" <pasic@linux.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio.c