Skip to content

Commit 13f3efa

Browse files
Feng Liumstsirkin
authored andcommitted
virtio-pci: Fix legacy device flag setting error in probe
The 'is_legacy' flag is used to differentiate between legacy vs modern device. Currently, it is based on the value of vp_dev->ldev.ioaddr. However, due to the shared memory of the union between struct virtio_pci_legacy_device and struct virtio_pci_modern_device, when virtio_pci_modern_probe modifies the content of struct virtio_pci_modern_device, it affects the content of struct virtio_pci_legacy_device, and ldev.ioaddr is no longer zero, causing the 'is_legacy' flag to be set as true. To resolve issue, when legacy device is probed, mark 'is_legacy' as true, when modern device is probed, keep 'is_legacy' as false. Fixes: 4f0fc22 ("virtio_pci: Optimize virtio_pci_device structure size") Signed-off-by: Feng Liu <feliu@nvidia.com> Reviewed-by: Parav Pandit <parav@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Message-Id: <20230719154550.79536-1-feliu@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com>
1 parent 8d4bdf1 commit 13f3efa

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

drivers/virtio/virtio_pci_common.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,6 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
557557

558558
pci_set_master(pci_dev);
559559

560-
vp_dev->is_legacy = vp_dev->ldev.ioaddr ? true : false;
561-
562560
rc = register_virtio_device(&vp_dev->vdev);
563561
reg_dev = vp_dev;
564562
if (rc)

drivers/virtio/virtio_pci_legacy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ int virtio_pci_legacy_probe(struct virtio_pci_device *vp_dev)
223223
vp_dev->config_vector = vp_config_vector;
224224
vp_dev->setup_vq = setup_vq;
225225
vp_dev->del_vq = del_vq;
226+
vp_dev->is_legacy = true;
226227

227228
return 0;
228229
}

0 commit comments

Comments
 (0)