From 99516b43a3fe265de9598ceac0efd293c587f9c6 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 10 Nov 2018 09:27:38 -0500 Subject: [PATCH] target/arm: New utility function to extract EC from syndrome Create and use a utility function to extract the EC field from a syndrome, rather than open-coding the shift. Backports commit 64b91e3f890a8c221b65c6820a5ee39107ee40f5 from qemu --- qemu/target/arm/helper.c | 4 ++-- qemu/target/arm/internals.h | 5 +++++ qemu/target/arm/op_helper.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qemu/target/arm/helper.c b/qemu/target/arm/helper.c index aa39e177..570873bc 100644 --- a/qemu/target/arm/helper.c +++ b/qemu/target/arm/helper.c @@ -7531,7 +7531,7 @@ static void arm_cpu_do_interrupt_aarch32_(CPUState *cs) uint32_t moe; /* If this is a debug exception we must update the DBGDSCR.MOE bits */ - switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) { + switch (syn_get_ec(env->exception.syndrome)) { case EC_BREAKPOINT: case EC_BREAKPOINT_SAME_EL: moe = 1; @@ -7877,7 +7877,7 @@ void arm_cpu_do_interrupt(CPUState *cs) if (qemu_loglevel_mask(CPU_LOG_INT) && !excp_is_internal(cs->exception_index)) { qemu_log_mask(CPU_LOG_INT, "...with ESR 0x%x/0x%" PRIx32 "\n", - env->exception.syndrome >> ARM_EL_EC_SHIFT, + syn_get_ec(env->exception.syndrome), env->exception.syndrome); } diff --git a/qemu/target/arm/internals.h b/qemu/target/arm/internals.h index e22ae6ad..31e7fb3d 100644 --- a/qemu/target/arm/internals.h +++ b/qemu/target/arm/internals.h @@ -280,6 +280,11 @@ enum arm_exception_class { #define ARM_EL_IL (1 << ARM_EL_IL_SHIFT) #define ARM_EL_ISV (1 << ARM_EL_ISV_SHIFT) +static inline uint32_t syn_get_ec(uint32_t syn) +{ + return syn >> ARM_EL_EC_SHIFT; +} + /* Utility functions for constructing various kinds of syndrome value. * Note that in general we follow the AArch64 syndrome values; in a * few cases the value in HSR for exceptions taken to AArch32 Hyp diff --git a/qemu/target/arm/op_helper.c b/qemu/target/arm/op_helper.c index 6b644ed6..e5a25940 100644 --- a/qemu/target/arm/op_helper.c +++ b/qemu/target/arm/op_helper.c @@ -41,7 +41,7 @@ void raise_exception(CPUARMState *env, uint32_t excp, * (see DDI0478C.a D1.10.4) */ target_el = 2; - if (syndrome >> ARM_EL_EC_SHIFT == EC_ADVSIMDFPACCESSTRAP) { + if (syn_get_ec(syndrome) == EC_ADVSIMDFPACCESSTRAP) { syndrome = syn_uncategorized(); } }