mirror of
https://github.com/torvalds/linux.git
synced 2025-04-09 14:45:27 +00:00
vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines
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 <kshk@linux.ibm.com> Message-Id: <20250204173127.166673-1-kshk@linux.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Acked-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
5dd639a164
commit
439252e167
@ -3884,6 +3884,9 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
|
||||
ndev->mvdev.max_vqs = max_vqs;
|
||||
mvdev = &ndev->mvdev;
|
||||
mvdev->mdev = mdev;
|
||||
/* cpu_to_mlx5vdpa16() below depends on this flag */
|
||||
mvdev->actual_features =
|
||||
(device_features & BIT_ULL(VIRTIO_F_VERSION_1));
|
||||
|
||||
ndev->vqs = kcalloc(max_vqs, sizeof(*ndev->vqs), GFP_KERNEL);
|
||||
ndev->event_cbs = kcalloc(max_vqs + 1, sizeof(*ndev->event_cbs), GFP_KERNEL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user