* [PATCH 1 of 7] Enhnace kvm-userspace configure script for powerpc
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:16 ` [PATCH 2 of 7] Ensure 4kB page alignment for embedded powerpc when using kvm Jerone Young
` (7 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1201488336 21600
# Node ID 4b35e985aaf2021d956b09bd690c72ea5cadb007
# Parent a2740102bf6564a194e55b605c69886c56a37ece
Enhnace kvm-userspace configure script for powerpc
Add qemu option to tell qemu to compile ppcemb-softmmu, if ARCH=powerpc is used.
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -101,6 +101,10 @@ if [ "$arch" = "ia64" ]; then
target_exec="ia64-softmmu"
fi
+if [ "$arch" = "powerpc" ]; then
+ target_exec="ppcemb-softmmu"
+fi
+
#configure user dir
(cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
--arch="$arch" \
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 2 of 7] Ensure 4kB page alignment for embedded powerpc when using kvm
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
2008-01-28 3:16 ` [PATCH 1 of 7] Enhnace kvm-userspace configure script for powerpc Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:16 ` [PATCH 3 of 7] Chnage so that Powerpc & IA64 do not have KVM_EXTRA_PAGES set Jerone Young
` (6 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Christian Ehrhardt <ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
# Date 1201488336 21600
# Node ID 57f4e5bd23e0da3c493e769e3e2b738e1495f7ef
# Parent 4b35e985aaf2021d956b09bd690c72ea5cadb007
Ensure 4kB page alignment for embedded powerpc when using kvm
Powerpc needs 4kB aligned pages when using qemu together with kvm. Qemu already had a similar issue when CONFIG_USER_ONLY was set so this patch adds just one more condition to the existing ifdef.
Signed-off-by: Christian Ehrhardt <ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -50,9 +50,10 @@ typedef uint32_t ppc_gpr_t;
/* Specific definitions for PowerPC embedded */
/* BookE have 36 bits physical address space */
#define TARGET_PHYS_ADDR_BITS 64
-#if defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_USER_ONLY) || defined(USE_KVM)
/* It looks like a lot of Linux programs assume page size
* is 4kB long. This is evil, but we have to deal with it...
+ * Also kvm for embedded powerpc needs (atm) 4kB aligned pages
*/
#define TARGET_PAGE_BITS 12
#else /* defined(CONFIG_USER_ONLY) */
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 3 of 7] Chnage so that Powerpc & IA64 do not have KVM_EXTRA_PAGES set
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
2008-01-28 3:16 ` [PATCH 1 of 7] Enhnace kvm-userspace configure script for powerpc Jerone Young
2008-01-28 3:16 ` [PATCH 2 of 7] Ensure 4kB page alignment for embedded powerpc when using kvm Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:16 ` [PATCH 4 of 7] Add vcpu to arguments of powerpc libkvm callbacks Jerone Young
` (5 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Christian Ehrhardt <ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
# Date 1201488336 21600
# Node ID 7c535acfd618f41aa6f49efa25e3fd6e1f75b633
# Parent 57f4e5bd23e0da3c493e769e3e2b738e1495f7ef
Chnage so that Powerpc & IA64 do not have KVM_EXTRA_PAGES set
IA64 already had an exclusion and so does ppc. This patch switches the
default to no extra pages and lets I386 and X86_64 get it's 3 extra pages
as needed.
Signed-off-by: Christian Ehrhardt <ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/qemu/vl.c b/qemu/vl.c
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -9313,10 +9313,10 @@ int main(int argc, char **argv)
#if USE_KVM
/* Initialize kvm */
-#ifdef TARGET_IA64
+#if defined(TARGET_I386) || defined(TARGET_X86_64)
+#define KVM_EXTRA_PAGES 3
+#else
#define KVM_EXTRA_PAGES 0
-#else
-#define KVM_EXTRA_PAGES 3
#endif
if (kvm_allowed) {
phys_ram_size += KVM_EXTRA_PAGES * TARGET_PAGE_SIZE;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 4 of 7] Add vcpu to arguments of powerpc libkvm callbacks
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
` (2 preceding siblings ...)
2008-01-28 3:16 ` [PATCH 3 of 7] Chnage so that Powerpc & IA64 do not have KVM_EXTRA_PAGES set Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:16 ` [PATCH 5 of 7] Add qemu powerpc build support Jerone Young
` (4 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1201488336 21600
# Node ID 3aa131f9bc863af5d029740b1579e747d3703c7e
# Parent 7c535acfd618f41aa6f49efa25e3fd6e1f75b633
Add vcpu to arguments of powerpc libkvm callbacks
This patch adds vcpu as an argmunent for powerpc specific callbacks:
powerpc_dcr_read
powerpc_dcr_write
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -26,15 +26,17 @@
#include <errno.h>
#include <stdio.h>
-int handle_dcr(struct kvm_run *run, kvm_context_t kvm)
+int handle_dcr(struct kvm_run *run, kvm_context_t kvm, int vcpu)
{
int ret = 0;
if (run->dcr.is_write)
- ret = kvm->callbacks->powerpc_dcr_write(run->dcr.dcrn,
+ ret = kvm->callbacks->powerpc_dcr_write(vcpu,
+ run->dcr.dcrn,
run->dcr.data);
else
- ret = kvm->callbacks->powerpc_dcr_read(run->dcr.dcrn,
+ ret = kvm->callbacks->powerpc_dcr_read(vcpu,
+ run->dcr.dcrn,
&(run->dcr.data));
return ret;
@@ -102,7 +104,7 @@ int kvm_arch_run(struct kvm_run *run, kv
switch (run->exit_reason){
case KVM_EXIT_DCR:
- ret = handle_dcr(run, kvm);
+ ret = handle_dcr(run, kvm, vcpu);
break;
default:
ret = 1;
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -66,8 +66,8 @@ struct kvm_callbacks {
int (*pre_kvm_run)(void *opaque, int vcpu);
int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
#if defined(__powerpc__)
- int (*powerpc_dcr_read)(uint32_t dcrn, uint32_t *data);
- int (*powerpc_dcr_write)(uint32_t dcrn, uint32_t data);
+ int (*powerpc_dcr_read)(int vcpu, uint32_t dcrn, uint32_t *data);
+ int (*powerpc_dcr_write)(int vcpu, uint32_t dcrn, uint32_t data);
#endif
};
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 5 of 7] Add qemu powerpc build support
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
` (3 preceding siblings ...)
2008-01-28 3:16 ` [PATCH 4 of 7] Add vcpu to arguments of powerpc libkvm callbacks Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:16 ` [PATCH 6 of 7] Add powerpc KVM support to qemu Jerone Young
` (3 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1201488336 21600
# Node ID 391b6488213008a4502b1753c26e8bd5200bd3c6
# Parent 3aa131f9bc863af5d029740b1579e747d3703c7e
Add qemu powerpc build support
This patch adds build support required to build ppcemb with KVM support for
powerpc.
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -299,7 +299,7 @@ OBJS+= libqemu.a
# cpu emulator library
LIBOBJS=exec.o kqemu.o qemu-kvm.o translate-op.o translate-all.o cpu-exec.o\
- translate.o op.o host-utils.o qemu-kvm-helper.o
+ translate.o op.o host-utils.o
ifdef CONFIG_SOFTFLOAT
LIBOBJS+=fpu/softfloat.o
else
@@ -310,15 +310,18 @@ ifeq ($(TARGET_ARCH), i386)
ifeq ($(TARGET_ARCH), i386)
LIBOBJS+=helper.o helper2.o
LIBOBJS+=qemu-kvm-x86.o kvm-tpr-opt.o
+LIBOBJS+=qemu-kvm-helper.o
endif
ifeq ($(TARGET_ARCH), x86_64)
LIBOBJS+=helper.o helper2.o
LIBOBJS+=qemu-kvm-x86.o kvm-tpr-opt.o
+LIBOBJS+=qemu-kvm-helper.o
endif
ifeq ($(TARGET_BASE_ARCH), ppc)
LIBOBJS+= op_helper.o helper.o
+LIBOBJS+= qemu-kvm-powerpc.o
endif
ifeq ($(TARGET_BASE_ARCH), mips)
@@ -486,6 +489,7 @@ CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOI
CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
# shared objects
VL_OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
+VL_OBJS+= cirrus_vga.o
# PREP target
VL_OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
VL_OBJS+= prep_pci.o ppc_prep.o
@@ -497,6 +501,7 @@ VL_OBJS+= unin_pci.o ppc_chrp.o
VL_OBJS+= unin_pci.o ppc_chrp.o
# PowerPC 4xx boards
VL_OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
+VL_OBJS+= ppc440.o ppc440_bamboo.o
endif
ifeq ($(TARGET_BASE_ARCH), mips)
VL_OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
@@ -656,6 +661,10 @@ firmware.o: firmware.c
$(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
endif
+ifeq ($(TARGET_ARCH), ppc)
+qemu-kvm-powerpc.o: qemu-kvm-powerpc.c qemu-kvm.h
+endif
+
cpu-exec.o: cpu-exec.c
$(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -199,6 +199,9 @@ if [ "$cpu" = "ia64" ] ; then
kvm="yes"
gdbstub="no"
slirp="no"
+fi
+if [ "$cpu" = "powerpc" ]; then
+ kvm="yes"
fi
;;
esac
@@ -1067,7 +1070,7 @@ echo "#define CONFIG_QEMU_PREFIX \"$inte
configure_kvm() {
if test $kvm = "yes" -a "$target_softmmu" = "yes" -a \
- \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" \); then
+ \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
echo "#define USE_KVM 1" >> $config_h
echo "CONFIG_KVM_KERNEL_INC=$kernel_path/include" >> $config_mak
fi
@@ -1118,6 +1121,7 @@ elif test "$target_cpu" = "ppcemb" ; the
echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
echo "#define TARGET_PPC 1" >> $config_h
echo "#define TARGET_PPCEMB 1" >> $config_h
+ configure_kvm
elif test "$target_cpu" = "ppc64" ; then
echo "TARGET_ARCH=ppc64" >> $config_mak
echo "TARGET_ABI_DIR=ppc" >> $config_mak
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 6 of 7] Add powerpc KVM support to qemu
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
` (4 preceding siblings ...)
2008-01-28 3:16 ` [PATCH 5 of 7] Add qemu powerpc build support Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:16 ` [PATCH 7 of 7] Add Powerpc 440 board model "bamboo" to take advantage of Powerpc KVM Jerone Young
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1201490017 21600
# Node ID bf22e220977099e60b57be9e16d7d96487defdc1
# Parent 391b6488213008a4502b1753c26e8bd5200bd3c6
Add powerpc KVM support to qemu.
This patch adds needed files and other modifications for supporting of powerpc KVM within qemu.
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Christian Ehrhardt <ehrhardt-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
new file mode 100644
--- /dev/null
+++ b/qemu/qemu-kvm-powerpc.c
@@ -0,0 +1,198 @@
+
+#include "config.h"
+#include "config-host.h"
+
+extern int kvm_allowed;
+extern int kvm_irqchip;
+
+#ifdef USE_KVM
+
+#include <string.h>
+#include "hw/hw.h"
+#include "sysemu.h"
+#include "cpu.h"
+#include "helper_regs.h"
+
+#include "qemu-kvm.h"
+#include <libkvm.h>
+#include <pthread.h>
+#include <sys/utsname.h>
+
+extern kvm_context_t kvm_context;
+extern __thread CPUState *vcpu_env;
+
+void cpu_reset(CPUState *env)
+{
+ cpu_ppc_reset(env);
+}
+
+
+int kvm_arch_qemu_create_context(void)
+{
+ return 0;
+}
+
+void kvm_arch_load_regs(CPUState *env)
+{
+ struct kvm_regs regs;
+ int rc,i;
+
+ rc = kvm_get_regs(kvm_context, env->cpu_index, ®s);
+ if (rc == -1)
+ perror("kvm_get_regs FAILED");
+
+ /* cr is untouched in qemu and not existant in CPUState fr ppr */
+ /* hflags is a morphed to MSR on ppc, no need to sync that down to kvm */
+
+ regs.pc = env->nip;
+
+ regs.ctr = env->ctr;
+ regs.lr = env->lr;
+ regs.xer = ppc_load_xer(env);
+ regs.msr = env->msr;
+
+ regs.srr0 = env->spr[SPR_SRR0];
+ regs.srr1 = env->spr[SPR_SRR1];
+
+ regs.sprg0 = env->spr[SPR_SPRG0];
+ regs.sprg1 = env->spr[SPR_SPRG1];
+ regs.sprg2 = env->spr[SPR_SPRG2];
+ regs.sprg3 = env->spr[SPR_SPRG3];
+ regs.sprg4 = env->spr[SPR_SPRG4];
+ regs.sprg5 = env->spr[SPR_SPRG5];
+ regs.sprg6 = env->spr[SPR_SPRG6];
+ regs.sprg7 = env->spr[SPR_SPRG7];
+
+ for (i = 0;i < 32; i++){
+ regs.gpr[i] = env->gpr[i];
+ regs.fpr[i] = env->fpr[i];
+ }
+
+ rc = kvm_set_regs(kvm_context, env->cpu_index, ®s);
+ if (rc == -1)
+ perror("kvm_set_regs FAILED");
+}
+
+
+void kvm_arch_save_regs(CPUState *env)
+{
+ struct kvm_regs regs;
+ uint32_t i, rc;
+
+ rc = kvm_get_regs(kvm_context, env->cpu_index, ®s);
+ if (rc == -1)
+ perror("kvm_get_regs FAILED");
+
+ env->ctr =regs.ctr;
+ env->lr = regs.lr;
+ ppc_store_xer(env,regs.xer);
+ env->msr = regs.msr;
+ /* calculate hflags based on the current msr using the ppc qemu helper */
+ hreg_compute_hflags(env);
+
+ env->nip = regs.pc;
+
+ env->spr[SPR_SRR0] = regs.srr0;
+ env->spr[SPR_SRR1] = regs.srr1;
+
+ env->spr[SPR_SPRG0] = regs.sprg0;
+ env->spr[SPR_SPRG1] = regs.sprg1;
+ env->spr[SPR_SPRG2] = regs.sprg2;
+ env->spr[SPR_SPRG3] = regs.sprg3;
+ env->spr[SPR_SPRG4] = regs.sprg4;
+ env->spr[SPR_SPRG5] = regs.sprg5;
+ env->spr[SPR_SPRG6] = regs.sprg6;
+ env->spr[SPR_SPRG7] = regs.sprg7;
+
+ for (i = 0;i < 32; i++){
+ env->gpr[i] = regs.gpr[i];
+ env->fpr[i] = regs.fpr[i];
+ }
+
+}
+
+int kvm_arch_qemu_init_env(CPUState *cenv)
+{
+ return 0;
+}
+
+int kvm_arch_halt(void *opaque, int vcpu)
+{
+ CPUState *env = cpu_single_env;
+
+ if (!(env->interrupt_request & CPU_INTERRUPT_HARD)
+ && (msr_ee))
+ {
+ env->halted = 1;
+ env->exception_index = EXCP_HLT;
+ }
+ return 1;
+}
+
+void kvm_arch_pre_kvm_run(void *opaque, int vcpu)
+{
+ return;
+}
+
+void kvm_arch_post_kvm_run(void *opaque, int vcpu)
+{
+ CPUState *env = qemu_kvm_cpu_env(vcpu);
+ cpu_single_env = env;
+ env->ready_for_interrupt_injection = \
+ kvm_is_ready_for_interrupt_injection(kvm_context, vcpu);
+}
+
+int kvm_arch_has_work(CPUState *env)
+{
+ if ((env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXIT)) &&
+ (msr_ee))
+ return 1;
+ return 0;
+}
+
+int kvm_arch_try_push_interrupts(void *opaque)
+{
+ CPUState *env = cpu_single_env;
+ int r;
+ unsigned irq;
+
+ if (env->ready_for_interrupt_injection &&
+ (env->interrupt_request & CPU_INTERRUPT_HARD))
+ {
+ env->interrupt_request &= ~CPU_INTERRUPT_HARD;
+
+ /* For now KVM disregards the 'irq' argument. However, in the
+ * future KVM could cache it in-kernel to avoid a heavyweight exit
+ * when reading the UIC.
+ */
+ irq = -1U;
+
+ r = kvm_inject_irq(kvm_context, env->cpu_index, irq);
+ if (r < 0)
+ printf("cpu %d fail inject %x\n", env->cpu_index, irq);
+ }
+
+ return (env->interrupt_request & CPU_INTERRUPT_HARD) != 0;
+}
+
+void kvm_arch_update_regs_for_sipi(CPUState *env)
+{
+ printf("%s: no kvm-powerpc multi processor support yet!\n", __func__);
+}
+
+/* map dcr access to existing qemu dcr emulation */
+int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data)
+{
+ CPUState *env = qemu_kvm_cpu_env(vcpu);
+ ppc_dcr_read(env->dcr_env, dcrn, data);
+ return 0; /* XXX ignore failed DCR ops */
+}
+
+int handle_powerpc_dcr_write(int vcpu, uint32_t dcrn, uint32_t data)
+{
+ CPUState *env = qemu_kvm_cpu_env(vcpu);
+ ppc_dcr_write(env->dcr_env, dcrn, data);
+ return 0; /* XXX ignore failed DCR ops */
+}
+
+#endif
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -55,8 +55,8 @@ int handle_tpr_access(void *opaque, int
uint64_t rip, int is_write);
#ifdef TARGET_PPC
-int handle_powerpc_dcr_read(uint32_t dcrn, uint32_t *data);
-int handle_powerpc_dcr_write(uint32_t dcrn, uint32_t data);
+int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data);
+int handle_powerpc_dcr_write(int vcpu,uint32_t dcrn, uint32_t data);
#endif
#define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
diff --git a/qemu/target-ppc/cpu.h b/qemu/target-ppc/cpu.h
--- a/qemu/target-ppc/cpu.h
+++ b/qemu/target-ppc/cpu.h
@@ -573,6 +573,10 @@ struct CPUPPCState {
target_ulong msr;
/* temporary general purpose registers */
ppc_gpr_t tgpr[4]; /* Used to speed-up TLB assist handlers */
+
+#ifdef USE_KVM
+ uint8_t ready_for_interrupt_injection;
+#endif
/* Floating point execution context */
/* temporary float registers */
@@ -1421,4 +1425,11 @@ enum {
/*****************************************************************************/
+/* hidden flags (hflags) - used internally by qemu to represent additional
+ * cpu states.
+ */
+#define HF_HALTED_SHIFT 1
+
+#define HF_HALTED_MASK 1<<HF_HALTED_SHIFT
+
#endif /* !defined (__CPU_PPC_H__) */
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 7 of 7] Add Powerpc 440 board model "bamboo" to take advantage of Powerpc KVM
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
` (5 preceding siblings ...)
2008-01-28 3:16 ` [PATCH 6 of 7] Add powerpc KVM support to qemu Jerone Young
@ 2008-01-28 3:16 ` Jerone Young
2008-01-28 3:46 ` [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Anthony Liguori
2008-01-28 11:03 ` Avi Kivity
8 siblings, 0 replies; 14+ messages in thread
From: Jerone Young @ 2008-01-28 3:16 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1201490062 21600
# Node ID 39f4363836421bc1f78f83c69ad10d76c58a678a
# Parent bf22e220977099e60b57be9e16d7d96487defdc1
Add Powerpc 440 board model "bamboo" to take advantage of Powerpc KVM.
This patch adds the bamboo board model to Qemu. The Bamboo is a PowerPC 440 SOC (System-on-chip) reference platform. This code takes advantage of PowerPC KVM capabilities.
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/qemu/hw/boards.h b/qemu/hw/boards.h
--- a/qemu/hw/boards.h
+++ b/qemu/hw/boards.h
@@ -32,6 +32,7 @@ extern QEMUMachine heathrow_machine;
extern QEMUMachine heathrow_machine;
extern QEMUMachine ref405ep_machine;
extern QEMUMachine taihu_machine;
+extern QEMUMachine bamboo_machine;
/* mips_r4k.c */
extern QEMUMachine mips_machine;
diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c
new file mode 100644
--- /dev/null
+++ b/qemu/hw/ppc440.c
@@ -0,0 +1,56 @@
+/*
+ * Qemu PowerPC 440 board emualtion
+ *
+ * Copyright 2007 IBM Corporation.
+ * Authors: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ *
+ */
+
+#include "ppc440.h"
+
+void ppc440_init(CPUState *env,
+ target_phys_addr_t ram_bases[2],
+ target_phys_addr_t ram_sizes[2],
+ qemu_irq **picp,
+ int do_init)
+{
+ ppc4xx_mmio_t *mmio;
+ qemu_irq *pic, *irqs;
+ ram_addr_t offset;
+ int i;
+
+ ppc_dcr_init(env, NULL, NULL);
+
+ /* mmio */
+ printf("setup mmio\n");
+ mmio = ppc4xx_mmio_init(env, 0xEF600000);
+
+ /* universal controller */
+ printf("setup universal controller\n");
+ irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
+ irqs[PPCUIC_OUTPUT_INT] =
+ ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
+ irqs[PPCUIC_OUTPUT_CINT] =
+ ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
+ pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
+ *picp = pic;
+
+ /* SDRAM controller */
+ printf("trying to setup sdram controller\n");
+ ppc405_sdram_init(env, pic[14], 2, ram_bases, ram_sizes, do_init);
+ offset = 0;
+ for (i = 0; i < 2; i++)
+ offset += ram_sizes[i];
+
+ /* serial ports on page 126 of 440EP user manual */
+ if (serial_hds[0]) {
+ printf("Initializing first serial port\n");
+ ppc405_serial_init(env, mmio,0x300, pic[31], serial_hds[0]);
+ }
+ if (serial_hds[1]) {
+ printf("Initializing 2nd serial port\n");
+ ppc405_serial_init(env, mmio,0x400, pic[30], serial_hds[1]);
+ }
+}
diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h
new file mode 100644
--- /dev/null
+++ b/qemu/hw/ppc440.h
@@ -0,0 +1,29 @@
+/*
+ * Qemu PowerPC 440 board emualtion
+ *
+ * Copyright 2007 IBM Corporation.
+ * Authors: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ *
+ */
+
+#ifndef QEMU_PPC440_H
+#define QEMU_PPC440_H
+
+#include "hw.h"
+#include "ppc.h"
+#include "ppc405.h"
+#include "pc.h"
+#include "qemu-timer.h"
+#include "sysemu.h"
+#include "exec-all.h"
+#include "boards.h"
+
+void ppc440_init(CPUState *env,
+ target_phys_addr_t ram_bases[2],
+ target_phys_addr_t ram_sizes[2],
+ qemu_irq **picp,
+ int do_init);
+
+#endif
diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
new file mode 100644
--- /dev/null
+++ b/qemu/hw/ppc440_bamboo.c
@@ -0,0 +1,124 @@
+/*
+ * Qemu PowerPC 440 board emualtion
+ *
+ * Copyright 2007 IBM Corporation.
+ * Authors: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ *
+ */
+
+#include "ppc440.h"
+
+#define KERNEL_LOAD_ADDR 0x400000 /* uboot loader puts kernel at 4MB */
+
+#if USE_KVM
+#include "qemu-kvm.h"
+#endif
+
+/* PPC 440 refrence demo board
+ *
+ * 440 PowerPC CPU
+ */
+
+void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
+ const char *boot_device, DisplayState *ds,
+ const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename,
+ const char *cpu_model)
+{
+ target_phys_addr_t ram_bases[2], ram_sizes[2];
+ qemu_irq *pic;
+ CPUState *env;
+ target_ulong ep;
+ int is_linux=1; /* Will assume allways is Linux for now */
+ long kernel_size=0;
+ target_ulong initrd_base=0;
+ target_ulong initrd_size=0;
+
+ printf("%s: START\n", __func__);
+
+ /* Setup Memory */
+ if (ram_size) {
+ printf("Ram size specified on command line is %i bytes\n",
+ (int)ram_size);
+ printf("WARNING: RAM is hard coded to 144MB\n");
+ }
+ else {
+ printf("Using defualt ram size of %iMB\n",
+ ((int)ram_size/1024)/1024);
+ }
+
+ /* Each bank can only have memory in configurations of
+ * 16MB, 32MB, 64MB, 128MB, or 256MB
+ */
+ ram_bases[0] = 0x0;
+ ram_sizes[0] = 0x08000000;
+ ram_bases[1] = 0x0;
+ ram_sizes[1] = 0x01000000;
+
+ printf("Ram size of domain is %d bytes\n", (int)ram_size);
+
+ /* Setup CPU */
+ /* XXX We cheat for now and use 405 */
+ env = cpu_ppc_init("405");
+ if (!env) {
+ fprintf(stderr, "Unable to initilize CPU!\n");
+ exit(1);
+ }
+
+ /* call init */
+ printf("Calling function ppc440_init\n");
+ ppc440_init(env, ram_bases, ram_sizes, &pic,1);
+ printf("Done calling ppc440_init\n");
+
+ /* Register mem */
+ cpu_register_physical_memory(0, ram_size, 0);
+#if USE_KVM
+ kvm_cpu_register_physical_memory(0, ram_size, 0);
+#endif
+ /* load kernel with uboot loader */
+ printf("%s: load kernel\n", __func__);
+ kernel_size = load_uboot(kernel_filename, &ep, &is_linux);
+ if (kernel_size < 0) {
+ fprintf(stderr, "qemu: could not load kernel '%s'\n",
+ kernel_filename);
+ exit(1);
+ }
+
+ /* load initrd */
+ if (initrd_filename) {
+ initrd_base = kernel_size + KERNEL_LOAD_ADDR;
+ initrd_size = load_image(initrd_filename,
+ phys_ram_base + initrd_base);
+
+ if (initrd_size < 0) {
+ fprintf(stderr,
+ "qemu: could not load initial ram disk '%s'\n",
+ initrd_filename);
+ exit(1);
+ }
+ }
+
+#if USE_KVM
+ /* XXX insert TLB entries */
+ env->gpr[1] = (16<<20) - 8;
+ env->gpr[4] = initrd_base;
+ env->gpr[5] = initrd_size;
+
+ env->nip = ep;
+
+ env->cpu_index = 0;
+ printf("%s: loading kvm registers\n", __func__);
+ kvm_load_registers(env);
+#endif
+
+ printf("%s: DONE\n", __func__);
+}
+
+QEMUMachine bamboo_machine = {
+ "bamboo",
+ "bamboo",
+ bamboo_init,
+};
diff --git a/qemu/vl.c b/qemu/vl.c
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8318,6 +8318,7 @@ static void register_machines(void)
qemu_register_machine(&prep_machine);
qemu_register_machine(&ref405ep_machine);
qemu_register_machine(&taihu_machine);
+ qemu_register_machine(&bamboo_machine);
#elif defined(TARGET_MIPS)
qemu_register_machine(&mips_machine);
qemu_register_machine(&mips_malta_machine);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
` (6 preceding siblings ...)
2008-01-28 3:16 ` [PATCH 7 of 7] Add Powerpc 440 board model "bamboo" to take advantage of Powerpc KVM Jerone Young
@ 2008-01-28 3:46 ` Anthony Liguori
[not found] ` <479D5032.6050807-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2008-01-28 11:03 ` Avi Kivity
8 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2008-01-28 3:46 UTC (permalink / raw)
To: Jerone Young
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Jerone Young wrote:
> This set of patches is to enable PowerPC embedded KVM capablities to be taken advantage of by qemu.
>
> The code currently boots a ungziped uImage of the Linux kernel complied for PowerPC 440 AMCC Bamboo evalution board. We have not fully tested userspace, but fixes will follow as we do. We are also missing networking support, though this will come shortly. Also our current bamboo board model is h
> ardcoded to have 144MB or RAM (which will get changed shortly also).
>
> What you need:
> - A PowerPC 440 based SOC (System-on-Chip)
> (we have been testing with a AMCC bamboo & AMCC sequoia boards)
> - PowerPC KVM Patches (these have been sent by Hollis Blanchard to the list)
> - KVM Kernel source with PowerPC KVM Patches applied
> - cross tools with powerpc 440 compiler (this is assuming your not using a power machine)
> - version of zlib-1.2.3 or higher compiled for powerpc
>
> Then you compile with userspace. Here is an example of what I use to configure kvm-userspace:
>
> ./configure --arch=powerpc --cross-prefix=powerpc-440-linux-gnu- --with-patched-kernel --kerneldir=/home/jerone/work/kvmppc.hg/ --disable-sdl --disable-vnc-tls --disable-gfx-check --disable-gcc-check --qemu-cflags="-I/home/jerone/work/zlib-1.2.3 -I/home/jerone/work/kvmppc.hg/include/" --qemu-ldflags="-L/home/jerone/work/zlib-1.2.3/"
>
> Then you run "make". After which you will have an excutable:
> kvm-userspace/qemu/ppcemb-softmmu/qemu-system-ppcemb
>
> To run, boot your compiled KVM PPC enabled kernel and also compile your special none gzipped cuImag
> e of Linux for the Bamboo board. Then run:
>
> ./qemu-system-ppcemb -nographic -M bamboo -kernel cuImage.bambo
>
Since you're just adding a new machine type to the existing ppcemb, it
may be worth while to split out the KVM logic and submit the machine
type directly to qemu-devel.
Does the code work with -no-kvm?
Regards,
Anthony Liguori
> Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> kvm-devel mailing list
> kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches
2008-01-28 3:16 [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Jerone Young
` (7 preceding siblings ...)
2008-01-28 3:46 ` [PATCH 0 of 7] PowerPC Embedded KVM qemu enablement patches Anthony Liguori
@ 2008-01-28 11:03 ` Avi Kivity
8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2008-01-28 11:03 UTC (permalink / raw)
To: Jerone Young
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Jerone Young wrote:
> This set of patches is to enable PowerPC embedded KVM capablities to be taken advantage of by qemu.
>
> The code currently boots a ungziped uImage of the Linux kernel complied for PowerPC 440 AMCC Bamboo evalution board. We have not fully tested userspace, but fixes will follow as we do. We are also missing networking support, though this will come shortly. Also our current bamboo board model is h
> ardcoded to have 144MB or RAM (which will get changed shortly also).
>
>
Applied all, thanks.
Please submit the non kvm specific parts (bamboo) to qemu as well.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread