target/arm: Create new arm_v7m_mmu_idx_for_secstate_and_priv()

The TT instruction is going to need to look up the MMU index
for a specified security and privilege state. Refactor the
existing arm_v7m_mmu_idx_for_secstate() into a version that
lets you specify the privilege state and one that uses the
current state of the CPU.

Backports commit ec8e3340286a87d3924c223d60ba5c994549f796 from qemu
This commit is contained in:
Peter Maydell 2018-03-05 13:23:03 -05:00 committed by Lioncash
parent 89acdeb9af
commit c441b19d76
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -2300,14 +2300,16 @@ 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)
/* Return the MMU index for a v7M CPU in the specified security and
* privilege state
*/
static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
bool secstate,
bool priv)
{
int el = arm_current_el(env);
ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
if (el != 0) {
if (priv) {
mmu_idx |= ARM_MMU_IDX_M_PRIV;
}
@ -2325,6 +2327,15 @@ static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env,
return 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)
{
bool priv = arm_current_el(env) != 0;
return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
}
/* Determine the current mmu_idx to use for normal loads/stores */
static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)
{