From: Matt Evans <matt@ozlabs.org>
To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: penberg@kernel.org, asias.hejun@gmail.com,
levinsasha928@gmail.com, gorcunov@gmail.com,
david@gibson.dropbear.id.au, aik@ozlabs.ru
Subject: [PATCH V4 7/7] kvm tools: Add PPC64 kvm_cpu__emulate_io()
Date: Tue, 31 Jan 2012 17:34:42 +1100 [thread overview]
Message-ID: <1327991682-18503-8-git-send-email-matt@ozlabs.org> (raw)
In-Reply-To: <1327991682-18503-1-git-send-email-matt@ozlabs.org>
This is the final piece of the puzzle for PPC SPAPR PCI; this
function splits MMIO accesses into the two PHB windows & directs
things to MMIO/IO emulation as appropriate.
Signed-off-by: Matt Evans <matt@ozlabs.org>
---
tools/kvm/Makefile | 1 +
tools/kvm/powerpc/include/kvm/kvm-cpu-arch.h | 10 +++++++++-
tools/kvm/powerpc/kvm-cpu.c | 22 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index 2d97b66..332b374 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -137,6 +137,7 @@ ifeq ($(uname_M), ppc64)
OBJS += powerpc/spapr_hcall.o
OBJS += powerpc/spapr_rtas.o
OBJS += powerpc/spapr_hvcons.o
+ OBJS += powerpc/spapr_pci.o
OBJS += powerpc/xics.o
# We use libfdt, but it's sometimes not packaged 64bit. It's small too,
# so just build it in:
diff --git a/tools/kvm/powerpc/include/kvm/kvm-cpu-arch.h b/tools/kvm/powerpc/include/kvm/kvm-cpu-arch.h
index c1c6539..7520c04 100644
--- a/tools/kvm/powerpc/include/kvm/kvm-cpu-arch.h
+++ b/tools/kvm/powerpc/include/kvm/kvm-cpu-arch.h
@@ -14,7 +14,7 @@
/* Architecture-specific kvm_cpu definitions. */
#include <linux/kvm.h> /* for struct kvm_regs */
-
+#include <stdbool.h>
#include <pthread.h>
#define MSR_SF (1UL<<63)
@@ -65,4 +65,12 @@ struct kvm_cpu {
void kvm_cpu__irq(struct kvm_cpu *vcpu, int pin, int level);
+/* This is never actually called on PPC. */
+static inline bool kvm_cpu__emulate_io(struct kvm *kvm, u16 port, void *data, int direction, int size, u32 count)
+{
+ return false;
+}
+
+bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, u8 is_write);
+
#endif /* KVM__KVM_CPU_ARCH_H */
diff --git a/tools/kvm/powerpc/kvm-cpu.c b/tools/kvm/powerpc/kvm-cpu.c
index 7dd1679..2505c69 100644
--- a/tools/kvm/powerpc/kvm-cpu.c
+++ b/tools/kvm/powerpc/kvm-cpu.c
@@ -15,6 +15,7 @@
#include "kvm/kvm.h"
#include "spapr.h"
+#include "spapr_pci.h"
#include "xics.h"
#include <sys/ioctl.h>
@@ -24,6 +25,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <assert.h>
static int debug_fd;
@@ -192,6 +194,26 @@ bool kvm_cpu__handle_exit(struct kvm_cpu *vcpu)
return ret;
}
+bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, u8 is_write)
+{
+ /*
+ * FIXME: This function will need to be split in order to support
+ * various PowerPC platforms/PHB types, etc. It currently assumes SPAPR
+ * PPC64 guest.
+ */
+ bool ret = false;
+
+ if ((phys_addr >= SPAPR_PCI_WIN_START) &&
+ (phys_addr < SPAPR_PCI_WIN_END)) {
+ ret = spapr_phb_mmio(kvm, phys_addr, data, len, is_write);
+ } else {
+ pr_warning("MMIO %s unknown address %llx (size %d)!\n",
+ is_write ? "write to" : "read from",
+ phys_addr, len);
+ }
+ return ret;
+}
+
#define CONDSTR_BIT(m, b) (((m) & MSR_##b) ? #b" " : "")
void kvm_cpu__show_registers(struct kvm_cpu *vcpu)
--
1.7.0.4
next prev parent reply other threads:[~2012-01-31 6:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 6:34 [PATCH V4 0/7] Add initial SPAPR PPC64 architecture support Matt Evans
2012-01-31 6:34 ` [PATCH V4 1/7] kvm tools: PPC64, add HPT/SDR1 for -PR KVM Matt Evans
2012-01-31 6:34 ` [PATCH V4 2/7] kvm tools: Generate SPAPR PPC64 guest device tree Matt Evans
2012-01-31 7:59 ` Pekka Enberg
2012-01-31 10:00 ` Matt Evans
2012-02-01 3:39 ` David Gibson
2012-02-01 4:13 ` Alexey Kardashevskiy
2012-01-31 6:34 ` [PATCH V4 3/7] kvm tools: Add SPAPR PPC64 hcall & rtascall structure Matt Evans
2012-01-31 8:11 ` Pekka Enberg
2012-01-31 10:22 ` Matt Evans
2012-01-31 6:34 ` [PATCH V4 4/7] kvm tools: Add SPAPR PPC64 HV console Matt Evans
2012-01-31 6:34 ` [PATCH V4 5/7] kvm tools: Add PPC64 XICS interrupt controller support Matt Evans
2012-01-31 6:34 ` [PATCH V4 6/7] kvm tools: Add PPC64 PCI Host Bridge Matt Evans
2012-02-01 3:40 ` David Gibson
2012-02-01 4:14 ` Alexey Kardashevskiy
2012-01-31 6:34 ` Matt Evans [this message]
2012-01-31 8:29 ` [PATCH V4 0/7] Add initial SPAPR PPC64 architecture support Pekka Enberg
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=1327991682-18503-8-git-send-email-matt@ozlabs.org \
--to=matt@ozlabs.org \
--cc=aik@ozlabs.ru \
--cc=asias.hejun@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=gorcunov@gmail.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=penberg@kernel.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).