mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-23 06:25:12 +00: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. Backports commit e6ae5981ea4b0f6feb223009a5108582e7644f8f from qemu
This commit is contained in:
parent
5d6b031550
commit
9056a93c9a
|
@ -182,11 +182,6 @@ static void arm_cpu_reset(CPUState *s)
|
|||
env->v7m.secure = true;
|
||||
}
|
||||
|
||||
/* For M profile we store FAULTMASK and PRIMASK in the
|
||||
* PSTATE F and I bits; these are both clear at reset.
|
||||
*/
|
||||
env->daif &= ~(PSTATE_I | PSTATE_F);
|
||||
|
||||
/* The reset value of this bit is IMPDEF, but ARM recommends
|
||||
* that it resets to 1, so QEMU always does that rather than making
|
||||
* it dependent on CPU model.
|
||||
|
|
|
@ -424,6 +424,8 @@ typedef struct CPUARMState {
|
|||
uint32_t bfar; /* BusFault Address */
|
||||
unsigned mpu_ctrl; /* MPU_CTRL */
|
||||
int exception;
|
||||
uint32_t primask;
|
||||
uint32_t faultmask;
|
||||
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
|
||||
} v7m;
|
||||
|
||||
|
@ -2176,7 +2178,7 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)
|
|||
* we're in a HardFault or NMI handler.
|
||||
*/
|
||||
if ((env->v7m.exception > 0 && env->v7m.exception <= 3)
|
||||
|| env->daif & PSTATE_F) {
|
||||
|| env->v7m.faultmask) {
|
||||
return arm_to_core_mmu_idx(ARMMMUIdx_MNegPri);
|
||||
}
|
||||
|
||||
|
|
|
@ -5427,7 +5427,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)
|
|||
|
||||
if (env->v7m.exception != ARMV7M_EXCP_NMI) {
|
||||
/* Auto-clear FAULTMASK on return from other than NMI */
|
||||
env->daif &= ~PSTATE_F;
|
||||
env->v7m.faultmask = 0;
|
||||
}
|
||||
|
||||
// Unicorn: if'd out
|
||||
|
@ -7986,12 +7986,12 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
|
|||
return (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) ?
|
||||
env->regs[13] : env->v7m.other_sp;
|
||||
case 16: /* PRIMASK */
|
||||
return (env->daif & PSTATE_I) != 0;
|
||||
return env->v7m.primask;
|
||||
case 17: /* BASEPRI */
|
||||
case 18: /* BASEPRI_MAX */
|
||||
return env->v7m.basepri;
|
||||
case 19: /* FAULTMASK */
|
||||
return (env->daif & PSTATE_F) != 0;
|
||||
return env->v7m.faultmask;
|
||||
default:
|
||||
/* ??? For debugging only. */
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special"
|
||||
|
@ -8054,11 +8054,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
|
|||
}
|
||||
break;
|
||||
case 16: /* PRIMASK */
|
||||
if (val & 1) {
|
||||
env->daif |= PSTATE_I;
|
||||
} else {
|
||||
env->daif &= ~PSTATE_I;
|
||||
}
|
||||
env->v7m.primask = val & 1;
|
||||
break;
|
||||
case 17: /* BASEPRI */
|
||||
env->v7m.basepri = val & 0xff;
|
||||
|
@ -8069,11 +8065,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
|
|||
env->v7m.basepri = val;
|
||||
break;
|
||||
case 19: /* FAULTMASK */
|
||||
if (val & 1) {
|
||||
env->daif |= PSTATE_F;
|
||||
} else {
|
||||
env->daif &= ~PSTATE_F;
|
||||
}
|
||||
env->v7m.faultmask = val & 1;
|
||||
break;
|
||||
case 20: /* CONTROL */
|
||||
switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
|
||||
|
|
Loading…
Reference in a new issue