Am 22.02.2013 20:04, schrieb Peter Maydell: > From: Christoffer Dall <cdall@xxxxxxxxxxxxxxx> > > Add basic support for KVM on ARM architecture. > > Signed-off-by: Christoffer Dall <cdall@xxxxxxxxxxxxxxx> > [PMM: Minor tweaks and code cleanup, switch to ONE_REG] > Signed-off-by: Peter Maydell <peter.maydell@xxxxxxxxxx> > Reviewed-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> > --- > hw/arm_pic.c | 26 ++++ > target-arm/Makefile.objs | 1 + > target-arm/cpu.h | 1 + > target-arm/helper.c | 2 +- > target-arm/kvm.c | 336 ++++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 365 insertions(+), 1 deletion(-) > create mode 100644 target-arm/kvm.c > > diff --git a/hw/arm_pic.c b/hw/arm_pic.c > index ffb4d41..45ccb9f 100644 > --- a/hw/arm_pic.c > +++ b/hw/arm_pic.c > @@ -9,6 +9,7 @@ > > #include "hw.h" > #include "arm-misc.h" > +#include "sysemu/kvm.h" > > /* Input 0 is IRQ and input 1 is FIQ. */ > static void arm_pic_cpu_handler(void *opaque, int irq, int level) > @@ -34,7 +35,32 @@ static void arm_pic_cpu_handler(void *opaque, int irq, int level) > } > } > > +static void kvm_arm_pic_cpu_handler(void *opaque, int irq, int level) > +{ > +#ifdef CONFIG_KVM > + ARMCPU *armcpu = opaque; > + CPUState *cpu = CPU(armcpu); I notice this is the only place you use "armcpu", elsewhere "cpu" is used for ARMCPU and "cs" for CPUState. Andreas > + int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT; > + > + switch (irq) { > + case ARM_PIC_CPU_IRQ: > + kvm_irq |= KVM_ARM_IRQ_CPU_IRQ; > + break; > + case ARM_PIC_CPU_FIQ: > + kvm_irq |= KVM_ARM_IRQ_CPU_FIQ; > + break; > + default: > + hw_error("kvm_arm_pic_cpu_handler: Bad interrupt line %d\n", irq); > + } > + kvm_irq |= cpu->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT; > + kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0); > +#endif > +} > + > qemu_irq *arm_pic_init_cpu(ARMCPU *cpu) > { > + if (kvm_enabled()) { > + return qemu_allocate_irqs(kvm_arm_pic_cpu_handler, cpu, 2); > + } > return qemu_allocate_irqs(arm_pic_cpu_handler, cpu, 2); > } > diff --git a/target-arm/Makefile.objs b/target-arm/Makefile.objs > index b6f1a9e..d89b57c 100644 > --- a/target-arm/Makefile.objs > +++ b/target-arm/Makefile.objs > @@ -1,4 +1,5 @@ > obj-y += arm-semi.o > obj-$(CONFIG_SOFTMMU) += machine.o > +obj-$(CONFIG_KVM) += kvm.o > obj-y += translate.o op_helper.o helper.o cpu.o > obj-y += neon_helper.o iwmmxt_helper.o > diff --git a/target-arm/cpu.h b/target-arm/cpu.h > index 2902ba5..c02e458 100644 > --- a/target-arm/cpu.h > +++ b/target-arm/cpu.h > @@ -237,6 +237,7 @@ void arm_translate_init(void); > void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); > int cpu_arm_exec(CPUARMState *s); > void do_interrupt(CPUARMState *); > +int bank_number(CPUARMState *env, int mode); Any chance to make this ARMCPU *cpu when exposing it globally? > void switch_mode(CPUARMState *, int); > uint32_t do_arm_semihosting(CPUARMState *env); > > diff --git a/target-arm/helper.c b/target-arm/helper.c > index e63da57..0380cb1 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -1617,7 +1617,7 @@ uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode) > #else > > /* Map CPU modes onto saved register banks. */ > -static inline int bank_number(CPUARMState *env, int mode) > +int bank_number(CPUARMState *env, int mode) > { > switch (mode) { > case ARM_CPU_MODE_USR: > diff --git a/target-arm/kvm.c b/target-arm/kvm.c > new file mode 100644 > index 0000000..13ebfd7 > --- /dev/null > +++ b/target-arm/kvm.c > @@ -0,0 +1,336 @@ > +/* > + * ARM implementation of KVM hooks > + * > + * Copyright Christoffer Dall 2009-2010 > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + * > + */ > + > +#include <stdio.h> > +#include <sys/types.h> > +#include <sys/ioctl.h> > +#include <sys/mman.h> > + > +#include <linux/kvm.h> > + > +#include "qemu-common.h" > +#include "qemu/timer.h" > +#include "sysemu/sysemu.h" > +#include "sysemu/kvm.h" > +#include "cpu.h" > +#include "hw/arm-misc.h" > + > +const KVMCapabilityInfo kvm_arch_required_capabilities[] = { static const? > + KVM_CAP_LAST_INFO > +}; [snip] Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html