Received: from eggs.gnu.org ([2001:4830:134:3::10]:40567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYHdx-0003sI-5T for qemu-devel@nongnu.org; Thu, 10 Apr 2014 12:16:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYHdw-0003XO-Ey for qemu-devel@nongnu.org; Thu, 10 Apr 2014 12:16:01 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:47599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYHdw-0003O1-7Y for qemu-devel@nongnu.org; Thu, 10 Apr 2014 12:16:00 -0400 From: Peter Maydell Date: Thu, 10 Apr 2014 17:15:35 +0100 Message-Id: <1397146536-30116-37-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1397146536-30116-1-git-send-email-peter.maydell@linaro.org> References: <1397146536-30116-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v6 36/37] target-arm: Handle the CPU being in AArch32 mode in the AArch64 set_pc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite , patches@linaro.org, Alexander Graf , Greg Bellows , Laurent Desnogues , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu, Christoffer Dall , Richard Henderson The AArch64 implementation of the set_pc method needs to be updated to handle the possibility that the CPU is in AArch32 mode; otherwise there are weird crashes when doing interprocessing in system emulation mode when an interrupt occurs and we fail to resynchronize the 32-bit PC with the TB we need to execute next. Signed-off-by: Peter Maydell Reviewed-by: Alex Bennée --- target-arm/cpu64.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c index 9a0c431..c673ac2 100644 --- a/target-arm/cpu64.c +++ b/target-arm/cpu64.c @@ -172,11 +172,15 @@ static void aarch64_cpu_finalizefn(Object *obj) static void aarch64_cpu_set_pc(CPUState *cs, vaddr value) { ARMCPU *cpu = ARM_CPU(cs); - /* - * TODO: this will need updating for system emulation, - * when the core may be in AArch32 mode. + /* It's OK to look at env for the current mode here, because it's + * never possible for an AArch64 TB to chain to an AArch32 TB. + * (Otherwise we would need to use synchronize_from_tb instead.) */ - cpu->env.pc = value; + if (is_a64(&cpu->env)) { + cpu->env.pc = value; + } else { + cpu->env.regs[15] = value; + } } static void aarch64_cpu_class_init(ObjectClass *oc, void *data) -- 1.9.1