2015-12-07 17:23:44 +01:00
|
|
|
#include "qemu/osdep.h"
|
2016-03-15 16:58:45 +01:00
|
|
|
#include "qemu-common.h"
|
|
|
|
#include "cpu.h"
|
2008-05-04 15:11:44 +02:00
|
|
|
#include "hw/hw.h"
|
|
|
|
#include "hw/boards.h"
|
2015-09-24 02:29:37 +02:00
|
|
|
#include "qemu/error-report.h"
|
2013-06-25 19:16:07 +02:00
|
|
|
#include "sysemu/kvm.h"
|
|
|
|
#include "kvm_arm.h"
|
2014-09-12 15:06:49 +02:00
|
|
|
#include "internals.h"
|
2016-03-15 12:51:18 +01:00
|
|
|
#include "migration/cpu.h"
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static bool vfp_needed(void *opaque)
|
2008-05-04 15:11:44 +02:00
|
|
|
{
|
2013-04-19 13:24:19 +02:00
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
return arm_feature(env, ARM_FEATURE_VFP);
|
|
|
|
}
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2017-01-19 20:00:50 +01:00
|
|
|
static int get_fpscr(QEMUFile *f, void *opaque, size_t size,
|
|
|
|
VMStateField *field)
|
2013-04-19 13:24:19 +02:00
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
uint32_t val = qemu_get_be32(f);
|
|
|
|
|
|
|
|
vfp_set_fpscr(env, val);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-19 20:00:50 +01:00
|
|
|
static int put_fpscr(QEMUFile *f, void *opaque, size_t size,
|
|
|
|
VMStateField *field, QJSON *vmdesc)
|
2013-04-19 13:24:19 +02:00
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
qemu_put_be32(f, vfp_get_fpscr(env));
|
2017-01-19 20:00:50 +01:00
|
|
|
return 0;
|
2013-04-19 13:24:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateInfo vmstate_fpscr = {
|
|
|
|
.name = "fpscr",
|
|
|
|
.get = get_fpscr,
|
|
|
|
.put = put_fpscr,
|
|
|
|
};
|
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static const VMStateDescription vmstate_vfp = {
|
|
|
|
.name = "cpu/vfp",
|
2013-09-03 21:12:09 +02:00
|
|
|
.version_id = 3,
|
|
|
|
.minimum_version_id = 3,
|
2014-09-23 14:09:54 +02:00
|
|
|
.needed = vfp_needed,
|
2013-04-19 13:24:19 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2018-02-09 11:40:31 +01:00
|
|
|
/* For compatibility, store Qn out of Zn here. */
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[0].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[1].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[2].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[3].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[4].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[5].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[6].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[7].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[8].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[9].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[10].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[11].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[12].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[13].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[14].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[15].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[16].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[17].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[18].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[19].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[20].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[21].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[22].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[23].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[24].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[25].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[26].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[27].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[28].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[29].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[30].d, ARMCPU, 0, 2),
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[31].d, ARMCPU, 0, 2),
|
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
/* The xregs array is a little awkward because element 1 (FPSCR)
|
|
|
|
* requires a specific accessor, so we have to split it up in
|
|
|
|
* the vmstate:
|
|
|
|
*/
|
|
|
|
VMSTATE_UINT32(env.vfp.xregs[0], ARMCPU),
|
|
|
|
VMSTATE_UINT32_SUB_ARRAY(env.vfp.xregs, ARMCPU, 2, 14),
|
|
|
|
{
|
|
|
|
.name = "fpscr",
|
|
|
|
.version_id = 0,
|
|
|
|
.size = sizeof(uint32_t),
|
|
|
|
.info = &vmstate_fpscr,
|
|
|
|
.flags = VMS_SINGLE,
|
|
|
|
.offset = 0,
|
|
|
|
},
|
2013-04-19 13:24:19 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
2008-05-04 15:11:44 +02:00
|
|
|
}
|
2013-04-19 13:24:19 +02:00
|
|
|
};
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static bool iwmmxt_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
return arm_feature(env, ARM_FEATURE_IWMMXT);
|
|
|
|
}
|
2009-07-30 14:33:47 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static const VMStateDescription vmstate_iwmmxt = {
|
|
|
|
.name = "cpu/iwmmxt",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2014-09-23 14:09:54 +02:00
|
|
|
.needed = iwmmxt_needed,
|
2013-04-19 13:24:19 +02:00
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT64_ARRAY(env.iwmmxt.regs, ARMCPU, 16),
|
|
|
|
VMSTATE_UINT32_ARRAY(env.iwmmxt.cregs, ARMCPU, 16),
|
|
|
|
VMSTATE_END_OF_LIST()
|
2009-07-30 14:33:47 +02:00
|
|
|
}
|
2013-04-19 13:24:19 +02:00
|
|
|
};
|
|
|
|
|
2018-01-23 04:53:47 +01:00
|
|
|
#ifdef TARGET_AARCH64
|
|
|
|
/* The expression ARM_MAX_VQ - 2 is 0 for pure AArch32 build,
|
|
|
|
* and ARMPredicateReg is actively empty. This triggers errors
|
|
|
|
* in the expansion of the VMSTATE macros.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool sve_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
return arm_feature(env, ARM_FEATURE_SVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The first two words of each Zreg is stored in VFP state. */
|
|
|
|
static const VMStateDescription vmstate_zreg_hi_reg = {
|
|
|
|
.name = "cpu/sve/zreg_hi",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT64_SUB_ARRAY(d, ARMVectorReg, 2, ARM_MAX_VQ - 2),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_preg_reg = {
|
|
|
|
.name = "cpu/sve/preg",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT64_ARRAY(p, ARMPredicateReg, 2 * ARM_MAX_VQ / 8),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_sve = {
|
|
|
|
.name = "cpu/sve",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = sve_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_STRUCT_ARRAY(env.vfp.zregs, ARMCPU, 32, 0,
|
|
|
|
vmstate_zreg_hi_reg, ARMVectorReg),
|
|
|
|
VMSTATE_STRUCT_ARRAY(env.vfp.pregs, ARMCPU, 17, 0,
|
|
|
|
vmstate_preg_reg, ARMPredicateReg),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif /* AARCH64 */
|
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static bool m_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
return arm_feature(env, ARM_FEATURE_M);
|
2008-05-04 15:11:44 +02:00
|
|
|
}
|
|
|
|
|
2017-09-04 16:21:52 +02:00
|
|
|
static const VMStateDescription vmstate_m_faultmask_primask = {
|
|
|
|
.name = "cpu/m/faultmask-primask",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.faultmask[M_REG_NS], ARMCPU),
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU),
|
2017-09-04 16:21:52 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-15 19:29:37 +01:00
|
|
|
/* CSSELR is in a subsection because we didn't implement it previously.
|
|
|
|
* Migration from an old implementation will leave it at zero, which
|
|
|
|
* is OK since the only CPUs in the old implementation make the
|
|
|
|
* register RAZ/WI.
|
|
|
|
* Since there was no version of QEMU which implemented the CSSELR for
|
|
|
|
* just non-secure, we transfer both banks here rather than putting
|
|
|
|
* the secure banked version in the m-security subsection.
|
|
|
|
*/
|
|
|
|
static bool csselr_vmstate_validate(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
|
|
|
return cpu->env.v7m.csselr[M_REG_NS] <= R_V7M_CSSELR_INDEX_MASK
|
|
|
|
&& cpu->env.v7m.csselr[M_REG_S] <= R_V7M_CSSELR_INDEX_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool m_csselr_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
|
|
|
return !arm_v7m_csselr_razwi(cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_m_csselr = {
|
|
|
|
.name = "cpu/m/csselr",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = m_csselr_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS),
|
|
|
|
VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-15 19:29:37 +01:00
|
|
|
static const VMStateDescription vmstate_m_scr = {
|
|
|
|
.name = "cpu/m/scr",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-15 19:29:37 +01:00
|
|
|
static const VMStateDescription vmstate_m_other_sp = {
|
|
|
|
.name = "cpu/m/other-sp",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32(env.v7m.other_sp, ARMCPU),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-15 19:29:38 +01:00
|
|
|
static bool m_v8m_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
return arm_feature(env, ARM_FEATURE_M) && arm_feature(env, ARM_FEATURE_V8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_m_v8m = {
|
|
|
|
.name = "cpu/m/v8m",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = m_v8m_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32_ARRAY(env.v7m.msplim, ARMCPU, M_REG_NUM_BANKS),
|
|
|
|
VMSTATE_UINT32_ARRAY(env.v7m.psplim, ARMCPU, M_REG_NUM_BANKS),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-16 19:07:55 +01:00
|
|
|
static const VMStateDescription vmstate_m = {
|
2013-04-19 13:24:19 +02:00
|
|
|
.name = "cpu/m",
|
2017-06-02 12:51:48 +02:00
|
|
|
.version_id = 4,
|
|
|
|
.minimum_version_id = 4,
|
2014-09-23 14:09:54 +02:00
|
|
|
.needed = m_needed,
|
2013-04-19 13:24:19 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.vecbase[M_REG_NS], ARMCPU),
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.basepri[M_REG_NS], ARMCPU),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.control[M_REG_NS], ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.ccr[M_REG_NS], ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.cfsr[M_REG_NS], ARMCPU),
|
armv7m: add state for v7M CCR, CFSR, HFSR, DFSR, MMFAR, BFAR
Add the structure fields, VMState fields, reset code and macros for
the v7M system control registers CCR, CFSR, HFSR, DFSR, MMFAR and
BFAR.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1485285380-10565-4-git-send-email-peter.maydell@linaro.org
2017-01-27 16:20:23 +01:00
|
|
|
VMSTATE_UINT32(env.v7m.hfsr, ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.v7m.dfsr, ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.mmfar[M_REG_NS], ARMCPU),
|
armv7m: add state for v7M CCR, CFSR, HFSR, DFSR, MMFAR, BFAR
Add the structure fields, VMState fields, reset code and macros for
the v7M system control registers CCR, CFSR, HFSR, DFSR, MMFAR and
BFAR.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 1485285380-10565-4-git-send-email-peter.maydell@linaro.org
2017-01-27 16:20:23 +01:00
|
|
|
VMSTATE_UINT32(env.v7m.bfar, ARMCPU),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_NS], ARMCPU),
|
2013-04-19 13:24:19 +02:00
|
|
|
VMSTATE_INT32(env.v7m.exception, ARMCPU),
|
|
|
|
VMSTATE_END_OF_LIST()
|
2017-09-04 16:21:52 +02:00
|
|
|
},
|
|
|
|
.subsections = (const VMStateDescription*[]) {
|
|
|
|
&vmstate_m_faultmask_primask,
|
2018-02-15 19:29:37 +01:00
|
|
|
&vmstate_m_csselr,
|
2018-02-15 19:29:37 +01:00
|
|
|
&vmstate_m_scr,
|
2018-02-15 19:29:37 +01:00
|
|
|
&vmstate_m_other_sp,
|
2018-02-15 19:29:38 +01:00
|
|
|
&vmstate_m_v8m,
|
2017-09-04 16:21:52 +02:00
|
|
|
NULL
|
2013-04-19 13:24:19 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool thumb2ee_needed(void *opaque)
|
2008-05-04 15:11:44 +02:00
|
|
|
{
|
2013-04-19 13:24:19 +02:00
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
return arm_feature(env, ARM_FEATURE_THUMB2EE);
|
|
|
|
}
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static const VMStateDescription vmstate_thumb2ee = {
|
|
|
|
.name = "cpu/thumb2ee",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2014-09-23 14:09:54 +02:00
|
|
|
.needed = thumb2ee_needed,
|
2013-04-19 13:24:19 +02:00
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32(env.teecr, ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.teehbr, ARMCPU),
|
|
|
|
VMSTATE_END_OF_LIST()
|
2008-05-04 15:11:44 +02:00
|
|
|
}
|
2013-04-19 13:24:19 +02:00
|
|
|
};
|
|
|
|
|
2015-06-19 15:17:44 +02:00
|
|
|
static bool pmsav7_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
2017-06-02 12:51:47 +02:00
|
|
|
return arm_feature(env, ARM_FEATURE_PMSA) &&
|
2017-09-07 14:54:51 +02:00
|
|
|
arm_feature(env, ARM_FEATURE_V7) &&
|
|
|
|
!arm_feature(env, ARM_FEATURE_V8);
|
2015-06-19 15:17:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
2017-09-07 14:54:53 +02:00
|
|
|
return cpu->env.pmsav7.rnr[M_REG_NS] < cpu->pmsav7_dregion;
|
2015-06-19 15:17:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_pmsav7 = {
|
|
|
|
.name = "cpu/pmsav7",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = pmsav7_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav7.drbar, ARMCPU, pmsav7_dregion, 0,
|
|
|
|
vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav7.drsr, ARMCPU, pmsav7_dregion, 0,
|
|
|
|
vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav7.dracr, ARMCPU, pmsav7_dregion, 0,
|
|
|
|
vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_VALIDATE("rgnr is valid", pmsav7_rgnr_vmstate_validate),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-27 12:59:10 +02:00
|
|
|
static bool pmsav7_rnr_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
/* For R profile cores pmsav7.rnr is migrated via the cpreg
|
|
|
|
* "RGNR" definition in helper.h. For M profile we have to
|
|
|
|
* migrate it separately.
|
|
|
|
*/
|
|
|
|
return arm_feature(env, ARM_FEATURE_M);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_pmsav7_rnr = {
|
|
|
|
.name = "cpu/pmsav7-rnr",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = pmsav7_rnr_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.pmsav7.rnr[M_REG_NS], ARMCPU),
|
2017-07-27 12:59:10 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-09-07 14:54:51 +02:00
|
|
|
static bool pmsav8_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
return arm_feature(env, ARM_FEATURE_PMSA) &&
|
|
|
|
arm_feature(env, ARM_FEATURE_V8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_pmsav8 = {
|
|
|
|
.name = "cpu/pmsav8",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = pmsav8_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav8.rbar[M_REG_NS], ARMCPU, pmsav7_dregion,
|
|
|
|
0, vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_NS], ARMCPU, pmsav7_dregion,
|
|
|
|
0, vmstate_info_uint32, uint32_t),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.pmsav8.mair0[M_REG_NS], ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.pmsav8.mair1[M_REG_NS], ARMCPU),
|
2017-09-07 14:54:51 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-09-07 14:54:53 +02:00
|
|
|
static bool s_rnr_vmstate_validate(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
|
|
|
return cpu->env.pmsav7.rnr[M_REG_S] < cpu->pmsav7_dregion;
|
|
|
|
}
|
|
|
|
|
2017-10-06 17:46:49 +02:00
|
|
|
static bool sau_rnr_vmstate_validate(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
|
|
|
return cpu->env.sau.rnr < cpu->sau_sregion;
|
|
|
|
}
|
|
|
|
|
2017-09-07 14:54:52 +02:00
|
|
|
static bool m_security_needed(void *opaque)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
|
|
|
|
return arm_feature(env, ARM_FEATURE_M_SECURITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_m_security = {
|
|
|
|
.name = "cpu/m-security",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = m_security_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32(env.v7m.secure, ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.other_ss_msp, ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.v7m.other_ss_psp, ARMCPU),
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.basepri[M_REG_S], ARMCPU),
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.primask[M_REG_S], ARMCPU),
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.faultmask[M_REG_S], ARMCPU),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.control[M_REG_S], ARMCPU),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.vecbase[M_REG_S], ARMCPU),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.pmsav8.mair0[M_REG_S], ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.pmsav8.mair1[M_REG_S], ARMCPU),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav8.rbar[M_REG_S], ARMCPU, pmsav7_dregion,
|
|
|
|
0, vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_S], ARMCPU, pmsav7_dregion,
|
|
|
|
0, vmstate_info_uint32, uint32_t),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.pmsav7.rnr[M_REG_S], ARMCPU),
|
|
|
|
VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate),
|
2017-09-07 14:54:53 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.mmfar[M_REG_S], ARMCPU),
|
2017-09-07 14:54:54 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.cfsr[M_REG_S], ARMCPU),
|
2017-10-06 17:46:48 +02:00
|
|
|
VMSTATE_UINT32(env.v7m.sfsr, ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.v7m.sfar, ARMCPU),
|
2017-10-06 17:46:49 +02:00
|
|
|
VMSTATE_VARRAY_UINT32(env.sau.rbar, ARMCPU, sau_sregion, 0,
|
|
|
|
vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_VARRAY_UINT32(env.sau.rlar, ARMCPU, sau_sregion, 0,
|
|
|
|
vmstate_info_uint32, uint32_t),
|
|
|
|
VMSTATE_UINT32(env.sau.rnr, ARMCPU),
|
|
|
|
VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
|
|
|
|
VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
|
2018-02-15 19:29:37 +01:00
|
|
|
VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU),
|
2018-02-15 19:29:37 +01:00
|
|
|
/* AIRCR is not secure-only, but our implementation is R/O if the
|
|
|
|
* security extension is unimplemented, so we migrate it here.
|
|
|
|
*/
|
|
|
|
VMSTATE_UINT32(env.v7m.aircr, ARMCPU),
|
2017-09-07 14:54:52 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-19 20:00:50 +01:00
|
|
|
static int get_cpsr(QEMUFile *f, void *opaque, size_t size,
|
|
|
|
VMStateField *field)
|
2013-04-19 13:24:19 +02:00
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
|
|
|
uint32_t val = qemu_get_be32(f);
|
|
|
|
|
2017-09-04 16:21:52 +02:00
|
|
|
if (arm_feature(env, ARM_FEATURE_M)) {
|
2017-09-04 16:21:52 +02:00
|
|
|
if (val & XPSR_EXCP) {
|
|
|
|
/* This is a CPSR format value from an older QEMU. (We can tell
|
|
|
|
* because values transferred in XPSR format always have zero
|
|
|
|
* for the EXCP field, and CPSR format will always have bit 4
|
|
|
|
* set in CPSR_M.) Rearrange it into XPSR format. The significant
|
|
|
|
* differences are that the T bit is not in the same place, the
|
|
|
|
* primask/faultmask info may be in the CPSR I and F bits, and
|
|
|
|
* we do not want the mode bits.
|
2017-09-07 14:54:52 +02:00
|
|
|
* We know that this cleanup happened before v8M, so there
|
|
|
|
* is no complication with banked primask/faultmask.
|
2017-09-04 16:21:52 +02:00
|
|
|
*/
|
|
|
|
uint32_t newval = val;
|
|
|
|
|
2017-09-07 14:54:52 +02:00
|
|
|
assert(!arm_feature(env, ARM_FEATURE_M_SECURITY));
|
|
|
|
|
2017-09-04 16:21:52 +02:00
|
|
|
newval &= (CPSR_NZCV | CPSR_Q | CPSR_IT | CPSR_GE);
|
|
|
|
if (val & CPSR_T) {
|
|
|
|
newval |= XPSR_T;
|
|
|
|
}
|
|
|
|
/* If the I or F bits are set then this is a migration from
|
|
|
|
* an old QEMU which still stored the M profile FAULTMASK
|
|
|
|
* and PRIMASK in env->daif. For a new QEMU, the data is
|
|
|
|
* transferred using the vmstate_m_faultmask_primask subsection.
|
|
|
|
*/
|
|
|
|
if (val & CPSR_F) {
|
2017-09-07 14:54:52 +02:00
|
|
|
env->v7m.faultmask[M_REG_NS] = 1;
|
2017-09-04 16:21:52 +02:00
|
|
|
}
|
|
|
|
if (val & CPSR_I) {
|
2017-09-07 14:54:52 +02:00
|
|
|
env->v7m.primask[M_REG_NS] = 1;
|
2017-09-04 16:21:52 +02:00
|
|
|
}
|
|
|
|
val = newval;
|
2017-09-04 16:21:52 +02:00
|
|
|
}
|
2017-09-04 16:21:52 +02:00
|
|
|
/* Ignore the low bits, they are handled by vmstate_m. */
|
|
|
|
xpsr_write(env, val, ~XPSR_EXCP);
|
|
|
|
return 0;
|
2017-09-04 16:21:52 +02:00
|
|
|
}
|
|
|
|
|
2014-12-11 13:07:53 +01:00
|
|
|
env->aarch64 = ((val & PSTATE_nRW) == 0);
|
|
|
|
|
|
|
|
if (is_a64(env)) {
|
|
|
|
pstate_write(env, val);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:36:43 +01:00
|
|
|
cpsr_write(env, val, 0xffffffff, CPSRWriteRaw);
|
2013-04-19 13:24:19 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2017-01-19 20:00:50 +01:00
|
|
|
static int put_cpsr(QEMUFile *f, void *opaque, size_t size,
|
|
|
|
VMStateField *field, QJSON *vmdesc)
|
2013-04-19 13:24:19 +02:00
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUARMState *env = &cpu->env;
|
2014-12-11 13:07:53 +01:00
|
|
|
uint32_t val;
|
|
|
|
|
2017-09-04 16:21:52 +02:00
|
|
|
if (arm_feature(env, ARM_FEATURE_M)) {
|
|
|
|
/* The low 9 bits are v7m.exception, which is handled by vmstate_m. */
|
|
|
|
val = xpsr_read(env) & ~XPSR_EXCP;
|
|
|
|
} else if (is_a64(env)) {
|
2014-12-11 13:07:53 +01:00
|
|
|
val = pstate_read(env);
|
|
|
|
} else {
|
|
|
|
val = cpsr_read(env);
|
|
|
|
}
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2014-12-11 13:07:53 +01:00
|
|
|
qemu_put_be32(f, val);
|
2017-01-19 20:00:50 +01:00
|
|
|
return 0;
|
2013-04-19 13:24:19 +02:00
|
|
|
}
|
2008-05-04 15:11:44 +02:00
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
static const VMStateInfo vmstate_cpsr = {
|
|
|
|
.name = "cpsr",
|
|
|
|
.get = get_cpsr,
|
|
|
|
.put = put_cpsr,
|
|
|
|
};
|
|
|
|
|
2017-02-23 19:29:23 +01:00
|
|
|
static int get_power(QEMUFile *f, void *opaque, size_t size,
|
|
|
|
VMStateField *field)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
bool powered_off = qemu_get_byte(f);
|
|
|
|
cpu->power_state = powered_off ? PSCI_OFF : PSCI_ON;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int put_power(QEMUFile *f, void *opaque, size_t size,
|
|
|
|
VMStateField *field, QJSON *vmdesc)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
|
|
|
/* Migration should never happen while we transition power states */
|
|
|
|
|
|
|
|
if (cpu->power_state == PSCI_ON ||
|
|
|
|
cpu->power_state == PSCI_OFF) {
|
|
|
|
bool powered_off = (cpu->power_state == PSCI_OFF) ? true : false;
|
|
|
|
qemu_put_byte(f, powered_off);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateInfo vmstate_powered_off = {
|
|
|
|
.name = "powered_off",
|
|
|
|
.get = get_power,
|
|
|
|
.put = put_power,
|
|
|
|
};
|
|
|
|
|
2017-09-25 13:29:12 +02:00
|
|
|
static int cpu_pre_save(void *opaque)
|
2013-06-25 19:16:07 +02:00
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
|
2013-06-25 19:16:07 +02:00
|
|
|
if (kvm_enabled()) {
|
|
|
|
if (!write_kvmstate_to_list(cpu)) {
|
|
|
|
/* This should never fail */
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!write_cpustate_to_list(cpu)) {
|
|
|
|
/* This should never fail. */
|
|
|
|
abort();
|
|
|
|
}
|
2013-06-25 19:16:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cpu->cpreg_vmstate_array_len = cpu->cpreg_array_len;
|
|
|
|
memcpy(cpu->cpreg_vmstate_indexes, cpu->cpreg_indexes,
|
|
|
|
cpu->cpreg_array_len * sizeof(uint64_t));
|
|
|
|
memcpy(cpu->cpreg_vmstate_values, cpu->cpreg_values,
|
|
|
|
cpu->cpreg_array_len * sizeof(uint64_t));
|
2017-09-25 13:29:12 +02:00
|
|
|
|
|
|
|
return 0;
|
2013-06-25 19:16:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cpu_post_load(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
int i, v;
|
|
|
|
|
|
|
|
/* Update the values list from the incoming migration data.
|
|
|
|
* Anything in the incoming data which we don't know about is
|
|
|
|
* a migration failure; anything we know about but the incoming
|
|
|
|
* data doesn't specify retains its current (reset) value.
|
|
|
|
* The indexes list remains untouched -- we only inspect the
|
|
|
|
* incoming migration index list so we can match the values array
|
|
|
|
* entries with the right slots in our own values array.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 0, v = 0; i < cpu->cpreg_array_len
|
|
|
|
&& v < cpu->cpreg_vmstate_array_len; i++) {
|
|
|
|
if (cpu->cpreg_vmstate_indexes[v] > cpu->cpreg_indexes[i]) {
|
|
|
|
/* register in our list but not incoming : skip it */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) {
|
|
|
|
/* register in their list but not ours: fail migration */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* matching register, copy the value over */
|
|
|
|
cpu->cpreg_values[i] = cpu->cpreg_vmstate_values[v];
|
|
|
|
v++;
|
|
|
|
}
|
|
|
|
|
2013-06-25 19:16:07 +02:00
|
|
|
if (kvm_enabled()) {
|
2015-07-21 12:18:45 +02:00
|
|
|
if (!write_list_to_kvmstate(cpu, KVM_PUT_FULL_STATE)) {
|
2013-06-25 19:16:07 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Note that it's OK for the TCG side not to know about
|
|
|
|
* every register in the list; KVM is authoritative if
|
|
|
|
* we're using it.
|
|
|
|
*/
|
|
|
|
write_list_to_cpustate(cpu);
|
|
|
|
} else {
|
|
|
|
if (!write_list_to_cpustate(cpu)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-06-25 19:16:07 +02:00
|
|
|
}
|
|
|
|
|
2014-09-29 19:48:46 +02:00
|
|
|
hw_breakpoint_update_all(cpu);
|
2014-09-12 15:06:49 +02:00
|
|
|
hw_watchpoint_update_all(cpu);
|
|
|
|
|
2013-06-25 19:16:07 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-19 13:24:19 +02:00
|
|
|
const VMStateDescription vmstate_arm_cpu = {
|
|
|
|
.name = "cpu",
|
2014-12-11 13:07:53 +01:00
|
|
|
.version_id = 22,
|
|
|
|
.minimum_version_id = 22,
|
2013-06-25 19:16:07 +02:00
|
|
|
.pre_save = cpu_pre_save,
|
|
|
|
.post_load = cpu_post_load,
|
2013-04-19 13:24:19 +02:00
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16),
|
2014-12-11 13:07:53 +01:00
|
|
|
VMSTATE_UINT64_ARRAY(env.xregs, ARMCPU, 32),
|
|
|
|
VMSTATE_UINT64(env.pc, ARMCPU),
|
2013-04-19 13:24:19 +02:00
|
|
|
{
|
|
|
|
.name = "cpsr",
|
|
|
|
.version_id = 0,
|
|
|
|
.size = sizeof(uint32_t),
|
|
|
|
.info = &vmstate_cpsr,
|
|
|
|
.flags = VMS_SINGLE,
|
|
|
|
.offset = 0,
|
|
|
|
},
|
|
|
|
VMSTATE_UINT32(env.spsr, ARMCPU),
|
2014-05-27 18:09:52 +02:00
|
|
|
VMSTATE_UINT64_ARRAY(env.banked_spsr, ARMCPU, 8),
|
2014-10-24 13:19:14 +02:00
|
|
|
VMSTATE_UINT32_ARRAY(env.banked_r13, ARMCPU, 8),
|
|
|
|
VMSTATE_UINT32_ARRAY(env.banked_r14, ARMCPU, 8),
|
2013-04-19 13:24:19 +02:00
|
|
|
VMSTATE_UINT32_ARRAY(env.usr_regs, ARMCPU, 5),
|
|
|
|
VMSTATE_UINT32_ARRAY(env.fiq_regs, ARMCPU, 5),
|
2014-05-27 18:09:52 +02:00
|
|
|
VMSTATE_UINT64_ARRAY(env.elr_el, ARMCPU, 4),
|
2014-05-27 18:09:52 +02:00
|
|
|
VMSTATE_UINT64_ARRAY(env.sp_el, ARMCPU, 4),
|
2013-06-25 19:16:07 +02:00
|
|
|
/* The length-check must come before the arrays to avoid
|
|
|
|
* incoming data possibly overflowing the array.
|
|
|
|
*/
|
2014-04-03 18:52:21 +02:00
|
|
|
VMSTATE_INT32_POSITIVE_LE(cpreg_vmstate_array_len, ARMCPU),
|
2013-06-25 19:16:07 +02:00
|
|
|
VMSTATE_VARRAY_INT32(cpreg_vmstate_indexes, ARMCPU,
|
|
|
|
cpreg_vmstate_array_len,
|
|
|
|
0, vmstate_info_uint64, uint64_t),
|
|
|
|
VMSTATE_VARRAY_INT32(cpreg_vmstate_values, ARMCPU,
|
|
|
|
cpreg_vmstate_array_len,
|
|
|
|
0, vmstate_info_uint64, uint64_t),
|
2014-01-04 23:15:47 +01:00
|
|
|
VMSTATE_UINT64(env.exclusive_addr, ARMCPU),
|
|
|
|
VMSTATE_UINT64(env.exclusive_val, ARMCPU),
|
|
|
|
VMSTATE_UINT64(env.exclusive_high, ARMCPU),
|
2013-04-19 13:24:19 +02:00
|
|
|
VMSTATE_UINT64(env.features, ARMCPU),
|
target-arm: Define exception record for AArch64 exceptions
For AArch32 exceptions, the only information provided about
the cause of an exception is the individual exception type (data
abort, undef, etc), which we store in cs->exception_index. For
AArch64, the CPU provides much more detail about the cause of
the exception, which can be found in the syndrome register.
Create a set of fields in CPUARMState which must be filled in
whenever an exception is raised, so that exception entry can
correctly fill in the syndrome register for the guest.
This includes the information which in AArch32 appears in
the DFAR and IFAR (fault address registers) and the DFSR
and IFSR (fault status registers) for data aborts and
prefetch aborts, since if we end up taking the MMU fault
to AArch64 rather than AArch32 this will need to end up
in different system registers.
This patch does a refactoring which moves the setting of the
AArch32 DFAR/DFSR/IFAR/IFSR from the point where the exception
is raised to the point where it is taken. (This is no change
for cores with an MMU, retains the existing clearly incorrect
behaviour for ARM946 of trashing the MP access permissions
registers which share the c5_data and c5_insn state fields,
and has no effect for v7M because we don't implement its
MPU fault status or address registers.)
As a side effect of the cleanup we fix a bug in the AArch64
linux-user mode code where we were passing a 64 bit fault
address through the 32 bit c6_data/c6_insn fields: it now
goes via the always-64-bit exception.vaddress.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
2014-04-15 20:18:38 +02:00
|
|
|
VMSTATE_UINT32(env.exception.syndrome, ARMCPU),
|
|
|
|
VMSTATE_UINT32(env.exception.fsr, ARMCPU),
|
|
|
|
VMSTATE_UINT64(env.exception.vaddress, ARMCPU),
|
2015-01-08 10:18:59 +01:00
|
|
|
VMSTATE_TIMER_PTR(gt_timer[GTIMER_PHYS], ARMCPU),
|
|
|
|
VMSTATE_TIMER_PTR(gt_timer[GTIMER_VIRT], ARMCPU),
|
2017-02-23 19:29:23 +01:00
|
|
|
{
|
|
|
|
.name = "power_state",
|
|
|
|
.version_id = 0,
|
|
|
|
.size = sizeof(bool),
|
|
|
|
.info = &vmstate_powered_off,
|
|
|
|
.flags = VMS_SINGLE,
|
|
|
|
.offset = 0,
|
|
|
|
},
|
2013-04-19 13:24:19 +02:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
2014-09-23 14:09:54 +02:00
|
|
|
.subsections = (const VMStateDescription*[]) {
|
|
|
|
&vmstate_vfp,
|
|
|
|
&vmstate_iwmmxt,
|
|
|
|
&vmstate_m,
|
|
|
|
&vmstate_thumb2ee,
|
2017-07-27 12:59:10 +02:00
|
|
|
/* pmsav7_rnr must come before pmsav7 so that we have the
|
|
|
|
* region number before we test it in the VMSTATE_VALIDATE
|
|
|
|
* in vmstate_pmsav7.
|
|
|
|
*/
|
|
|
|
&vmstate_pmsav7_rnr,
|
2015-06-19 15:17:44 +02:00
|
|
|
&vmstate_pmsav7,
|
2017-09-07 14:54:51 +02:00
|
|
|
&vmstate_pmsav8,
|
2017-09-07 14:54:52 +02:00
|
|
|
&vmstate_m_security,
|
2018-01-23 04:53:47 +01:00
|
|
|
#ifdef TARGET_AARCH64
|
|
|
|
&vmstate_sve,
|
|
|
|
#endif
|
2014-09-23 14:09:54 +02:00
|
|
|
NULL
|
2009-07-30 14:33:47 +02:00
|
|
|
}
|
2013-04-19 13:24:19 +02:00
|
|
|
};
|