@@ -131,6 +131,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
ARCH_INCLUDE := powerpc/include
CFLAGS += -m64
@@ -24,6 +24,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <assert.h>
static int debug_fd;
@@ -177,6 +178,39 @@ bool kvm_cpu__handle_exit(struct kvm_cpu *vcpu)
return ret;
}
+bool kvm_cpu__emulate_io(struct kvm_cpu *cpu, struct kvm_run *kvm_run)
+{
+ bool ret = false;
+ u64 phys_addr;
+
+ /* We'll never get KVM_EXIT_IO, it's x86-specific. All IO is MM! :P
+ * So, look at our windows here & split addresses into I/O or MMIO.
+ */
+ assert(kvm_run->exit_reason == KVM_EXIT_MMIO);
+
+ phys_addr = cpu->kvm_run->mmio.phys_addr;
+ if ((phys_addr >= SPAPR_PCI_IO_WIN_ADDR) &&
+ (phys_addr < SPAPR_PCI_IO_WIN_ADDR + SPAPR_PCI_IO_WIN_SIZE)) {
+ ret = kvm__emulate_io(cpu->kvm, phys_addr - SPAPR_PCI_IO_WIN_ADDR,
+ cpu->kvm_run->mmio.data,
+ cpu->kvm_run->mmio.is_write ?
+ KVM_EXIT_IO_OUT : KVM_EXIT_IO_IN,
+ cpu->kvm_run->mmio.len, 1);
+ } else if ((phys_addr >= SPAPR_PCI_MEM_WIN_ADDR) &&
+ (phys_addr < SPAPR_PCI_MEM_WIN_ADDR + SPAPR_PCI_MEM_WIN_SIZE)) {
+ ret = kvm__emulate_mmio(cpu->kvm,
+ cpu->kvm_run->mmio.phys_addr - SPAPR_PCI_MEM_WIN_ADDR,
+ cpu->kvm_run->mmio.data,
+ cpu->kvm_run->mmio.len,
+ cpu->kvm_run->mmio.is_write);
+ } else {
+ pr_warning("MMIO %s unknown address %lx (size %d)!\n",
+ cpu->kvm_run->mmio.is_write ? "write to" : "read from",
+ phys_addr, cpu->kvm_run->mmio.len);
+ }
+ return ret;
+}
+
#define CONDSTR_BIT(m, b) (((m) & MSR_##b) ? #b" " : "")
void kvm_cpu__show_registers(struct kvm_cpu *vcpu)
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/kvm-cpu.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html