diff options
author | Andre Przywara <andre.przywara@arm.com> | 2017-04-25 15:39:29 +0100 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2017-06-09 11:16:47 +0100 |
commit | 714ab9e66030b225158a9cd121d740ca0dfaa0ba (patch) | |
tree | cd6224e4feba2d9b0b612bbb2ce2666a1eae5d01 | |
parent | 663165a2862dca03581f76db07bdbc3a8f19fbc4 (diff) | |
download | kvmtool-714ab9e66030b225158a9cd121d740ca0dfaa0ba.tar.gz |
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: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | arm/gic.c | 3 | ||||
-rw-r--r-- | include/kvm/kvm.h | 1 | ||||
-rw-r--r-- | virtio/pci.c | 8 |
3 files changed, 11 insertions, 1 deletions
@@ -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) diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index a76a25d2..90463b8c 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -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; diff --git a/virtio/pci.c b/virtio/pci.c index 04176c1d..f0e884c1 100644 --- a/virtio/pci.c +++ b/virtio/pci.c @@ -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); } |