Skip to content

Commit 13b47b2

Browse files
Konstantin Shkolnyyjfvogel
authored andcommitted
vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines
[ Upstream commit 439252e167ac45a5d46f573aac1da7d8f3e051ad ] mlx5_vdpa_dev_add() doesn’t initialize mvdev->actual_features. It’s initialized later by mlx5_vdpa_set_driver_features(). However, mlx5_vdpa_get_config() depends on the VIRTIO_F_VERSION_1 flag in actual_features, to return data with correct endianness. When it’s called before mlx5_vdpa_set_driver_features(), the data are incorrectly returned as big-endian on big-endian machines, while QEMU then interprets them as little-endian. The fix is to initialize this VIRTIO_F_VERSION_1 as early as possible, especially considering that mlx5_vdpa_dev_add() insists on this flag to always be set anyway. Signed-off-by: Konstantin Shkolnyy <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Dragos Tatulea <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 0d508cefcd24a3ac1b934313d647ebd68bf9b946) Signed-off-by: Jack Vogel <[email protected]>
1 parent f5869d6 commit 13b47b2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,6 +3884,9 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
38843884
ndev->mvdev.max_vqs = max_vqs;
38853885
mvdev = &ndev->mvdev;
38863886
mvdev->mdev = mdev;
3887+
/* cpu_to_mlx5vdpa16() below depends on this flag */
3888+
mvdev->actual_features =
3889+
(device_features & BIT_ULL(VIRTIO_F_VERSION_1));
38873890

38883891
ndev->vqs = kcalloc(max_vqs, sizeof(*ndev->vqs), GFP_KERNEL);
38893892
ndev->event_cbs = kcalloc(max_vqs + 1, sizeof(*ndev->event_cbs), GFP_KERNEL);

0 commit comments

Comments
 (0)