From: Peter Maydell <peter.maydell@linaro.org>
To: "Mian M. Hamayun" <m.hamayun@virtualopensystems.com>
Cc: tech@virtualopensystems.com, qemu-devel@nongnu.org,
kvmarm@lists.cs.columbia.edu
Subject: Re: [Qemu-devel] [PATCH 3/6] Added Aarch64 CPU Initialization, Get and Put Registers Support.
Date: Sat, 29 Jun 2013 20:17:03 +0100 [thread overview]
Message-ID: <CAFEAcA8==kk-gzpppVB1O59GhCN5-x6y9-awLisHcZkJc1f=Ng@mail.gmail.com> (raw)
In-Reply-To: <1372421519-5146-3-git-send-email-m.hamayun@virtualopensystems.com>
On 28 June 2013 13:11, Mian M. Hamayun <m.hamayun@virtualopensystems.com> wrote:
> From: "Mian M. Hamayun" <m.hamayun@virtualopensystems.com>
>
> 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@virtualopensystems.com>
> ---
> 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
next prev parent reply other threads:[~2013-06-29 19:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-28 12:11 [Qemu-devel] [PATCH 1/6] Added aarch64 configure support and default configuration Mian M. Hamayun
2013-06-28 12:11 ` [Qemu-devel] [PATCH 2/6] Added KVM Headers from KVM Tool Mian M. Hamayun
2013-06-28 12:11 ` [Qemu-devel] [PATCH 3/6] Added Aarch64 CPU Initialization, Get and Put Registers Support Mian M. Hamayun
2013-06-28 12:43 ` Alexander Graf
2013-06-29 17:48 ` Mian M. Hamayun
2013-06-29 18:05 ` Alexander Graf
2013-06-29 19:17 ` Peter Maydell [this message]
2013-07-01 17:54 ` Alexander Spyridakis
2013-06-28 12:11 ` [Qemu-devel] [PATCH 4/6] Added the Versatile Express Machine Model for A57 Mian M. Hamayun
2013-06-29 19:21 ` Peter Maydell
2013-07-01 18:06 ` Alexander Spyridakis
2013-07-01 19:08 ` Peter Maydell
2013-06-28 12:11 ` [Qemu-devel] [PATCH 5/6] Added Boot Support for Aarch64 Processor Mian M. Hamayun
2013-06-28 12:11 ` [Qemu-devel] [PATCH 6/6] Added SMP for Aarch64 Processors Mian M. Hamayun
2013-06-29 19:24 ` Peter Maydell
2013-07-01 18:18 ` Alexander Spyridakis
2013-06-29 19:20 ` [Qemu-devel] [PATCH 1/6] Added aarch64 configure support and default configuration Peter Maydell
2013-07-01 18:46 ` Alexander Spyridakis
2013-07-01 19:22 ` Peter Maydell
2013-07-01 19:24 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFEAcA8==kk-gzpppVB1O59GhCN5-x6y9-awLisHcZkJc1f=Ng@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=m.hamayun@virtualopensystems.com \
--cc=qemu-devel@nongnu.org \
--cc=tech@virtualopensystems.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).