virtio-pci: Fix legacy device flag setting error in probe
authorFeng Liu <feliu@nvidia.com>
Wed, 19 Jul 2023 15:45:50 +0000 (11:45 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 10 Aug 2023 19:24:28 +0000 (15:24 -0400)
commit13f3efaca024e16ccfab0e8b2cf29d66489d8d54
tree930f23b9e9d31800cb22047e0d61bf07497f3ce5
parent8d4bdf11f096e5b343ee0f9aaa8c262dc16d2e1e
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: 4f0fc22534e3 ("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>
drivers/virtio/virtio_pci_common.c
drivers/virtio/virtio_pci_legacy.c