From: Greg Bellows <greg.bellows@linaro.org>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org,
christoffer.dall@linaro.org
Cc: Greg Bellows <greg.bellows@linaro.org>
Subject: [Qemu-devel] [PATCH 4/5] target-arm: Add AArch32 guest support to KVM64
Date: Mon, 19 Jan 2015 16:30:20 -0600 [thread overview]
Message-ID: <1421706621-23731-5-git-send-email-greg.bellows@linaro.org> (raw)
In-Reply-To: <1421706621-23731-1-git-send-email-greg.bellows@linaro.org>
Add 32-bit to/from 64-bit register synchronization on register gets and puts.
Set EL1_32BIT feature flag passed to KVM
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
---
target-arm/kvm64.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index ba16821..0061099 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -81,8 +81,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
int ret;
ARMCPU *cpu = ARM_CPU(cs);
- if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE ||
- !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+ if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) {
fprintf(stderr, "KVM is not supported for this guest CPU type\n");
return -EINVAL;
}
@@ -96,6 +95,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
cpu->psci_version = 2;
cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2;
}
+ if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+ cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT;
+ }
/* Do KVM_ARM_VCPU_INIT ioctl */
ret = kvm_arm_vcpu_init(cs);
@@ -133,6 +135,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
+ aarch64_sync_32_to_64(env);
for (i = 0; i < 31; i++) {
reg.id = AARCH64_CORE_REG(regs.regs[i]);
reg.addr = (uintptr_t) &env->xregs[i];
@@ -162,7 +165,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)
}
/* Note that KVM thinks pstate is 64 bit but we use a uint32_t */
- val = pstate_read(env);
+ if (is_a64(env)) {
+ val = pstate_read(env);
+ } else {
+ val = cpsr_read(env);
+ }
reg.id = AARCH64_CORE_REG(regs.pstate);
reg.addr = (uintptr_t) &val;
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
@@ -218,6 +225,7 @@ int kvm_arch_get_registers(CPUState *cs)
return ret;
}
}
+ aarch64_sync_64_to_32(env);
reg.id = AARCH64_CORE_REG(regs.sp);
reg.addr = (uintptr_t) &env->sp_el[0];
@@ -239,7 +247,12 @@ int kvm_arch_get_registers(CPUState *cs)
if (ret) {
return ret;
}
- pstate_write(env, val);
+ if (is_a64(env)) {
+ pstate_write(env, val);
+ } else {
+ env->uncached_cpsr = val & CPSR_M;
+ cpsr_write(env, val, 0xffffffff);
+ }
/* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the
* QEMU side we keep the current SP in xregs[31] as well.
--
1.8.3.2
next prev parent reply other threads:[~2015-01-19 22:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 22:30 [Qemu-devel] [PATCH 0/5] target-arm: ARM64: Adding EL1 AARCH32 guest support Greg Bellows
2015-01-19 22:30 ` [Qemu-devel] [PATCH 1/5] target-arm: Add ARM CPU feature parsing Greg Bellows
2015-01-20 14:19 ` Alex Bennée
2015-01-20 14:49 ` Greg Bellows
2015-01-21 10:57 ` Alex Bennée
2015-01-20 15:22 ` Igor Mammedov
2015-01-20 15:34 ` Peter Maydell
2015-01-20 15:59 ` Igor Mammedov
2015-01-20 16:08 ` Peter Maydell
2015-01-20 16:25 ` Igor Mammedov
2015-01-20 22:45 ` Greg Bellows
2015-01-21 11:33 ` Igor Mammedov
2015-01-20 15:34 ` Greg Bellows
2015-01-20 16:02 ` Eduardo Habkost
2015-01-20 16:05 ` Igor Mammedov
2015-01-19 22:30 ` [Qemu-devel] [PATCH 2/5] target-arm: Add feature parsing to virt Greg Bellows
2015-01-20 16:58 ` Alex Bennée
2015-01-19 22:30 ` [Qemu-devel] [PATCH 3/5] target-arm: Add 32/64-bit register sync Greg Bellows
2015-01-19 22:30 ` Greg Bellows [this message]
2015-01-20 16:57 ` [Qemu-devel] [PATCH 4/5] target-arm: Add AArch32 guest support to KVM64 Alex Bennée
2015-01-20 20:03 ` Greg Bellows
2015-01-21 10:54 ` Alex Bennée
2015-01-21 10:56 ` Peter Maydell
2015-01-19 22:30 ` [Qemu-devel] [PATCH 5/5] target-arm: Adjust kernel load address for Image Greg Bellows
2015-01-20 10:21 ` [Qemu-devel] [PATCH 0/5] target-arm: ARM64: Adding EL1 AARCH32 guest support Sergey Fedorov
2015-01-20 10:26 ` 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=1421706621-23731-5-git-send-email-greg.bellows@linaro.org \
--to=greg.bellows@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).