target-arm: Guest cpu endianness determination for virtio KVM ARM/ARM64

This patch implements a fucntion pointer "virtio_is_big_endian"
from "CPUClass" structure for arm/arm64.
Function arm_cpu_is_big_endian() is added to determine and
return the guest cpu endianness to virtio.
This is required for running cross endian guests with virtio on ARM/ARM64.

Backports commit 84f2bed3cf505f90b7918e2de32e11da27160563 from qemu
This commit is contained in:
Pranavkumar Sawargaonkar 2018-02-12 12:02:33 -05:00 committed by Lioncash
parent e3c3cccb7a
commit 30f4d72db5
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 28 additions and 0 deletions

View file

@ -272,6 +272,29 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
}
#endif
static bool arm_cpu_is_big_endian(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(NULL, cs);
CPUARMState *env = &cpu->env;
int cur_el;
// UNICORN: Commented out
//cpu_synchronize_state(cs);
/* In 32bit guest 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;
}
static inline void set_feature(CPUARMState *env, int feature)
{
env->features |= 1ULL << feature;
@ -1117,6 +1140,9 @@ static void arm_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data
#else
cc->do_interrupt = arm_cpu_do_interrupt;
cc->get_phys_page_debug = arm_cpu_get_phys_page_debug;
// UNICORN: Commented out
//cc->vmsd = &vmstate_arm_cpu;
//cc->virtio_is_big_endian = arm_cpu_is_big_endian;
#endif
cc->debug_excp_handler = arm_debug_excp_handler;
}

View file

@ -32,6 +32,8 @@
# define ELF_MACHINE EM_ARM
#endif
#define TARGET_IS_BIENDIAN 1
#define CPUArchState struct CPUARMState
#include "qemu-common.h"