Add powerpc kvm qemu support
PATCH 1/1 Add powerpc kvm qemu support
# HG changeset patch
# User Jerone Young <[email protected]>
# Date 1200692014 21600
# Node ID 1c5b26c965e85986cc93c6b905394a8b2a6b5950 # Parent c1641ad67444cc0401fe3462b33dd88df01beae0 Add powerpc kvm qemu support
This patch adds code needed for support of powerpc in kvm qemu.
* * *
[PATCH] fill kvm_callback with arch specific dcr_read/dcr_write callbacks
This Patch adds the callback assignment and handlers for powerpc_dcr_read and ppc_dcr_write which are called from libkvm.
This is the part of the patch that changes powerpc code and will be folded to our combined patch for qemu-kvm-powerpc.c.
qemu-kvm-powerpc.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
* * *
* * *
[PATCH] cr not used
cr not used (not part of CPUState in qemu for ppc), but we don't need that comment anymore.
* * *
[PATCH] hflags works using qemu helper function
qemu has a calculation function to get valid hflags (as appliable to ppc) out of env->msr. This patch uses this function from target-ppc/helper_regs.h to solve that - remove todo
* * *
[TODO] is available for ppc (at least atm)
is available for ppc (at least atm), remove todo
* * *
[TOFOLD] interrupt injection is available in USE_KVM ifdefs
interrupt injection is available in USE_KVM ifdefs, remove todo
* * *
* * *
* * *
[PATCH] fix ppc440_init argument list
This argument list did not match the call from main in vl.c
ppc440_boards_kvm.c | 1 - 1 files changed, 1 deletion(-)
* * *
[PATCH] remove old shortcuts
these are no longer needed - patch will be fold into add_qemu_code later
ppc440_boards_kvm.c | 7 ------- 1 files changed, 7 deletions(-)
* * *
qemu/Makefile.target +11 -1
@@ -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)
@@ -477,6 +480,7 @@ ifeq ($(TARGET_BASE_ARCH), ia64) ifeq ($(TARGET_BASE_ARCH), ia64) # Hardware support VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) +VL_OBJS+= cirrus_vga.o VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o ipf.o VL_OBJS+= cirrus_vga.o parallel.o acpi.o piix_pci.o VL_OBJS+= usb-uhci.o smbus_eeprom.o
@@ -486,6 +490,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 +502,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+= $(LIBOBJS) ppc440_boards_kvm.o endif ifeq ($(TARGET_BASE_ARCH), mips) VL_OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
@@ -656,6 +662,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 $@ $<
qemu/configure +5 -1
@@ -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
qemu/hw/boards.h +1 -0
@@ -32,6 +32,7 @@ extern QEMUMachine heathrow_machine;extern QEMUMachine heathrow_machine;extern QEMUMachine ref405ep_machine;extern QEMUMachine taihu_machine; +extern QEMUMachine bambookvm_machine;/* mips_r4k.c */ extern QEMUMachine mips_machine;
qemu/hw/ppc440_boards_kvm.c new file +249 -0
249 lines not on this page · raw message
qemu/qemu-kvm-powerpc.c new file +207 -0
207 lines not on this page · raw message
qemu/target-ppc/cpu.h +12 -0
@@ -573,6 +573,11 @@ struct CPUPPCState {target_ulong msr;/* temporary general purpose registers */ ppc_gpr_t tgpr[4 ];/* Used to speed-up TLB assist handlers */ + +#ifdef USE_KVM +uint64_t tsc;/* time stamp counter */ +uint8_t ready_for_interrupt_injection; +#endif /* Floating point execution context */ /* temporary float registers */
@@ -1421,4 +1426,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__) */
qemu/vl.c +1 -0
@@ -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 (&bambookvm_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/
_______________________________________________
kvm-ppc-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel
qemu/hw/ppc440_boards_kvm.c line 2
Quoted 5 lines · Jerone Young
qemu/hw/ppc440_boards_kvm.c new file +2
-0@@ -0,0 +1,251 @@ +/* +* Qemu PowerPC 440 board emualtion with KVM enlightnments
enhancements?
qemu/hw/ppc440_boards_kvm.c line 11
Quoted 9 lines
qemu/hw/ppc440_boards_kvm.c new file +9
-0+* +* Copyright 2007 IBM Corporation. +* Added by: Jerone Young <[email protected]> +* +* This work is licensed under the GNU LGPL license, version 2. +* +*/ + +/* XXX THIS CODE IS STILL DRAFT! DO NOT POST TO THE LIST! */
heh
Quoted 5 lines
qemu/hw/ppc440_boards_kvm.c new file +5
-0+ +#include <sys/mman.h> + +#include "hw.h" +#include "ppc.h"
qemu/hw/ppc440_boards_kvm.c line 26
Quoted 10 lines
qemu/hw/ppc440_boards_kvm.c new file +10
-0+#include "ppc405.h" +#include "pc.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "exec-all.h" +#include "boards.h" + +#include "qemu-kvm.h" + +#define DEFAULT_RAM_SIZE 32*1024*1024
You want parentheses around that expression.
Quoted 7 lines
qemu/hw/ppc440_boards_kvm.c new file +7
-0+static void bambooKVM_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) +{
....
qemu/hw/ppc440_boards_kvm.c line 231
Quoted 12 lines
qemu/hw/ppc440_boards_kvm.c new file +12
-0+ +/* XXX insert TLB entries */ + env->gpr[1 ] = (16 <<20 ) -8 ; + env->gpr[4 ] = initrd_base; + env->gpr[5 ] = initrd_size; + +/* Set program counter (ip in x86 terms .... but it's ep in ppc) */ + env->nip = ep; +printf ("Program Counter (ep) is being set to 0x%08x\n" , ep); + +/* lock RAM */ +mlock (phys_ram_base, phys_ram_size);
Do you care if that fails?
qemu/hw/ppc440_boards_kvm.c line 243
Quoted 12 lines
qemu/hw/ppc440_boards_kvm.c new file +12
-0+ +/* run in kvm */ +/* XXX SMP IS NOT SUPPORTED YET */ +printf ("%s: running kvm functions\n" , __func__); + env->cpu_index =0 ; + +/* XXX need a call to set ep */ +printf ("%s: loading kvm registers\n" , __func__); +kvm_load_registers (env); + +printf ("%s: DONE\n" , __func__); +}
-------------------------------------------------------------------------
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-ppc-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel
Quoted 9 lines · Nathan Lynch
qemu/hw/ppc440_boards_kvm.c line 2
Quoted 5 lines · Jerone Young
qemu/hw/ppc440_boards_kvm.c new file +2
-0@@ -0,0 +1,251 @@ +/* +* Qemu PowerPC 440 board emualtion with KVM enlightnments enhancements?
Quoted 11 lines
qemu/hw/ppc440_boards_kvm.c line 11
Quoted 9 lines
qemu/hw/ppc440_boards_kvm.c new file +9
-0+* +* Copyright 2007 IBM Corporation. +* Added by: Jerone Young <[email protected]> +* +* This work is licensed under the GNU LGPL license, version 2. +* +*/ + +/* XXX THIS CODE IS STILL DRAFT! DO NOT POST TO THE LIST! */ heh
I've cleaned this up in our internal repo. I plan on sending these patches every friday till we get them in upstream KVM. But it was a last minute decision to send what we had to the list. Next one will be a LOT cleaner.
Quoted 11 lines
Quoted 11 lines
qemu/hw/ppc440_boards_kvm.c new file +9
-0+ +#include <sys/mman.h> + +#include "hw.h" +#include "ppc.h" +#include "ppc405.h" +#include "pc.h" +#include "qemu-timer.h" +#include "sysemu.h"
Quoted 8 lines
qemu/hw/ppc440_boards_kvm.c line 26
Quoted 6 lines
qemu/hw/ppc440_boards_kvm.c new file +6
-0+#include "exec-all.h" +#include "boards.h" + +#include "qemu-kvm.h" + +#define DEFAULT_RAM_SIZE 32*1024*1024You want parentheses around that expression.
I've removed this now. But yes you are right, not having the parentheses can cause problems if you have DEFAULT_RAM_SIZE^2 or something like that.
Quoted 12 lines
Quoted 9 lines
qemu/hw/ppc440_boards_kvm.c new file +7
-0+static void bambooKVM_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) +{....
Quoted 14 lines
qemu/hw/ppc440_boards_kvm.c line 231
Quoted 12 lines
qemu/hw/ppc440_boards_kvm.c new file +12
-0+ +/* XXX insert TLB entries */ + env->gpr[1 ] = (16 <<20 ) -8 ; + env->gpr[4 ] = initrd_base; + env->gpr[5 ] = initrd_size; + +/* Set program counter (ip in x86 terms .... but it's ep in ppc) */ + env->nip = ep; +printf ("Program Counter (ep) is being set to 0x%08x\n" , ep); + +/* lock RAM */ +mlock (phys_ram_base, phys_ram_size);Do you care if that fails?
Good catch. I'll add a check for it.
Quoted 14 lines
Quoted 4 lines
qemu/hw/ppc440_boards_kvm.c new file +2
-0+ +/* run in kvm */ qemu/hw/ppc440_boards_kvm.c line 243
Quoted 10 lines
qemu/hw/ppc440_boards_kvm.c new file +10
-0+/* XXX SMP IS NOT SUPPORTED YET */ +printf ("%s: running kvm functions\n" , __func__); + env->cpu_index =0 ; + +/* XXX need a call to set ep */ +printf ("%s: loading kvm registers\n" , __func__); +kvm_load_registers (env); + +printf ("%s: DONE\n" , __func__); +}
-------------------------------------------------------------------------
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-ppc-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel
PATCH 1/1 Add powerpc kvm qemu support
In reply to Jerone Young# HG changeset patch
# User Jerone Young <[email protected]>
# Date 1201288298 21600
# Node ID 8c7c65b2c7e8ecabe0e452e4098a5ff439dd9645 # Parent 1bba54954f3ed64959afc0d652fac4ccef714974 Add powerpc kvm qemu support
This patch adds code needed for support of powerpc in kvm qemu.
* * *
[PATCH] fill kvm_callback with arch specific dcr_read/dcr_write callbacks
This Patch adds the callback assignment and handlers for powerpc_dcr_read and ppc_dcr_write which are called from libkvm.
This is the part of the patch that changes powerpc code and will be folded to our combined patch for qemu-kvm-powerpc.c.
qemu-kvm-powerpc.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
* * *
* * *
[PATCH] cr not used
cr not used (not part of CPUState in qemu for ppc), but we don't need that comment anymore.
* * *
[PATCH] hflags works using qemu helper function
qemu has a calculation function to get valid hflags (as appliable to ppc) out of env->msr. This patch uses this function from target-ppc/helper_regs.h to solve that - remove todo
* * *
[TODO] is available for ppc (at least atm)
is available for ppc (at least atm), remove todo
* * *
[TOFOLD] interrupt injection is available in USE_KVM ifdefs
interrupt injection is available in USE_KVM ifdefs, remove todo
* * *
* * *
* * *
[PATCH] fix ppc440_init argument list
This argument list did not match the call from main in vl.c
ppc440_boards_kvm.c | 1 - 1 files changed, 1 deletion(-)
* * *
[PATCH] remove old shortcuts
these are no longer needed - patch will be fold into add_qemu_code later
ppc440_boards_kvm.c | 7 ------- 1 files changed, 7 deletions(-)
* * *
qemu/Makefile.target +11 -1
@@ -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)
@@ -477,6 +480,7 @@ ifeq ($(TARGET_BASE_ARCH), ia64) ifeq ($(TARGET_BASE_ARCH), ia64) # Hardware support VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) +VL_OBJS+= cirrus_vga.o VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o ipf.o VL_OBJS+= cirrus_vga.o parallel.o acpi.o piix_pci.o VL_OBJS+= usb-uhci.o smbus_eeprom.o
@@ -486,6 +490,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 +502,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+= $(LIBOBJS) ppc440_boards_kvm.o endif ifeq ($(TARGET_BASE_ARCH), mips) VL_OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
@@ -656,6 +662,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 $@ $<
qemu/configure +5 -1
@@ -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
qemu/hw/boards.h +1 -0
@@ -32,6 +32,7 @@ extern QEMUMachine heathrow_machine;extern QEMUMachine heathrow_machine;extern QEMUMachine ref405ep_machine;extern QEMUMachine taihu_machine; +extern QEMUMachine bambookvm_machine;/* mips_r4k.c */ extern QEMUMachine mips_machine;
qemu/hw/ppc440_boards_kvm.c new file +228 -0
228 lines not on this page · raw message
qemu/qemu-kvm-powerpc.c new file +204 -0
204 lines not on this page · raw message
qemu/target-ppc/cpu.h +12 -0
@@ -573,6 +573,11 @@ struct CPUPPCState {target_ulong msr;/* temporary general purpose registers */ ppc_gpr_t tgpr[4 ];/* Used to speed-up TLB assist handlers */ + +#ifdef USE_KVM +uint64_t tsc;/* time stamp counter */ +uint8_t ready_for_interrupt_injection; +#endif /* Floating point execution context */ /* temporary float registers */
@@ -1421,4 +1426,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__) */
qemu/vl.c +1 -0
@@ -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 (&bambookvm_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/
_______________________________________________
kvm-ppc-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel