From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
Alexander Graf <agraf@suse.de>,
Alex Williamson <alex.williamson@redhat.com>,
qemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 2/3] KVM: add kvm_arch_irqchip_add_msi_route
Date: Fri, 21 Jun 2013 19:22:54 +1000 [thread overview]
Message-ID: <1371806575-19347-3-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1371806575-19347-1-git-send-email-aik@ozlabs.ru>
At the moment kvm_irqchip_add_msi_route() adds routing entries for every
MSI IRQ we want to use with IRQFD.
However on PPC64-pSeries no routing is required as QEMU is already doing
MSIMessage to IRQ converson. When the guest needs to allocate some
MSI vectors, it asks a hypervisor (QEMU) which returns IRQs and does all
the MSIMessage allocation/initialization in QEMU.
The patch adds callbacks to let a specific platform define how exactly
the routing is configured.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
include/sysemu/kvm.h | 1 +
kvm-all.c | 5 +++++
target-arm/kvm.c | 6 ++++++
target-i386/kvm.c | 6 ++++++
target-ppc/kvm.c | 10 ++++++++++
target-s390x/kvm.c | 6 ++++++
6 files changed, 34 insertions(+)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 8b19322..9d5459d 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -215,6 +215,7 @@ int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
int kvm_arch_on_sigbus(int code, void *addr);
void kvm_arch_init_irq_routing(KVMState *s);
+int kvm_arch_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
int kvm_set_irq(KVMState *s, int irq, int level);
int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg);
diff --git a/kvm-all.c b/kvm-all.c
index 91aa7ff..a92cc04 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1187,6 +1187,11 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
struct kvm_irq_routing_entry kroute;
int virq;
+ virq = kvm_arch_irqchip_add_msi_route(s, msg);
+ if (virq >= 0) {
+ return virq;
+ }
+
if (!kvm_gsi_routing_enabled()) {
return -ENOSYS;
}
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 7a90d38..1a9bec1 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -22,6 +22,7 @@
#include "kvm_arm.h"
#include "cpu.h"
#include "hw/arm/arm.h"
+#include "hw/pci/msi.h"
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_LAST_INFO
@@ -497,3 +498,8 @@ void kvm_arch_remove_all_hw_breakpoints(void)
void kvm_arch_init_irq_routing(KVMState *s)
{
}
+
+int kvm_arch_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
+{
+ return -1;
+}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 7ba98cd..96bb85c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -33,6 +33,7 @@
#include "exec/ioport.h"
#include "hyperv.h"
#include "hw/pci/pci.h"
+#include "hw/pci/msi.h"
//#define DEBUG_KVM
@@ -2207,6 +2208,11 @@ void kvm_arch_init_irq_routing(KVMState *s)
kvm_gsi_routing_allowed = true;
}
+int kvm_arch_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
+{
+ return -1;
+}
+
/* Classic KVM device assignment interface. Will remain x86 only. */
int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr,
uint32_t flags, uint32_t *dev_id)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index b60b684..d6da146 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -35,6 +35,7 @@
#include "hw/sysbus.h"
#include "hw/ppc/spapr.h"
#include "hw/ppc/spapr_vio.h"
+#include "hw/pci/msi.h"
#include "sysemu/watchdog.h"
//#define DEBUG_KVM
@@ -1973,3 +1974,12 @@ int kvm_arch_on_sigbus(int code, void *addr)
void kvm_arch_init_irq_routing(KVMState *s)
{
}
+
+int kvm_arch_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
+{
+ if (!kvm_msi_via_irqfd_allowed)
+ return -1;
+
+ msg.address -= spapr->msi_win_addr;
+ return (msg.address >> 2) + msg.data;
+}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 4d9ac4a..4fa7a3d 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -36,6 +36,7 @@
#include "sysemu/device_tree.h"
#include "qapi/qmp/qjson.h"
#include "monitor/monitor.h"
+#include "hw/pci/msi.h"
/* #define DEBUG_KVM */
@@ -932,3 +933,8 @@ void kvm_s390_enable_css_support(S390CPU *cpu)
void kvm_arch_init_irq_routing(KVMState *s)
{
}
+
+int kvm_arch_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
+{
+ return -1;
+}
--
1.7.10.4
next prev parent reply other threads:[~2013-06-21 9:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 9:22 [Qemu-devel] [PATCH 0/3] RFCv2 kvm irqfd: add directly mapped MSI IRQ support Alexey Kardashevskiy
2013-06-21 9:22 ` [Qemu-devel] [PATCH 1/3] spapr pci msi: rework Alexey Kardashevskiy
2013-06-21 10:31 ` Alexander Graf
2013-06-21 10:52 ` Alexey Kardashevskiy
2013-06-21 11:58 ` Anthony Liguori
2013-06-21 11:59 ` Alexander Graf
2013-06-21 12:09 ` Benjamin Herrenschmidt
2013-06-21 12:02 ` Benjamin Herrenschmidt
2013-06-21 9:22 ` Alexey Kardashevskiy [this message]
2013-06-21 10:33 ` [Qemu-devel] [PATCH 2/3] KVM: add kvm_arch_irqchip_add_msi_route Alexander Graf
2013-06-21 12:03 ` Benjamin Herrenschmidt
2013-06-21 12:05 ` Alexander Graf
2013-06-21 12:10 ` Benjamin Herrenschmidt
2013-06-21 13:46 ` Alexander Graf
2013-06-21 21:54 ` Benjamin Herrenschmidt
2013-06-21 22:12 ` Alexander Graf
2013-06-21 22:21 ` Benjamin Herrenschmidt
2013-06-21 23:10 ` Alex Williamson
2013-06-21 23:19 ` Benjamin Herrenschmidt
2013-06-21 9:22 ` [Qemu-devel] [PATCH 3/3] KVM: PPC: enable irqfd Alexey Kardashevskiy
2013-06-21 17:52 ` Scott Wood
2013-06-22 1:12 ` Alexey Kardashevskiy
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=1371806575-19347-3-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).