mirror of https://github.com/xemu-project/xemu.git
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20220822152741.1617527-8-richard.henderson@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
b7b9b579cf
commit
e59367e2ef
|
@ -1513,17 +1513,16 @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
|
||||||
|
|
||||||
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
||||||
hwaddr *phys_ptr, int *prot,
|
GetPhysAddrResult *result,
|
||||||
target_ulong *page_size,
|
|
||||||
ARMMMUFaultInfo *fi)
|
ARMMMUFaultInfo *fi)
|
||||||
{
|
{
|
||||||
ARMCPU *cpu = env_archcpu(env);
|
ARMCPU *cpu = env_archcpu(env);
|
||||||
int n;
|
int n;
|
||||||
bool is_user = regime_is_user(env, mmu_idx);
|
bool is_user = regime_is_user(env, mmu_idx);
|
||||||
|
|
||||||
*phys_ptr = address;
|
result->phys = address;
|
||||||
*page_size = TARGET_PAGE_SIZE;
|
result->page_size = TARGET_PAGE_SIZE;
|
||||||
*prot = 0;
|
result->prot = 0;
|
||||||
|
|
||||||
if (regime_translation_disabled(env, mmu_idx) ||
|
if (regime_translation_disabled(env, mmu_idx) ||
|
||||||
m_is_ppb_region(env, address)) {
|
m_is_ppb_region(env, address)) {
|
||||||
|
@ -1535,7 +1534,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
* which always does a direct read using address_space_ldl(), rather
|
* which always does a direct read using address_space_ldl(), rather
|
||||||
* than going via this function, so we don't need to check that here.
|
* than going via this function, so we don't need to check that here.
|
||||||
*/
|
*/
|
||||||
get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
|
get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
|
||||||
} else { /* MPU enabled */
|
} else { /* MPU enabled */
|
||||||
for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
|
for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
|
||||||
/* region search */
|
/* region search */
|
||||||
|
@ -1577,7 +1576,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
if (ranges_overlap(base, rmask,
|
if (ranges_overlap(base, rmask,
|
||||||
address & TARGET_PAGE_MASK,
|
address & TARGET_PAGE_MASK,
|
||||||
TARGET_PAGE_SIZE)) {
|
TARGET_PAGE_SIZE)) {
|
||||||
*page_size = 1;
|
result->page_size = 1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1615,7 +1614,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rsize < TARGET_PAGE_BITS) {
|
if (rsize < TARGET_PAGE_BITS) {
|
||||||
*page_size = 1 << rsize;
|
result->page_size = 1 << rsize;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1626,7 +1625,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
fi->type = ARMFault_Background;
|
fi->type = ARMFault_Background;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
|
get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
|
||||||
} else { /* a MPU hit! */
|
} else { /* a MPU hit! */
|
||||||
uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
|
uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
|
||||||
uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
|
uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
|
||||||
|
@ -1643,16 +1642,16 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
case 5:
|
case 5:
|
||||||
break; /* no access */
|
break; /* no access */
|
||||||
case 3:
|
case 3:
|
||||||
*prot |= PAGE_WRITE;
|
result->prot |= PAGE_WRITE;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 2:
|
case 2:
|
||||||
case 6:
|
case 6:
|
||||||
*prot |= PAGE_READ | PAGE_EXEC;
|
result->prot |= PAGE_READ | PAGE_EXEC;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
/* for v7M, same as 6; for R profile a reserved value */
|
/* for v7M, same as 6; for R profile a reserved value */
|
||||||
if (arm_feature(env, ARM_FEATURE_M)) {
|
if (arm_feature(env, ARM_FEATURE_M)) {
|
||||||
*prot |= PAGE_READ | PAGE_EXEC;
|
result->prot |= PAGE_READ | PAGE_EXEC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
@ -1668,16 +1667,16 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
*prot |= PAGE_WRITE;
|
result->prot |= PAGE_WRITE;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
*prot |= PAGE_READ | PAGE_EXEC;
|
result->prot |= PAGE_READ | PAGE_EXEC;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
/* for v7M, same as 6; for R profile a reserved value */
|
/* for v7M, same as 6; for R profile a reserved value */
|
||||||
if (arm_feature(env, ARM_FEATURE_M)) {
|
if (arm_feature(env, ARM_FEATURE_M)) {
|
||||||
*prot |= PAGE_READ | PAGE_EXEC;
|
result->prot |= PAGE_READ | PAGE_EXEC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
@ -1690,14 +1689,14 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
|
|
||||||
/* execute never */
|
/* execute never */
|
||||||
if (xn) {
|
if (xn) {
|
||||||
*prot &= ~PAGE_EXEC;
|
result->prot &= ~PAGE_EXEC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fi->type = ARMFault_Permission;
|
fi->type = ARMFault_Permission;
|
||||||
fi->level = 1;
|
fi->level = 1;
|
||||||
return !(*prot & (1 << access_type));
|
return !(result->prot & (1 << access_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
|
@ -2422,8 +2421,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
|
||||||
} else if (arm_feature(env, ARM_FEATURE_V7)) {
|
} else if (arm_feature(env, ARM_FEATURE_V7)) {
|
||||||
/* PMSAv7 */
|
/* PMSAv7 */
|
||||||
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
|
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
|
||||||
&result->phys, &result->prot,
|
result, fi);
|
||||||
&result->page_size, fi);
|
|
||||||
} else {
|
} else {
|
||||||
/* Pre-v7 MPU */
|
/* Pre-v7 MPU */
|
||||||
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
|
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
|
||||||
|
|
Loading…
Reference in New Issue