mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/arm: Don't store M profile PRIMASK and FAULTMASK in daif
We currently store the M profile CPU register state PRIMASK and FAULTMASK in the daif field of the CPU state in its I and F bits. This is a legacy from the original implementation, which tried to share the cpu_exec_interrupt code between A profile and M profile. We've since separated out the two cases because they are significantly different, so now there is no common code between M and A profile which looks at env->daif: all the uses are either in A-only or M-only code paths. Sharing the state fields now is just confusing, and will make things awkward when we implement v8M, where the PRIMASK and FAULTMASK registers are banked between security states. Switch M profile over to using v7m.faultmask and v7m.primask fields for these registers. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 1501692241-23310-10-git-send-email-peter.maydell@linaro.org
This commit is contained in:
parent
987ab45e10
commit
e6ae5981ea
5 changed files with 43 additions and 21 deletions
|
@ -97,6 +97,17 @@ static bool m_needed(void *opaque)
|
|||
return arm_feature(env, ARM_FEATURE_M);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_m_faultmask_primask = {
|
||||
.name = "cpu/m/faultmask-primask",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT32(env.v7m.faultmask, ARMCPU),
|
||||
VMSTATE_UINT32(env.v7m.primask, ARMCPU),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_m = {
|
||||
.name = "cpu/m",
|
||||
.version_id = 4,
|
||||
|
@ -115,6 +126,10 @@ static const VMStateDescription vmstate_m = {
|
|||
VMSTATE_UINT32(env.v7m.mpu_ctrl, ARMCPU),
|
||||
VMSTATE_INT32(env.v7m.exception, ARMCPU),
|
||||
VMSTATE_END_OF_LIST()
|
||||
},
|
||||
.subsections = (const VMStateDescription*[]) {
|
||||
&vmstate_m_faultmask_primask,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -201,6 +216,24 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size,
|
|||
CPUARMState *env = &cpu->env;
|
||||
uint32_t val = qemu_get_be32(f);
|
||||
|
||||
if (arm_feature(env, ARM_FEATURE_M)) {
|
||||
/* 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. Set v7m.faultmask and v7m.primask
|
||||
* accordingly, and then clear the bits so they don't confuse
|
||||
* cpsr_write(). For a new QEMU, the bits here will always be
|
||||
* clear, and the data is transferred using the
|
||||
* vmstate_m_faultmask_primask subsection.
|
||||
*/
|
||||
if (val & CPSR_F) {
|
||||
env->v7m.faultmask = 1;
|
||||
}
|
||||
if (val & CPSR_I) {
|
||||
env->v7m.primask = 1;
|
||||
}
|
||||
val &= ~(CPSR_F | CPSR_I);
|
||||
}
|
||||
|
||||
env->aarch64 = ((val & PSTATE_nRW) == 0);
|
||||
|
||||
if (is_a64(env)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue