From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Pavel Fedin <p.fedin@samsung.com>
Subject: [Qemu-devel] [PULL 47/49] kvm: Pass PCI device pointer to MSI routing functions
Date: Fri, 16 Oct 2015 10:50:09 +0200 [thread overview]
Message-ID: <1444985411-17803-48-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1444985411-17803-1-git-send-email-pbonzini@redhat.com>
From: Pavel Fedin <p.fedin@samsung.com>
In-kernel ITS emulation on ARM64 will require to supply requester IDs.
These IDs can now be retrieved from the device pointer using new
pci_requester_id() function.
This patch adds pci_dev pointer to KVM GSI routing functions and makes
callers passing it.
x86 architecture does not use requester IDs, but hw/i386/kvm/pci-assign.c
also made passing PCI device pointer instead of NULL for consistency with
the rest of the code.
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Message-Id: <ce081423ba2394a4efc30f30708fca07656bc500.1444916432.git.p.fedin@samsung.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/kvm/pci-assign.c | 9 +++++----
hw/vfio/pci.c | 11 ++++++-----
hw/virtio/virtio-pci.c | 5 +++--
include/sysemu/kvm.h | 7 ++++---
kvm-all.c | 9 +++++----
kvm-stub.c | 5 +++--
target-arm/kvm.c | 2 +-
target-i386/kvm.c | 2 +-
target-mips/kvm.c | 2 +-
target-ppc/kvm.c | 2 +-
target-s390x/kvm.c | 2 +-
11 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index e48cae6..0fd6923 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -979,7 +979,7 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
MSIMessage msg = msi_get_message(pci_dev, 0);
int virq;
- virq = kvm_irqchip_add_msi_route(kvm_state, msg);
+ virq = kvm_irqchip_add_msi_route(kvm_state, msg, pci_dev);
if (virq < 0) {
perror("assigned_dev_update_msi: kvm_irqchip_add_msi_route");
return;
@@ -1017,7 +1017,7 @@ static void assigned_dev_update_msi_msg(PCIDevice *pci_dev)
}
kvm_irqchip_update_msi_route(kvm_state, assigned_dev->msi_virq[0],
- msi_get_message(pci_dev, 0));
+ msi_get_message(pci_dev, 0), pci_dev);
}
static bool assigned_dev_msix_masked(MSIXTableEntry *entry)
@@ -1083,7 +1083,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
msg.address = entry->addr_lo | ((uint64_t)entry->addr_hi << 32);
msg.data = entry->data;
- r = kvm_irqchip_add_msi_route(kvm_state, msg);
+ r = kvm_irqchip_add_msi_route(kvm_state, msg, pci_dev);
if (r < 0) {
return r;
}
@@ -1602,7 +1602,8 @@ static void assigned_dev_msix_mmio_write(void *opaque, hwaddr addr,
msg.data = entry->data;
ret = kvm_irqchip_update_msi_route(kvm_state,
- adev->msi_virq[i], msg);
+ adev->msi_virq[i], msg,
+ pdev);
if (ret) {
error_report("Error updating irq routing entry (%d)", ret);
}
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index dcabb6d..8fadbcf 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -424,7 +424,7 @@ static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector,
return;
}
- virq = kvm_irqchip_add_msi_route(kvm_state, *msg);
+ virq = kvm_irqchip_add_msi_route(kvm_state, *msg, &vdev->pdev);
if (virq < 0) {
event_notifier_cleanup(&vector->kvm_interrupt);
return;
@@ -449,9 +449,10 @@ static void vfio_remove_kvm_msi_virq(VFIOMSIVector *vector)
event_notifier_cleanup(&vector->kvm_interrupt);
}
-static void vfio_update_kvm_msi_virq(VFIOMSIVector *vector, MSIMessage msg)
+static void vfio_update_kvm_msi_virq(VFIOMSIVector *vector, MSIMessage msg,
+ PCIDevice *pdev)
{
- kvm_irqchip_update_msi_route(kvm_state, vector->virq, msg);
+ kvm_irqchip_update_msi_route(kvm_state, vector->virq, msg, pdev);
}
static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
@@ -486,7 +487,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
if (!msg) {
vfio_remove_kvm_msi_virq(vector);
} else {
- vfio_update_kvm_msi_virq(vector, *msg);
+ vfio_update_kvm_msi_virq(vector, *msg, pdev);
}
} else {
vfio_add_kvm_msi_virq(vdev, vector, msg, true);
@@ -760,7 +761,7 @@ static void vfio_update_msi(VFIOPCIDevice *vdev)
}
msg = msi_get_message(&vdev->pdev, i);
- vfio_update_kvm_msi_virq(vector, msg);
+ vfio_update_kvm_msi_virq(vector, msg, &vdev->pdev);
}
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index e5c406d..f55dd2b 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -590,7 +590,7 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
int ret;
if (irqfd->users == 0) {
- ret = kvm_irqchip_add_msi_route(kvm_state, msg);
+ ret = kvm_irqchip_add_msi_route(kvm_state, msg, &proxy->pci_dev);
if (ret < 0) {
return ret;
}
@@ -726,7 +726,8 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
if (proxy->vector_irqfd) {
irqfd = &proxy->vector_irqfd[vector];
if (irqfd->msg.data != msg.data || irqfd->msg.address != msg.address) {
- ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg);
+ ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg,
+ &proxy->pci_dev);
if (ret < 0) {
return ret;
}
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 5fb22d2..24657d8 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -326,7 +326,7 @@ int kvm_arch_on_sigbus(int code, void *addr);
void kvm_arch_init_irq_routing(KVMState *s);
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
- uint64_t address, uint32_t data);
+ uint64_t address, uint32_t data, PCIDevice *dev);
int kvm_arch_msi_data_to_gsi(uint32_t data);
@@ -451,8 +451,9 @@ static inline void cpu_clean_state(CPUState *cpu)
}
}
-int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
-int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg);
+int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg, PCIDevice *dev);
+int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
+ PCIDevice *dev);
void kvm_irqchip_release_virq(KVMState *s, int virq);
int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter);
diff --git a/kvm-all.c b/kvm-all.c
index 5519c02..ab50a16 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1189,7 +1189,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
return kvm_set_irq(s, route->kroute.gsi, 1);
}
-int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
+int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg, PCIDevice *dev)
{
struct kvm_irq_routing_entry kroute = {};
int virq;
@@ -1213,7 +1213,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
- if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data)) {
+ if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) {
kvm_irqchip_release_virq(s, virq);
return -EINVAL;
}
@@ -1224,7 +1224,8 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
return virq;
}
-int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
+int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
+ PCIDevice *dev)
{
struct kvm_irq_routing_entry kroute = {};
@@ -1242,7 +1243,7 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
kroute.u.msi.address_lo = (uint32_t)msg.address;
kroute.u.msi.address_hi = msg.address >> 32;
kroute.u.msi.data = le32_to_cpu(msg.data);
- if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data)) {
+ if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) {
return -EINVAL;
}
diff --git a/kvm-stub.c b/kvm-stub.c
index d9ad624..08bcc32 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -115,7 +115,7 @@ int kvm_on_sigbus(int code, void *addr)
}
#ifndef CONFIG_USER_ONLY
-int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
+int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg, PCIDevice *dev)
{
return -ENOSYS;
}
@@ -128,7 +128,8 @@ void kvm_irqchip_release_virq(KVMState *s, int virq)
{
}
-int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
+int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
+ PCIDevice *dev)
{
return -ENOSYS;
}
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 6aadcd8..79ef4c6 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -605,7 +605,7 @@ int kvm_arm_vgic_probe(void)
}
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
- uint64_t address, uint32_t data)
+ uint64_t address, uint32_t data, PCIDevice *dev)
{
return 0;
}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 65cd944..ee5bef9 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -2992,7 +2992,7 @@ int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id)
}
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
- uint64_t address, uint32_t data)
+ uint64_t address, uint32_t data, PCIDevice *dev)
{
return 0;
}
diff --git a/target-mips/kvm.c b/target-mips/kvm.c
index d287d42..12d7db3 100644
--- a/target-mips/kvm.c
+++ b/target-mips/kvm.c
@@ -678,7 +678,7 @@ int kvm_arch_get_registers(CPUState *cs)
}
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
- uint64_t address, uint32_t data)
+ uint64_t address, uint32_t data, PCIDevice *dev)
{
return 0;
}
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 7276299..38aa927 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -2483,7 +2483,7 @@ error_out:
}
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
- uint64_t address, uint32_t data)
+ uint64_t address, uint32_t data, PCIDevice *dev)
{
return 0;
}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 5fdee1b..0305ffa 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -2208,7 +2208,7 @@ int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
}
int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
- uint64_t address, uint32_t data)
+ uint64_t address, uint32_t data, PCIDevice *dev)
{
S390PCIBusDevice *pbdev;
uint32_t fid = data >> ZPCI_MSI_VEC_BITS;
--
2.5.0
next prev parent reply other threads:[~2015-10-16 8:51 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 8:49 [Qemu-devel] [PULL 00/49] Misc patches for 2015-10-16 Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 01/49] nbd: switch from g_slice allocator to malloc Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 02/49] scsi: " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 03/49] megasas: fix megasas_get_sata_addr Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 04/49] configure: Require Python 2.6 Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 05/49] exec.c: Don't call cpu_reload_memory_map() from cpu_exec_init() Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 06/49] cpu-exec-common.c: Clarify comment about cpu_reload_memory_map()'s RCU operations Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 07/49] exec.c: Collect AddressSpace related fields into a CPUAddressSpace struct Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 08/49] checkpatch: allow open braces on typedef lines Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 09/49] linux-headers: update from kvm/next Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 10/49] target-i386/kvm: Hyper-V HV_X64_MSR_RESET support Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 11/49] target-i386/kvm: set Hyper-V features cpuid bit HV_X64_MSR_VP_INDEX_AVAILABLE Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 12/49] target-i386/kvm: Hyper-V HV_X64_MSR_VP_RUNTIME support Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 13/49] exec: remove non-TCG stuff from exec-all.h header Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 14/49] kvm-all: Align to qemu_real_host_page_size in kvm_set_phys_mem Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 15/49] checkpatch: port fix from kernel "## is not a valid modifier" Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 16/49] MAINTAINERS: add two devices to the e500 section Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 18/49] MAINTAINERS: Add more pxa2xx files and boards Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 19/49] MAINTAINERS: Add maintainer for ARM PrimeCell and integrated devices Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 20/49] MAINTAINERS: Add more devices to realview board Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 21/49] qemu-sockets: fix conversion of ipv4/ipv6 JSON to QemuOpts Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 22/49] README: fill out some useful quickstart information Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 23/49] qemu-char: cleanup qmp_chardev_add Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 24/49] qemu-char: cleanup HAVE_CHARDEV_* Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 25/49] qemu-char: add create to register_char_driver Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 26/49] qemu-char: convert file backend to data-driven creation Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 27/49] qemu-char: convert serial " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 28/49] qemu-char: convert parallel " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 29/49] qemu-char: convert pipe " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 30/49] qemu-char: convert socket " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 31/49] qemu-char: convert UDP " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 32/49] qemu-char: convert pty " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 33/49] qemu-char: convert null " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 34/49] qemu-char: convert mux " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 35/49] qemu-char: convert msmouse " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 36/49] qemu-char: convert braille " Paolo Bonzini
2015-10-16 8:49 ` [Qemu-devel] [PULL 37/49] qemu-char: convert testdev " Paolo Bonzini
2015-10-16 12:23 ` Eric Blake
2015-10-16 8:50 ` [Qemu-devel] [PULL 38/49] qemu-char: convert stdio " Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 39/49] qemu-char: convert console " Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 40/49] qemu-char: convert spice " Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 41/49] qemu-char: convert vc " Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 42/49] qemu-char: convert ringbuf " Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 43/49] qemu-char: cleanup after completed conversion to cd->create Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 44/49] doc/rcu: fix g_free_rcu() usage example Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 45/49] kvm: Make KVM_CAP_SIGNAL_MSI globally available Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 46/49] hw/pci: Introduce pci_requester_id() Paolo Bonzini
2015-10-16 8:50 ` Paolo Bonzini [this message]
2015-10-16 8:50 ` [Qemu-devel] [PULL 48/49] kvm: Move x86-specific functions into target-i386/kvm.c Paolo Bonzini
2015-10-16 8:50 ` [Qemu-devel] [PULL 49/49] kvm: Allow the Hyper-V vendor ID to be specified Paolo Bonzini
2015-10-16 15:26 ` [Qemu-devel] [PULL 00/49] Misc patches for 2015-10-16 Paolo Bonzini
2015-10-18 16:55 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444985411-17803-48-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=p.fedin@samsung.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).