* [PATCH] vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines.
@ 2025-01-30 21:43 Konstantin Shkolnyy
2025-01-31 7:57 ` Dragos Tatulea
0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Shkolnyy @ 2025-01-30 21:43 UTC (permalink / raw)
To: dtatulea
Cc: virtualization, linux-kernel, mjrosato, mst, jasowang,
Konstantin Shkolnyy
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 flag is clear, and the data are
returned as big-endian on big-endian machines, while QEMU interprets them
as little-endian.
Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
---
drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 36099047560d..f9ea240b8145 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -3884,6 +3884,7 @@ 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;
+ mvdev->actual_features = device_features;
ndev->vqs = kcalloc(max_vqs, sizeof(*ndev->vqs), GFP_KERNEL);
ndev->event_cbs = kcalloc(max_vqs + 1, sizeof(*ndev->event_cbs), GFP_KERNEL);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines.
2025-01-30 21:43 [PATCH] vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines Konstantin Shkolnyy
@ 2025-01-31 7:57 ` Dragos Tatulea
0 siblings, 0 replies; 2+ messages in thread
From: Dragos Tatulea @ 2025-01-31 7:57 UTC (permalink / raw)
To: Konstantin Shkolnyy; +Cc: virtualization, linux-kernel, mjrosato, mst, jasowang
On 01/30, Konstantin Shkolnyy wrote:
> 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 flag is clear, and the data are
> returned as big-endian on big-endian machines, while QEMU interprets them
> as little-endian.
>
Good catch! Thank you for the patch.
Could you add the clarification that mlx5_vdpa_dev_add() uses the
endianess helpers (cpu_to_mlx5vdpa16()) which depend on actual_flags
being set properly.
> Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
> ---
> drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 36099047560d..f9ea240b8145 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -3884,6 +3884,7 @@ 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;
> + mvdev->actual_features = device_features;
>
Maybe it is better to be conservative: only pick the VIRTIO_F_VERSION_1
flag out of device_features.
Thanks,
Dragos
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-31 7:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-30 21:43 [PATCH] vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines Konstantin Shkolnyy
2025-01-31 7:57 ` Dragos Tatulea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).