Add preliminary KVM support for non-embedded PPC v2
cover Add preliminary KVM support for non-embedded PPC v2
With KVM support emerging for Book3S (PPC64), let's add support for it in Qemu too, so we have a user of this awesome new infrastructure.
This patchset enabled building of Qemu on KVM, though it does not work completely due to
1) Brokenness of Qemu (PPC32 and PPC64 targets are broken for me atm)
2) Brokenness in Slot management (guest breaks in Linux's PCI init code)
Nevertheless, this is a good starting point for anyone who wants to get involved with KVM on PowerPC!
V1 -> V2
- remove unnecessary code for MP patch
- include SoB
Alexander Graf (4):
Enable PPC KVM for non-embedded
Set PVR in sregs
Add mp_state to PPC CPU struct
Fix warning in kvm-all.c
configure | 11 +++++++++++ kvm-all.c | 2 +- target-ppc/cpu.h | 4 ++++ target-ppc/kvm.c | 11 +++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-)
PATCH 1/4 Enable PPC KVM for non-embedded
We now have KVM on PPC64 too and might get it on PPC32 as well, as soon as someone writes it.
So let's enable KVM for PPC32 and PPC64 targets.
--- configure | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
configure +11 -0
@@ -1969,6 +1969,7 @@ target_kvm="$kvm" # Make sure the target and host cpus are compatible if test ! \( "$target_arch2" = "$cpu" -o \ \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \ + \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \ \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \ \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then target_kvm="no"
@@ -2087,6 +2088,11 @@ case "$target_arch2" in echo "TARGET_ARCH=ppc" >> $config_mak echo "#define TARGET_ARCH \"ppc\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h + if test "$target_kvm" = "yes" ; then + echo "CONFIG_KVM=y" >> $config_mak + echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak + echo "#define CONFIG_KVM 1" >> $config_h + fi gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" target_phys_bits=32 ;;
@@ -2110,6 +2116,11 @@ case "$target_arch2" in echo "#define TARGET_ARCH \"ppc64\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h + if test "$target_kvm" = "yes" ; then + echo "CONFIG_KVM=y" >> $config_mak + echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak + echo "#define CONFIG_KVM 1" >> $config_h + fi gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" target_phys_bits=64 ;;
Signature · 1 line
1.6.0.2
PATCH 2/4 Set PVR in sregs
We need to tell the kernel about some initial CPU state we don't have yet, so let's use the "sregs" IOCTL for that and simply put the Processor Version Register in there.
Now the kernel knows which guest CPU to virtualize.
--- target-ppc/kvm.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
target-ppc/kvm.c +9 -2
@@ -44,7 +44,13 @@ int kvm_arch_init(KVMState *s, int smp_cpus)int kvm_arch_init_vcpu (CPUState *cenv) { -return 0 ; +int ret =0 ; +struct kvm_sregs sregs; + + sregs.pvr = cenv->spr[SPR_PVR ]; + ret =kvm_vcpu_ioctl (cenv,KVM_SET_SREGS , &sregs); + +return ret; }int kvm_arch_put_registers (CPUState *env)
@@ -127,7 +133,8 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)* interrupt, reset, etc) in PPC-specific env->irq_input_state. */ if (run->ready_for_interrupt_injection && (env->interrupt_request &CPU_INTERRUPT_HARD ) && - (env->irq_input_state & (1 <<PPC40x_INPUT_INT))) +// (env->irq_input_state & (1<<PPC40x_INPUT_INT))) + (env->irq_input_state & (1 <<PPC6xx_INPUT_INT))) {/* For now KVM disregards the 'irq' argument. However, in the * future KVM could cache it in-kernel to avoid a heavyweight exit
Signature · 1 line
1.6.0.2
PATCH 3/4 Add mp_state to PPC CPU struct
Some generic code tries to access env->mp_state. Let's just make it happy and provide it.
--- target-ppc/cpu.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
target-ppc/cpu.h +4 -0
@@ -660,6 +660,10 @@ struct CPUPPCState {target_ulong hreset_vector;#endif +#ifdef CONFIG_KVM +uint32_t mp_state; +#endif +/* Those resources are used only during code translation */ /* Next instruction pointer */ target_ulong nip;
Signature · 1 line
1.6.0.2
PATCH 4/4 Fix warning in kvm-all.c
This fixes a warning I stumbled across while compiling qemu on PPC64.
--- kvm-all.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kvm-all.c +1 -1
@@ -226,7 +226,7 @@ static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr,if (mem ==NULL ) {fprintf (stderr,"BUG: %s: invalid parameters " TARGET_FMT_plx"-" TARGET_FMT_plx"\n" , __func__, phys_addr, - phys_addr + size -1 ); + (target_phys_addr_t)(phys_addr + size -1 ));return -EINVAL ; }
Signature · 1 line
1.6.0.2
PATCH 1/1 Enable kvm for ppc/ppc64
In reply to Alexander GrafFrom: Juan Quintela <[email protected]>
Hi
With new configure, patch should be like this.
--- configure | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
configure +2 -1
@@ -2016,11 +2016,12 @@ case "$target_arch2" in fi esac case "$target_arch2" in - i386|x86_64|ppcemb) + i386|x86_64|ppcemb|ppc|ppc64) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \ \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \ + \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \ \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \ \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then echo "CONFIG_KVM=y" >> $config_mak
Signature · 1 line
1.6.2.5
Re: [Qemu-devel] [PATCH] Enable kvm for ppc/ppc64
Quoted 8 lines · [email protected] wrote:
From: Juan Quintela <[email protected]>
Hi
With new configure, patch should be like this.
Signed-off-by Juan Quintela <[email protected]>
I don't think kvm exists for ppc/ppc64 (yet).
Regards,
Anthony Liguori
[Qemu-devel] Re: [PATCH] Enable kvm for ppc/ppc64
Quoted 11 lines · Anthony Liguori
Quoted 8 lines · [email protected] wrote:
From: Juan Quintela <[email protected]>
Hi
With new configure, patch should be like this.
Signed-off-by Juan Quintela <[email protected]>I don't think kvm exists for ppc/ppc64 (yet).
This one was the "correct" version of Alexander Graf patch :p I have to improve the in-reply-to: handling.
Later, Juan.
Quoted 3 lines
Regards,
Anthony Liguori
Re: [Qemu-devel] [PATCH] Enable kvm for ppc/ppc64
In reply to [email protected]Quoted 5 lines · On 17.07.2009, at 02:15, [email protected] wrote:
From: Juan Quintela <[email protected]>
Hi
With new configure, patch should be like this.
Cool, thanks :-).
I'll put this in v3.
Alex