Commit 714ab9e6 authored by Andre Przywara's avatar Andre Przywara Committed by Will Deacon
Browse files

PCI: inject PCI device ID on MSI injection



The ITS emulation requires a unique device ID to be passed along the
MSI payload when kvmtool wants to trigger an MSI in the guest.
According to the proposed changes to the interface add the PCI
bus/device/function triple to the structure passed with the ioctl.
Check the respective capability before actually adding the device ID
to the kvm_msi struct.

Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 663165a2
......@@ -245,6 +245,9 @@ static int gic__init_gic(struct kvm *kvm)
return ret;
}
kvm->msix_needs_devid = kvm__supports_vm_extension(kvm,
KVM_CAP_MSI_DEVID);
return 0;
}
late_init(gic__init_gic)
......
......@@ -63,6 +63,7 @@ struct kvm {
struct list_head mem_banks;
bool nmi_disabled;
bool msix_needs_devid;
const char *vmlinux;
struct disk_image **disks;
......
......@@ -334,7 +334,8 @@ static void virtio_pci__msix_mmio_callback(struct kvm_cpu *vcpu,
update_msix_map(vpci, table, vecnum);
}
static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci, int vec)
static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci,
int vec)
{
struct kvm_msi msi = {
.address_lo = vpci->msix_table[vec].msg.address_lo,
......@@ -342,6 +343,11 @@ static void virtio_pci__signal_msi(struct kvm *kvm, struct virtio_pci *vpci, int
.data = vpci->msix_table[vec].msg.data,
};
if (kvm->msix_needs_devid) {
msi.flags = KVM_MSI_VALID_DEVID;
msi.devid = vpci->dev_hdr.dev_num << 3;
}
ioctl(kvm->vm_fd, KVM_SIGNAL_MSI, &msi);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment