From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 05/19] kvm: x86: Wire up MSI support for in-kernel irqchip
Date: Mon, 21 May 2012 19:37:33 +0300 [thread overview]
Message-ID: <1337618267-16669-6-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1337618267-16669-1-git-send-email-avi@redhat.com>
From: Jan Kiszka <jan.kiszka@siemens.com>
Catch writes to the MSI MMIO region in the KVM APIC and forward them to
the kernel. Provide the kernel support GSI routing, this allows to
enable MSI support also for in-kernel irqchip mode.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
hw/kvm/apic.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/hw/kvm/apic.c b/hw/kvm/apic.c
index ffe7a52..8ba4079 100644
--- a/hw/kvm/apic.c
+++ b/hw/kvm/apic.c
@@ -10,6 +10,7 @@
* See the COPYING file in the top-level directory.
*/
#include "hw/apic_internal.h"
+#include "hw/msi.h"
#include "kvm.h"
static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic,
@@ -145,10 +146,39 @@ static void kvm_apic_external_nmi(APICCommonState *s)
run_on_cpu(s->cpu_env, do_inject_external_nmi, s);
}
+static uint64_t kvm_apic_mem_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
+{
+ return ~(uint64_t)0;
+}
+
+static void kvm_apic_mem_write(void *opaque, target_phys_addr_t addr,
+ uint64_t data, unsigned size)
+{
+ MSIMessage msg = { .address = addr, .data = data };
+ int ret;
+
+ ret = kvm_irqchip_send_msi(kvm_state, msg);
+ if (ret < 0) {
+ fprintf(stderr, "KVM: injection failed, MSI lost (%s)\n",
+ strerror(-ret));
+ }
+}
+
+static const MemoryRegionOps kvm_apic_io_ops = {
+ .read = kvm_apic_mem_read,
+ .write = kvm_apic_mem_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
static void kvm_apic_init(APICCommonState *s)
{
- memory_region_init_reservation(&s->io_memory, "kvm-apic-msi",
- MSI_SPACE_SIZE);
+ memory_region_init_io(&s->io_memory, &kvm_apic_io_ops, s, "kvm-apic-msi",
+ MSI_SPACE_SIZE);
+
+ if (kvm_has_gsi_routing()) {
+ msi_supported = true;
+ }
}
static void kvm_apic_class_init(ObjectClass *klass, void *data)
--
1.7.10.1
next prev parent reply other threads:[~2012-05-21 18:11 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-21 16:37 [Qemu-devel] [PULL 00/20 1.2] kvm updates Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 01/19] kvm: Refactor KVMState::max_gsi to gsi_count Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 02/19] Introduce MSIMessage structure Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 03/19] kvm: Introduce basic MSI support for in-kernel irqchips Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 04/19] pc: Enable MSI support at APIC level Avi Kivity
2012-05-21 16:37 ` Avi Kivity [this message]
2012-05-21 16:37 ` [Qemu-devel] [PATCH 06/19] kvm: Update kernel headers Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 07/19] kvm: Add support for direct MSI injections Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 08/19] kvm: Enable in-kernel irqchip support by default Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 09/19] msix: Factor out msix_get_message Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 10/19] msix: Invoke msix_handle_mask_update on msix_mask_all Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 11/19] msix: Introduce vector notifiers Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 12/19] kvm: Rename kvm_irqchip_add_route to kvm_irqchip_add_irq_route Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 13/19] kvm: Introduce kvm_irqchip_add_msi_route Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 14/19] kvm: Publicize kvm_irqchip_release_virq Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 15/19] kvm: Make kvm_irqchip_commit_routes an internal service Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 16/19] kvm: Introduce kvm_irqchip_add/remove_irqfd Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 17/19] kvm: Enable use of kvm_irqchip_in_kernel in hwlib code Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 18/19] msix: Add msix_nr_vectors_allocated Avi Kivity
2012-05-21 16:37 ` [Qemu-devel] [PATCH 19/19] virtio/vhost: Add support for KVM in-kernel MSI injection Avi Kivity
2012-06-04 5:46 ` [Qemu-devel] [PULL 00/20 1.2] kvm updates Anthony Liguori
2012-06-05 0:52 ` Andreas Färber
2012-06-05 1:58 ` Anthony Liguori
2012-06-05 2:26 ` Andreas Färber
2012-06-05 7:42 ` Avi Kivity
2012-06-05 8:10 ` Alexander Graf
2012-06-05 8:32 ` Jan Kiszka
2012-06-05 9:02 ` Anthony Liguori
2012-06-05 9:11 ` Avi Kivity
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=1337618267-16669-6-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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).