virtio_net: use LE accessors for speed/duplex
authorMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Aug 2020 09:39:36 +0000 (05:39 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Aug 2020 15:08:41 +0000 (11:08 -0400)
Speed and duplex config fields depend on VIRTIO_NET_F_SPEED_DUPLEX
which being 63>31 depends on VIRTIO_F_VERSION_1.

Accordingly, use LE accessors for these fields.

Reported-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/net/virtio_net.c
include/uapi/linux/virtio_net.h

index ba38765dc4905aa9c461fb49e75a47e6440f81ec..0934b1ec53204ba7d4adc0abbf7480b0dbd4c760 100644 (file)
@@ -2264,12 +2264,13 @@ static void virtnet_update_settings(struct virtnet_info *vi)
        if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_SPEED_DUPLEX))
                return;
 
-       speed = virtio_cread32(vi->vdev, offsetof(struct virtio_net_config,
-                                                 speed));
+       virtio_cread_le(vi->vdev, struct virtio_net_config, speed, &speed);
+
        if (ethtool_validate_speed(speed))
                vi->speed = speed;
-       duplex = virtio_cread8(vi->vdev, offsetof(struct virtio_net_config,
-                                                 duplex));
+
+       virtio_cread_le(vi->vdev, struct virtio_net_config, duplex, &duplex);
+
        if (ethtool_validate_duplex(duplex))
                vi->duplex = duplex;
 }
index 27d996f29dd1d5b0a4b0270c17d7f4646ebf35ca..3f55a4215f11b7014b991893f0e796547aae5bde 100644 (file)
@@ -99,7 +99,7 @@ struct virtio_net_config {
         * speed, in units of 1Mb. All values 0 to INT_MAX are legal.
         * Any other value stands for unknown.
         */
-       __virtio32 speed;
+       __le32 speed;
        /*
         * 0x00 - half duplex
         * 0x01 - full duplex