[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250505225634.2688578-161-sashal@kernel.org>
Date: Mon, 5 May 2025 18:54:21 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Konstantin Shkolnyy <kshk@...ux.ibm.com>,
"Michael S . Tsirkin" <mst@...hat.com>,
Dragos Tatulea <dtatulea@...dia.com>,
Jason Wang <jasowang@...hat.com>,
Sasha Levin <sashal@...nel.org>,
eperezma@...hat.com,
cratiu@...dia.com,
tariqt@...dia.com,
virtualization@...ts.linux.dev
Subject: [PATCH AUTOSEL 6.6 161/294] vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines
From: Konstantin Shkolnyy <kshk@...ux.ibm.com>
[ 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 <kshk@...ux.ibm.com>
Message-Id: <20250204173127.166673-1-kshk@...ux.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
Reviewed-by: Dragos Tatulea <dtatulea@...dia.com>
Acked-by: Jason Wang <jasowang@...hat.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index b56aae3f7be37..9b8b70ffde5a0 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -3420,6 +3420,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);
--
2.39.5
Powered by blists - more mailing lists