From 61a59665d60fd61087f24841efd9417c3a940a93 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 19 Feb 2018 01:23:19 -0500 Subject: [PATCH] target-arm: Don't report presence of EL2 if it doesn't exist We already modify the processor feature bits to not report EL3 support to the guest if EL3 isn't enabled for the CPU we're emulating. Add similar support for not reporting EL2 unless it is enabled. This is necessary because real world guest code running at EL3 (trusted firmware or bootloaders) will query the ID registers to determine whether it should start a guest Linux kernel in EL2 or EL3. Backports commit 3c2f7bb32b4c597925c5c7411307d51f1a56045d from qemu --- qemu/target-arm/cpu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qemu/target-arm/cpu.c b/qemu/target-arm/cpu.c index 1bc3ea18..b4bae8e9 100644 --- a/qemu/target-arm/cpu.c +++ b/qemu/target-arm/cpu.c @@ -530,6 +530,15 @@ static int arm_cpu_realizefn(struct uc_struct *uc, DeviceState *dev, Error **err cpu->id_aa64pfr0 &= ~0xf000; } + if (!arm_feature(env, ARM_FEATURE_EL2)) { + /* Disable the hypervisor feature bits in the processor feature + * registers if we don't have EL2. These are id_pfr1[15:12] and + * id_aa64pfr0_el1[11:8]. + */ + cpu->id_aa64pfr0 &= ~0xf00; + cpu->id_pfr1 &= ~0xf000; + } + if (!cpu->has_mpu) { unset_feature(env, ARM_FEATURE_MPU); }