summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRahul Thakur <rjthakur@google.com>2017-03-01 10:27:05 -0800
committerRahul Thakur <rjthakur@google.com>2017-03-03 04:56:45 +0000
commitceb3bd9733d094b7c7d659ec5990fda26c2da27c (patch)
treeb3735b3735eb4e3fc314b261cea3f2896d9324ab /src
parent0fc9dcf46b98ee0e35e8ca428c1021dbbc4f67da (diff)
downloadgem5-ceb3bd9733d094b7c7d659ec5990fda26c2da27c.tar.xz
arm, kvm: enable running 32-bit Guest under ARM KVM64
1) Pass KVM_ARM_VCPU_EL1_32BIT to kvmArmVCpuInit when running 32-bit OS 2) Correctly map 64-bit registers to banked 32-bit ones Change-Id: I1dec6427d6f5c3bba599ccdd804f1dfe80d3e670 Reviewed-on: https://gem5-review.googlesource.com/2261 Maintainer: Rahul Thakur <rjthakur@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/arch/arm/kvm/armv8_cpu.cc8
-rw-r--r--src/arch/arm/kvm/base_cpu.cc3
2 files changed, 10 insertions, 1 deletions
diff --git a/src/arch/arm/kvm/armv8_cpu.cc b/src/arch/arm/kvm/armv8_cpu.cc
index 08b901123..67e2e465e 100644
--- a/src/arch/arm/kvm/armv8_cpu.cc
+++ b/src/arch/arm/kvm/armv8_cpu.cc
@@ -268,7 +268,13 @@ ArmV8KvmCPU::updateThreadContext()
for (int i = 0; i < NUM_XREGS; ++i) {
const auto value(getOneRegU64(kvmXReg(i)));
DPRINTF(KvmContext, " X%i := 0x%x\n", i, value);
- tc->setIntReg(INTREG_X0 + i, value);
+ // KVM64 returns registers in 64-bit layout. If we are in aarch32
+ // mode, we need to map these to banked ARM32 registers.
+ if (inAArch64(tc)) {
+ tc->setIntReg(INTREG_X0 + i, value);
+ } else {
+ tc->setIntRegFlat(IntReg64Map[INTREG_X0 + i], value);
+ }
}
for (const auto &ri : intRegMap) {
diff --git a/src/arch/arm/kvm/base_cpu.cc b/src/arch/arm/kvm/base_cpu.cc
index e511fd661..e25112cae 100644
--- a/src/arch/arm/kvm/base_cpu.cc
+++ b/src/arch/arm/kvm/base_cpu.cc
@@ -79,6 +79,9 @@ BaseArmKvmCPU::startup()
memset(&target_config, 0, sizeof(target_config));
vm.kvmArmPreferredTarget(target_config);
+ if (!((ArmSystem *)system)->highestELIs64()) {
+ target_config.features[0] |= (1 << KVM_ARM_VCPU_EL1_32BIT);
+ }
kvmArmVCpuInit(target_config);
}