From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= Subject: Re: [PATCH v6 3/9] ARM: KVM: Add support for KVM on ARM architecture Date: Sat, 23 Feb 2013 16:14:23 +0100 Message-ID: <5128DCCF.9060105@suse.de> References: <1361559865-22168-1-git-send-email-peter.maydell@linaro.org> <1361559865-22168-4-git-send-email-peter.maydell@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Cc: Christoffer Dall , kvm@vger.kernel.org, Gleb Natapov , patches@linaro.org, Marcelo Tosatti , qemu-devel@nongnu.org, Blue Swirl , Paolo Bonzini , kvmarm@lists.cs.columbia.edu To: Peter Maydell Return-path: In-Reply-To: <1361559865-22168-4-git-send-email-peter.maydell@linaro.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org Am 22.02.2013 20:04, schrieb Peter Maydell: > From: Christoffer Dall >=20 > Add basic support for KVM on ARM architecture. >=20 > Signed-off-by: Christoffer Dall > [PMM: Minor tweaks and code cleanup, switch to ONE_REG] > Signed-off-by: Peter Maydell > Reviewed-by: Paolo Bonzini > --- > 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 >=20 > 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 @@ > =20 > #include "hw.h" > #include "arm-misc.h" > +#include "sysemu/kvm.h" > =20 > /* 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 ir= q, int level) > } > } > =20 > +static void kvm_arm_pic_cpu_handler(void *opaque, int irq, int level) > +{ > +#ifdef CONFIG_KVM > + ARMCPU *armcpu =3D opaque; > + CPUState *cpu =3D 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 =3D KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT; > + > + switch (irq) { > + case ARM_PIC_CPU_IRQ: > + kvm_irq |=3D KVM_ARM_IRQ_CPU_IRQ; > + break; > + case ARM_PIC_CPU_FIQ: > + kvm_irq |=3D KVM_ARM_IRQ_CPU_FIQ; > + break; > + default: > + hw_error("kvm_arm_pic_cpu_handler: Bad interrupt line %d\n", i= rq); > + } > + kvm_irq |=3D 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 +=3D arm-semi.o > obj-$(CONFIG_SOFTMMU) +=3D machine.o > +obj-$(CONFIG_KVM) +=3D kvm.o > obj-y +=3D translate.o op_helper.o helper.o cpu.o > obj-y +=3D 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); > =20 > 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 > =20 > /* 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 > +#include > +#include > +#include > + > +#include > + > +#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[] =3D { static const? > + KVM_CAP_LAST_INFO > +}; [snip] Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg