From 1457b73a13f5289f20f2e6b81a555a8c9b4fc529 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Wed, 21 Feb 2018 02:10:31 -0500 Subject: [PATCH] target-arm: cpu: Move cpu_is_big_endian to header There is a CPU data endianness test that is used to drive the virtio_big_endian test. Move this up to the header so it can be more generally used for endian tests. The KVM specific cpu_syncronize_state call is left behind in the virtio specific function. Rename it arm_cpu-data_is_big_endian() to more accurately capture that this is for data accesses only. Backports commit ed50ff7875d61a75517c92deb0444d73fbbca878 from qemu --- qemu/target-arm/cpu.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qemu/target-arm/cpu.h b/qemu/target-arm/cpu.h index 94083603..434af518 100644 --- a/qemu/target-arm/cpu.h +++ b/qemu/target-arm/cpu.h @@ -2167,6 +2167,25 @@ static inline uint64_t *aa64_vfp_qreg(CPUARMState *env, unsigned regno) return &env->vfp.regs[2 * regno]; } +/* Return true if the processor is in big-endian mode. */ +static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) +{ + int cur_el; + + /* In 32bit endianness is determined by looking at CPSR's E bit */ + if (!is_a64(env)) { + return (env->uncached_cpsr & CPSR_E) ? 1 : 0; + } + + cur_el = arm_current_el(env); + + if (cur_el == 0) { + return (env->cp15.sctlr_el[1] & SCTLR_E0E) != 0; + } + + return (env->cp15.sctlr_el[cur_el] & SCTLR_EE) != 0; +} + #include "exec/exec-all.h" enum {