On 28 June 2013 13:11, Mian M. Hamayun <m.hamayun@xxxxxxxxxxxxxxxxxxxxxx> wrote: > From: "Mian M. Hamayun" <m.hamayun@xxxxxxxxxxxxxxxxxxxxxx> > > The init function tries to initialize with Foundation models first and on > failure retries initializing on Fast Models. > > Get and Put Registers deal with the basic state of Aarch64 CPUs for the moment. > > Signed-off-by: Mian M. Hamayun <m.hamayun@xxxxxxxxxxxxxxxxxxxxxx> > --- > linux-headers/linux/kvm.h | 1 + > target-arm/cpu.c | 8 +++ > target-arm/cpu.h | 1 + > target-arm/kvm.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 130 insertions(+) > > diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h > index c614070..4df5292 100644 > --- a/linux-headers/linux/kvm.h > +++ b/linux-headers/linux/kvm.h > @@ -783,6 +783,7 @@ struct kvm_dirty_tlb { > #define KVM_REG_IA64 0x3000000000000000ULL > #define KVM_REG_ARM 0x4000000000000000ULL > #define KVM_REG_S390 0x5000000000000000ULL > +#define KVM_REG_ARM64 0x6000000000000000ULL > > #define KVM_REG_SIZE_SHIFT 52 > #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL > diff --git a/target-arm/cpu.c b/target-arm/cpu.c > index 496a59f..34eba77 100644 > --- a/target-arm/cpu.c > +++ b/target-arm/cpu.c > @@ -601,6 +601,13 @@ static void cortex_a15_initfn(Object *obj) > define_arm_cp_regs(cpu, cortexa15_cp_reginfo); > } > > +static void cortex_a57_initfn(Object *obj) > +{ > + ARMCPU *cpu = ARM_CPU(obj); > + set_feature(&cpu->env, ARM_FEATURE_V8); > + cpu->env.aarch64 = 1; /* We force 64-bit mode for guests */ This is definitely in the wrong place. cpu reset for 64 bit CPUs should start them off in AArch64. > +} > + > static void ti925t_initfn(Object *obj) > { > ARMCPU *cpu = ARM_CPU(obj); > @@ -781,6 +788,7 @@ static const ARMCPUInfo arm_cpus[] = { > { .name = "cortex-a8", .initfn = cortex_a8_initfn }, > { .name = "cortex-a9", .initfn = cortex_a9_initfn }, > { .name = "cortex-a15", .initfn = cortex_a15_initfn }, > + { .name = "cortex-a57", .initfn = cortex_a57_initfn }, > { .name = "ti925t", .initfn = ti925t_initfn }, > { .name = "sa1100", .initfn = sa1100_initfn }, > { .name = "sa1110", .initfn = sa1110_initfn }, > diff --git a/target-arm/cpu.h b/target-arm/cpu.h > index cd42814..f1cae7f 100644 > --- a/target-arm/cpu.h > +++ b/target-arm/cpu.h > @@ -410,6 +410,7 @@ enum arm_features { > ARM_FEATURE_V6, > ARM_FEATURE_V6K, > ARM_FEATURE_V7, > + ARM_FEATURE_V8, > ARM_FEATURE_THUMB2, > ARM_FEATURE_MPU, /* Only has Memory Protection Unit, not full MMU. */ > ARM_FEATURE_VFP3, > diff --git a/target-arm/kvm.c b/target-arm/kvm.c > index 27dcab9..0125f16 100644 > --- a/target-arm/kvm.c > +++ b/target-arm/kvm.c > @@ -23,6 +23,11 @@ > #include "cpu.h" > #include "hw/arm/arm.h" > > +#ifdef TARGET_AARCH64 > +#define AARCH64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ > + KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) > +#endif > + > const KVMCapabilityInfo kvm_arch_required_capabilities[] = { > KVM_CAP_LAST_INFO > }; > @@ -41,6 +46,28 @@ unsigned long kvm_arch_vcpu_id(CPUState *cpu) > return cpu->cpu_index; > } > > +#ifdef TARGET_AARCH64 > +int kvm_arch_init_vcpu(CPUState *cs) > +{ > + struct kvm_vcpu_init init; > + int ret; > + > + /* Try initializing with Foundation Models */ > + init.target = KVM_ARM_TARGET_FOUNDATION_V8; > + memset(init.features, 0, sizeof(init.features)); > + ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init); > + if (ret) { > + /* Retry initializing with Fast Models */ > + init.target = KVM_ARM_TARGET_AEM_V8; If we're emulating an A57 we should be asking KVM for an A57 guest. If we're asking KVM for "a CPU like the one in the Foundation model" we need to support that via -cpu $something. But I'm a bit dubious about that anyway -- you need to provide a good justification for why KVM/QEMU should be emulating emulators and not hardware. -- PMM _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm