mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-27 00:35:59 +00:00
kvm tools: don't crash on virtio MSI-X reset
Handle VIRTIO_MSI_NO_VECTOR by not trying to use it as a valid vector. We still need to remove the GSI and everything, but this is enough to prevent crashes and keep everything working properly for now. Reported-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
+8
-3
@@ -146,6 +146,8 @@ static bool virtio_pci__specific_io_out(struct kvm *kvm, struct virtio_device *v
|
||||
switch (offset) {
|
||||
case VIRTIO_MSI_CONFIG_VECTOR:
|
||||
vec = vpci->config_vector = ioport__read16(data);
|
||||
if (vec == VIRTIO_MSI_NO_VECTOR)
|
||||
break;
|
||||
|
||||
gsi = irq__add_msix_route(kvm, &vpci->msix_table[vec].msg);
|
||||
|
||||
@@ -154,6 +156,9 @@ static bool virtio_pci__specific_io_out(struct kvm *kvm, struct virtio_device *v
|
||||
case VIRTIO_MSI_QUEUE_VECTOR:
|
||||
vec = vpci->vq_vector[vpci->queue_selector] = ioport__read16(data);
|
||||
|
||||
if (vec == VIRTIO_MSI_NO_VECTOR)
|
||||
break;
|
||||
|
||||
gsi = irq__add_msix_route(kvm, &vpci->msix_table[vec].msg);
|
||||
vpci->gsis[vpci->queue_selector] = gsi;
|
||||
if (vdev->ops->notify_vq_gsi)
|
||||
@@ -253,7 +258,7 @@ int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq)
|
||||
struct virtio_pci *vpci = vdev->virtio;
|
||||
int tbl = vpci->vq_vector[vq];
|
||||
|
||||
if (virtio_pci__msix_enabled(vpci)) {
|
||||
if (virtio_pci__msix_enabled(vpci) && tbl != VIRTIO_MSI_NO_VECTOR) {
|
||||
if (vpci->pci_hdr.msix.ctrl & cpu_to_le16(PCI_MSIX_FLAGS_MASKALL) ||
|
||||
vpci->msix_table[tbl].ctrl & cpu_to_le16(PCI_MSIX_ENTRY_CTRL_MASKBIT)) {
|
||||
|
||||
@@ -277,7 +282,7 @@ int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev)
|
||||
struct virtio_pci *vpci = vdev->virtio;
|
||||
int tbl = vpci->config_vector;
|
||||
|
||||
if (virtio_pci__msix_enabled(vpci)) {
|
||||
if (virtio_pci__msix_enabled(vpci) && tbl != VIRTIO_MSI_NO_VECTOR) {
|
||||
if (vpci->pci_hdr.msix.ctrl & cpu_to_le16(PCI_MSIX_FLAGS_MASKALL) ||
|
||||
vpci->msix_table[tbl].ctrl & cpu_to_le16(PCI_MSIX_ENTRY_CTRL_MASKBIT)) {
|
||||
|
||||
@@ -286,7 +291,7 @@ int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev)
|
||||
}
|
||||
|
||||
if (vpci->features & VIRTIO_PCI_F_SIGNAL_MSI)
|
||||
virtio_pci__signal_msi(kvm, vpci, vpci->config_vector);
|
||||
virtio_pci__signal_msi(kvm, vpci, tbl);
|
||||
else
|
||||
kvm__irq_trigger(kvm, vpci->config_gsi);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user