mirror of
				https://github.com/yuzu-emu/unicorn.git
				synced 2025-11-04 13:54:48 +00:00 
			
		
		
		
	target/arm: Reorganize ARMMMUIdx
Prepare for, but do not yet implement, the EL2&0 regime. This involves adding the new MMUIdx enumerators and adjusting some of the MMUIdx related predicates to match. Backports commit b9f6033c1a5fb7da55ed353794db8ec064f78bb2 from qemu.
This commit is contained in:
		
							parent
							
								
									85a7cfbdc6
								
							
						
					
					
						commit
						0318d7af99
					
				| 
						 | 
				
			
			@ -3405,6 +3405,7 @@
 | 
			
		|||
#define arm_v7m_mmu_idx_for_secstate_and_priv arm_v7m_mmu_idx_for_secstate_and_priv_aarch64
 | 
			
		||||
#define arm_hcr_el2_eff arm_hcr_el2_eff_aarch64
 | 
			
		||||
#define arm_mmu_idx arm_mmu_idx_aarch64
 | 
			
		||||
#define arm_mmu_idx_to_el arm_mmu_idx_to_el_aarch64
 | 
			
		||||
#define arm_register_pre_el_change_hook arm_register_pre_el_change_hook_aarch64
 | 
			
		||||
#define arm_register_el_change_hook arm_register_el_change_hook_aarch64
 | 
			
		||||
#define arm_reset_cpu arm_reset_cpu_aarch64
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3405,6 +3405,7 @@
 | 
			
		|||
#define arm_v7m_mmu_idx_for_secstate_and_priv arm_v7m_mmu_idx_for_secstate_and_priv_aarch64eb
 | 
			
		||||
#define arm_hcr_el2_eff arm_hcr_el2_eff_aarch64eb
 | 
			
		||||
#define arm_mmu_idx arm_mmu_idx_aarch64eb
 | 
			
		||||
#define arm_mmu_idx_to_el arm_mmu_idx_to_el_aarch64eb
 | 
			
		||||
#define arm_register_pre_el_change_hook arm_register_pre_el_change_hook_aarch64eb
 | 
			
		||||
#define arm_register_el_change_hook arm_register_el_change_hook_aarch64eb
 | 
			
		||||
#define arm_reset_cpu arm_reset_cpu_aarch64eb
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3397,6 +3397,7 @@
 | 
			
		|||
#define ARM_REGS_STORAGE_SIZE ARM_REGS_STORAGE_SIZE_arm
 | 
			
		||||
#define arm_hcr_el2_eff arm_hcr_el2_eff_arm
 | 
			
		||||
#define arm_mmu_idx arm_mmu_idx_arm
 | 
			
		||||
#define arm_mmu_idx_to_el arm_mmu_idx_to_el_arm
 | 
			
		||||
#define arm_register_pre_el_change_hook arm_register_pre_el_change_hook_arm
 | 
			
		||||
#define arm_register_el_change_hook arm_register_el_change_hook_arm
 | 
			
		||||
#define arm_reset_cpu arm_reset_cpu_arm
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3397,6 +3397,7 @@
 | 
			
		|||
#define ARM_REGS_STORAGE_SIZE ARM_REGS_STORAGE_SIZE_armeb
 | 
			
		||||
#define arm_hcr_el2_eff arm_hcr_el2_eff_armeb
 | 
			
		||||
#define arm_mmu_idx arm_mmu_idx_armeb
 | 
			
		||||
#define arm_mmu_idx_to_el arm_mmu_idx_to_el_armeb
 | 
			
		||||
#define arm_register_pre_el_change_hook arm_register_pre_el_change_hook_armeb
 | 
			
		||||
#define arm_register_el_change_hook arm_register_el_change_hook_armeb
 | 
			
		||||
#define arm_reset_cpu arm_reset_cpu_armeb
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3406,6 +3406,7 @@ arm_symbols = (
 | 
			
		|||
    'ARM_REGS_STORAGE_SIZE',
 | 
			
		||||
    'arm_hcr_el2_eff',
 | 
			
		||||
    'arm_mmu_idx',
 | 
			
		||||
    'arm_mmu_idx_to_el',
 | 
			
		||||
    'arm_register_pre_el_change_hook',
 | 
			
		||||
    'arm_register_el_change_hook',
 | 
			
		||||
    'arm_reset_cpu',
 | 
			
		||||
| 
						 | 
				
			
			@ -3462,6 +3463,7 @@ aarch64_symbols = (
 | 
			
		|||
    'arm_v7m_mmu_idx_for_secstate_and_priv',
 | 
			
		||||
    'arm_hcr_el2_eff',
 | 
			
		||||
    'arm_mmu_idx',
 | 
			
		||||
    'arm_mmu_idx_to_el',
 | 
			
		||||
    'arm_register_pre_el_change_hook',
 | 
			
		||||
    'arm_register_el_change_hook',
 | 
			
		||||
    'arm_reset_cpu',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,6 @@
 | 
			
		|||
# define TARGET_PAGE_BITS 10
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define NB_MMU_MODES 8
 | 
			
		||||
#define NB_MMU_MODES 9
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2714,18 +2714,21 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
 | 
			
		|||
 *  + NonSecure EL1 & 0 stage 1
 | 
			
		||||
 *  + NonSecure EL1 & 0 stage 2
 | 
			
		||||
 *  + NonSecure EL2
 | 
			
		||||
 *  + Secure EL1 & EL0
 | 
			
		||||
 *  + NonSecure EL2 & 0   (ARMv8.1-VHE)
 | 
			
		||||
 *  + Secure EL1 & 0
 | 
			
		||||
 *  + Secure EL3
 | 
			
		||||
 * If EL3 is 32-bit:
 | 
			
		||||
 *  + NonSecure PL1 & 0 stage 1
 | 
			
		||||
 *  + NonSecure PL1 & 0 stage 2
 | 
			
		||||
 *  + NonSecure PL2
 | 
			
		||||
 *  + Secure PL0 & PL1
 | 
			
		||||
 *  + Secure PL0
 | 
			
		||||
 *  + Secure PL1
 | 
			
		||||
 * (reminder: for 32 bit EL3, Secure PL1 is *EL3*, not EL1.)
 | 
			
		||||
 *
 | 
			
		||||
 * For QEMU, an mmu_idx is not quite the same as a translation regime because:
 | 
			
		||||
 *  1. we need to split the "EL1 & 0" regimes into two mmu_idxes, because they
 | 
			
		||||
 *     may differ in access permissions even if the VA->PA map is the same
 | 
			
		||||
 *  1. we need to split the "EL1 & 0" and "EL2 & 0" regimes into two mmu_idxes,
 | 
			
		||||
 *     because they may differ in access permissions even if the VA->PA map is
 | 
			
		||||
 *     the same
 | 
			
		||||
 *  2. we want to cache in our TLB the full VA->IPA->PA lookup for a stage 1+2
 | 
			
		||||
 *     translation, which means that we have one mmu_idx that deals with two
 | 
			
		||||
 *     concatenated translation regimes [this sort of combined s1+2 TLB is
 | 
			
		||||
| 
						 | 
				
			
			@ -2737,19 +2740,23 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
 | 
			
		|||
 *  4. we can also safely fold together the "32 bit EL3" and "64 bit EL3"
 | 
			
		||||
 *     translation regimes, because they map reasonably well to each other
 | 
			
		||||
 *     and they can't both be active at the same time.
 | 
			
		||||
 * This gives us the following list of mmu_idx values:
 | 
			
		||||
 *  5. we want to be able to use the TLB for accesses done as part of a
 | 
			
		||||
 *     stage1 page table walk, rather than having to walk the stage2 page
 | 
			
		||||
 *     table over and over.
 | 
			
		||||
 *
 | 
			
		||||
 * NS EL0 (aka NS PL0) stage 1+2
 | 
			
		||||
 * NS EL1 (aka NS PL1) stage 1+2
 | 
			
		||||
 * This gives us the following list of cases:
 | 
			
		||||
 *
 | 
			
		||||
 * NS EL0 EL1&0 stage 1+2 (aka NS PL0)
 | 
			
		||||
 * NS EL1 EL1&0 stage 1+2 (aka NS PL1)
 | 
			
		||||
 * NS EL0 EL2&0
 | 
			
		||||
 * NS EL2 EL2&0
 | 
			
		||||
 * NS EL2 (aka NS PL2)
 | 
			
		||||
 * S EL0 EL1&0 (aka S PL0)
 | 
			
		||||
 * S EL1 EL1&0 (not used if EL3 is 32 bit)
 | 
			
		||||
 * S EL3 (aka S PL1)
 | 
			
		||||
 * S EL0 (aka S PL0)
 | 
			
		||||
 * S EL1 (not used if EL3 is 32 bit)
 | 
			
		||||
 * NS EL0+1 stage 2
 | 
			
		||||
 * NS EL1&0 stage 2
 | 
			
		||||
 *
 | 
			
		||||
 * (The last of these is an mmu_idx because we want to be able to use the TLB
 | 
			
		||||
 * for the accesses done as part of a stage 1 page table walk, rather than
 | 
			
		||||
 * having to walk the stage 2 page table over and over.)
 | 
			
		||||
 * for a total of 9 different mmu_idx.
 | 
			
		||||
 *
 | 
			
		||||
 * R profile CPUs have an MPU, but can use the same set of MMU indexes
 | 
			
		||||
 * as A profile. They only need to distinguish NS EL0 and NS EL1 (and
 | 
			
		||||
| 
						 | 
				
			
			@ -2791,22 +2798,43 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
 | 
			
		|||
#define ARM_MMU_IDX_NOTLB 0x20  /* does not have a TLB */
 | 
			
		||||
#define ARM_MMU_IDX_M     0x40  /* M profile */
 | 
			
		||||
 | 
			
		||||
/* meanings of the bits for M profile mmu idx values */
 | 
			
		||||
/* Meanings of the bits for M profile mmu idx values */
 | 
			
		||||
#define ARM_MMU_IDX_M_PRIV   0x1
 | 
			
		||||
#define ARM_MMU_IDX_M_NEGPRI 0x2
 | 
			
		||||
#define ARM_MMU_IDX_M_S 0x4
 | 
			
		||||
#define ARM_MMU_IDX_M_S      0x4  /* Secure */
 | 
			
		||||
 | 
			
		||||
#define ARM_MMU_IDX_TYPE_MASK (~0x7)
 | 
			
		||||
#define ARM_MMU_IDX_COREIDX_MASK 0x7
 | 
			
		||||
#define ARM_MMU_IDX_TYPE_MASK \
 | 
			
		||||
    (ARM_MMU_IDX_A | ARM_MMU_IDX_M | ARM_MMU_IDX_NOTLB)
 | 
			
		||||
#define ARM_MMU_IDX_COREIDX_MASK 0xf
 | 
			
		||||
 | 
			
		||||
typedef enum ARMMMUIdx {
 | 
			
		||||
    /*
 | 
			
		||||
     * A-profile.
 | 
			
		||||
     */
 | 
			
		||||
    ARMMMUIdx_E10_0 =  0 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_E10_1 = 1 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_E2 = 2 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_SE3 = 3 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_SE10_0 = 4 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_SE10_1 = 5 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_E20_0 =  1 | ARM_MMU_IDX_A,
 | 
			
		||||
 | 
			
		||||
    ARMMMUIdx_E10_1 =  2 | ARM_MMU_IDX_A,
 | 
			
		||||
 | 
			
		||||
    ARMMMUIdx_E2 =     3 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_E20_2 =  4 | ARM_MMU_IDX_A,
 | 
			
		||||
 | 
			
		||||
    ARMMMUIdx_SE10_0 = 5 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_SE10_1 = 6 | ARM_MMU_IDX_A,
 | 
			
		||||
    ARMMMUIdx_SE3 =    7 | ARM_MMU_IDX_A,
 | 
			
		||||
 | 
			
		||||
    ARMMMUIdx_Stage2 = 8 | ARM_MMU_IDX_A,
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * These are not allocated TLBs and are used only for AT system
 | 
			
		||||
     * instructions or for the first stage of an S12 page table walk.
 | 
			
		||||
     */
 | 
			
		||||
    ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB,
 | 
			
		||||
    ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB,
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * M-profile.
 | 
			
		||||
     */
 | 
			
		||||
    ARMMMUIdx_MUser = ARM_MMU_IDX_M,
 | 
			
		||||
    ARMMMUIdx_MPriv = ARM_MMU_IDX_M | ARM_MMU_IDX_M_PRIV,
 | 
			
		||||
    ARMMMUIdx_MUserNegPri = ARMMMUIdx_MUser | ARM_MMU_IDX_M_NEGPRI,
 | 
			
		||||
| 
						 | 
				
			
			@ -2815,11 +2843,6 @@ typedef enum ARMMMUIdx {
 | 
			
		|||
    ARMMMUIdx_MSPriv = ARMMMUIdx_MPriv | ARM_MMU_IDX_M_S,
 | 
			
		||||
    ARMMMUIdx_MSUserNegPri = ARMMMUIdx_MUserNegPri | ARM_MMU_IDX_M_S,
 | 
			
		||||
    ARMMMUIdx_MSPrivNegPri = ARMMMUIdx_MPrivNegPri | ARM_MMU_IDX_M_S,
 | 
			
		||||
    /* Indexes below here don't have TLBs and are used only for AT system
 | 
			
		||||
     * instructions or for the first stage of an S12 page table walk.
 | 
			
		||||
     */
 | 
			
		||||
    ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB,
 | 
			
		||||
    ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB,
 | 
			
		||||
} ARMMMUIdx;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			@ -2831,8 +2854,10 @@ typedef enum ARMMMUIdx {
 | 
			
		|||
 | 
			
		||||
typedef enum ARMMMUIdxBit {
 | 
			
		||||
    TO_CORE_BIT(E10_0),
 | 
			
		||||
    TO_CORE_BIT(E20_0),
 | 
			
		||||
    TO_CORE_BIT(E10_1),
 | 
			
		||||
    TO_CORE_BIT(E2),
 | 
			
		||||
    TO_CORE_BIT(E20_2),
 | 
			
		||||
    TO_CORE_BIT(SE10_0),
 | 
			
		||||
    TO_CORE_BIT(SE10_1),
 | 
			
		||||
    TO_CORE_BIT(SE3),
 | 
			
		||||
| 
						 | 
				
			
			@ -2852,49 +2877,6 @@ typedef enum ARMMMUIdxBit {
 | 
			
		|||
 | 
			
		||||
#define MMU_USER_IDX 0
 | 
			
		||||
 | 
			
		||||
static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    return mmu_idx & ARM_MMU_IDX_COREIDX_MASK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    if (arm_feature(env, ARM_FEATURE_M)) {
 | 
			
		||||
        return mmu_idx | ARM_MMU_IDX_M;
 | 
			
		||||
    } else {
 | 
			
		||||
        return mmu_idx | ARM_MMU_IDX_A;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Return the exception level we're running at if this is our mmu_idx */
 | 
			
		||||
static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    switch (mmu_idx & ARM_MMU_IDX_TYPE_MASK) {
 | 
			
		||||
    case ARM_MMU_IDX_A:
 | 
			
		||||
        return mmu_idx & 3;
 | 
			
		||||
    case ARM_MMU_IDX_M:
 | 
			
		||||
        return mmu_idx & ARM_MMU_IDX_M_PRIV;
 | 
			
		||||
    default:
 | 
			
		||||
        g_assert_not_reached();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Return the MMU index for a v7M CPU with all relevant information
 | 
			
		||||
 * manually specified.
 | 
			
		||||
 */
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
 | 
			
		||||
                              bool secstate, bool priv, bool negpri);
 | 
			
		||||
 | 
			
		||||
/* Return the MMU index for a v7M CPU in the specified security and
 | 
			
		||||
 * privilege state.
 | 
			
		||||
 */
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
 | 
			
		||||
                                                bool secstate, bool priv);
 | 
			
		||||
 | 
			
		||||
/* Return the MMU index for a v7M CPU in the specified security state */
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cpu_mmu_index:
 | 
			
		||||
 * @env: The cpu environment
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8548,9 +8548,11 @@ void arm_cpu_do_interrupt(CPUState *cs)
 | 
			
		|||
#endif /* !CONFIG_USER_ONLY */
 | 
			
		||||
 | 
			
		||||
/* Return the exception level which controls this address translation regime */
 | 
			
		||||
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
 | 
			
		||||
static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    switch (mmu_idx) {
 | 
			
		||||
    case ARMMMUIdx_E20_0:
 | 
			
		||||
    case ARMMMUIdx_E20_2:
 | 
			
		||||
    case ARMMMUIdx_Stage2:
 | 
			
		||||
    case ARMMMUIdx_E2:
 | 
			
		||||
        return 2;
 | 
			
		||||
| 
						 | 
				
			
			@ -8561,6 +8563,8 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
 | 
			
		|||
    case ARMMMUIdx_SE10_1:
 | 
			
		||||
    case ARMMMUIdx_Stage1_E0:
 | 
			
		||||
    case ARMMMUIdx_Stage1_E1:
 | 
			
		||||
    case ARMMMUIdx_E10_0:
 | 
			
		||||
    case ARMMMUIdx_E10_1:
 | 
			
		||||
    case ARMMMUIdx_MPrivNegPri:
 | 
			
		||||
    case ARMMMUIdx_MUserNegPri:
 | 
			
		||||
    case ARMMMUIdx_MPriv:
 | 
			
		||||
| 
						 | 
				
			
			@ -8664,10 +8668,14 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
 | 
			
		|||
 */
 | 
			
		||||
static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    if (mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_E10_1) {
 | 
			
		||||
        mmu_idx += (ARMMMUIdx_Stage1_E0 - ARMMMUIdx_E10_0);
 | 
			
		||||
    }
 | 
			
		||||
    switch (mmu_idx) {
 | 
			
		||||
    case ARMMMUIdx_E10_0:
 | 
			
		||||
        return ARMMMUIdx_Stage1_E0;
 | 
			
		||||
    case ARMMMUIdx_E10_1:
 | 
			
		||||
        return ARMMMUIdx_Stage1_E1;
 | 
			
		||||
    default:
 | 
			
		||||
        return mmu_idx;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Return true if the translation regime is using LPAE format page tables */
 | 
			
		||||
| 
						 | 
				
			
			@ -8702,6 +8710,7 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
 | 
			
		|||
{
 | 
			
		||||
    switch (mmu_idx) {
 | 
			
		||||
    case ARMMMUIdx_SE10_0:
 | 
			
		||||
    case ARMMMUIdx_E20_0:
 | 
			
		||||
    case ARMMMUIdx_Stage1_E0:
 | 
			
		||||
    case ARMMMUIdx_MUser:
 | 
			
		||||
    case ARMMMUIdx_MSUser:
 | 
			
		||||
| 
						 | 
				
			
			@ -11153,6 +11162,31 @@ int fp_exception_el(CPUARMState *env, int cur_el)
 | 
			
		|||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Return the exception level we're running at if this is our mmu_idx */
 | 
			
		||||
int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    if (mmu_idx & ARM_MMU_IDX_M) {
 | 
			
		||||
        return mmu_idx & ARM_MMU_IDX_M_PRIV;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    switch (mmu_idx) {
 | 
			
		||||
    case ARMMMUIdx_E10_0:
 | 
			
		||||
    case ARMMMUIdx_E20_0:
 | 
			
		||||
    case ARMMMUIdx_SE10_0:
 | 
			
		||||
        return 0;
 | 
			
		||||
    case ARMMMUIdx_E10_1:
 | 
			
		||||
    case ARMMMUIdx_SE10_1:
 | 
			
		||||
        return 1;
 | 
			
		||||
    case ARMMMUIdx_E2:
 | 
			
		||||
    case ARMMMUIdx_E20_2:
 | 
			
		||||
        return 2;
 | 
			
		||||
    case ARMMMUIdx_SE3:
 | 
			
		||||
        return 3;
 | 
			
		||||
    default:
 | 
			
		||||
        g_assert_not_reached();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIG_TCG
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -11169,10 +11203,26 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env)
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    el = arm_current_el(env);
 | 
			
		||||
    if (el < 2 && arm_is_secure_below_el3(env)) {
 | 
			
		||||
        return ARMMMUIdx_SE10_0 + el;
 | 
			
		||||
    } else {
 | 
			
		||||
        return ARMMMUIdx_E10_0 + el;
 | 
			
		||||
    switch (el) {
 | 
			
		||||
    case 0:
 | 
			
		||||
        /* TODO: ARMv8.1-VHE */
 | 
			
		||||
        if (arm_is_secure_below_el3(env)) {
 | 
			
		||||
            return ARMMMUIdx_SE10_0;
 | 
			
		||||
        }
 | 
			
		||||
        return ARMMMUIdx_E10_0;
 | 
			
		||||
    case 1:
 | 
			
		||||
        if (arm_is_secure_below_el3(env)) {
 | 
			
		||||
            return ARMMMUIdx_SE10_1;
 | 
			
		||||
        }
 | 
			
		||||
        return ARMMMUIdx_E10_1;
 | 
			
		||||
    case 2:
 | 
			
		||||
        /* TODO: ARMv8.1-VHE */
 | 
			
		||||
        /* TODO: ARMv8.4-SecEL2 */
 | 
			
		||||
        return ARMMMUIdx_E2;
 | 
			
		||||
    case 3:
 | 
			
		||||
        return ARMMMUIdx_SE3;
 | 
			
		||||
    default:
 | 
			
		||||
        g_assert_not_reached();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -771,6 +771,39 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
 | 
			
		|||
                      MMUAccessType access_type, int mmu_idx,
 | 
			
		||||
                      bool probe, uintptr_t retaddr);
 | 
			
		||||
 | 
			
		||||
static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    return mmu_idx & ARM_MMU_IDX_COREIDX_MASK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx)
 | 
			
		||||
{
 | 
			
		||||
    if (arm_feature(env, ARM_FEATURE_M)) {
 | 
			
		||||
        return mmu_idx | ARM_MMU_IDX_M;
 | 
			
		||||
    } else {
 | 
			
		||||
        return mmu_idx | ARM_MMU_IDX_A;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Return the MMU index for a v7M CPU with all relevant information
 | 
			
		||||
 * manually specified.
 | 
			
		||||
 */
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
 | 
			
		||||
                              bool secstate, bool priv, bool negpri);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Return the MMU index for a v7M CPU in the specified security and
 | 
			
		||||
 * privilege state.
 | 
			
		||||
 */
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
 | 
			
		||||
                                                bool secstate, bool priv);
 | 
			
		||||
 | 
			
		||||
/* Return the MMU index for a v7M CPU in the specified security state */
 | 
			
		||||
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
 | 
			
		||||
 | 
			
		||||
/* Return true if the stage 1 translation regime is using LPAE format page
 | 
			
		||||
 * tables */
 | 
			
		||||
bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -166,7 +166,6 @@ static inline int get_a32_user_mem_index(DisasContext *s)
 | 
			
		|||
    case ARMMMUIdx_MSUserNegPri:
 | 
			
		||||
    case ARMMMUIdx_MSPrivNegPri:
 | 
			
		||||
        return arm_to_core_mmu_idx(ARMMMUIdx_MSUserNegPri);
 | 
			
		||||
    case ARMMMUIdx_Stage2:
 | 
			
		||||
    default:
 | 
			
		||||
        g_assert_not_reached();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue