mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 07:15:27 +00:00
target/arm: Factor out "get mmuidx for specified security state"
For the SG instruction and secure function return we are going to want to do memory accesses using the MMU index of the CPU in secure state, even though the CPU is currently in non-secure state. Write arm_v7m_mmu_idx_for_secstate() to do this job, and use it in cpu_mmu_index(). Backports commit b81ac0eb6315e602b18439961e0538538e4aed4f from qemu
This commit is contained in:
parent
6958a4763d
commit
059f238f11
|
@ -2287,26 +2287,36 @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
|
|||
}
|
||||
}
|
||||
|
||||
/* Return the MMU index for a v7M CPU in the specified security state */
|
||||
static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env,
|
||||
bool secstate)
|
||||
{
|
||||
int el = arm_current_el(env);
|
||||
ARMMMUIdx mmu_idx;
|
||||
|
||||
if (el == 0) {
|
||||
mmu_idx = secstate ? ARMMMUIdx_MSUser : ARMMMUIdx_MUser;
|
||||
} else {
|
||||
mmu_idx = secstate ? ARMMMUIdx_MSPriv : ARMMMUIdx_MPriv;
|
||||
}
|
||||
|
||||
// Unicorn: if'd out
|
||||
#if 0
|
||||
if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) {
|
||||
mmu_idx = secstate ? ARMMMUIdx_MSNegPri : ARMMMUIdx_MNegPri;
|
||||
}
|
||||
#endif
|
||||
|
||||
return mmu_idx;
|
||||
}
|
||||
|
||||
/* Determine the current mmu_idx to use for normal loads/stores */
|
||||
static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)
|
||||
{
|
||||
int el = arm_current_el(env);
|
||||
|
||||
if (arm_feature(env, ARM_FEATURE_M)) {
|
||||
ARMMMUIdx mmu_idx;
|
||||
|
||||
if (el == 0) {
|
||||
mmu_idx = env->v7m.secure ? ARMMMUIdx_MSUser : ARMMMUIdx_MUser;
|
||||
} else {
|
||||
mmu_idx = env->v7m.secure ? ARMMMUIdx_MSPriv : ARMMMUIdx_MPriv;
|
||||
}
|
||||
|
||||
// Unicorn: if'd out
|
||||
#if 0
|
||||
if (armv7m_nvic_neg_prio_requested(env->nvic, env->v7m.secure)) {
|
||||
mmu_idx = env->v7m.secure ? ARMMMUIdx_MSNegPri : ARMMMUIdx_MNegPri;
|
||||
}
|
||||
#endif
|
||||
ARMMMUIdx mmu_idx = arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure);
|
||||
|
||||
return arm_to_core_mmu_idx(mmu_idx);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue