mirror of https://github.com/xemu-project/xemu.git
target/arm: Use GetPhysAddrResult in pmsav8_mpu_lookup
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20220822152741.1617527-10-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
5272b23e2e
commit
d2c92e5856
|
@ -1125,12 +1125,6 @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
|
||||||
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
||||||
V8M_SAttributes *sattrs);
|
V8M_SAttributes *sattrs);
|
||||||
|
|
||||||
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
|
||||||
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
|
||||||
hwaddr *phys_ptr, MemTxAttrs *txattrs,
|
|
||||||
int *prot, bool *is_subpage,
|
|
||||||
ARMMMUFaultInfo *fi, uint32_t *mregion);
|
|
||||||
|
|
||||||
/* Cacheability and shareability attributes for a memory access */
|
/* Cacheability and shareability attributes for a memory access */
|
||||||
typedef struct ARMCacheAttrs {
|
typedef struct ARMCacheAttrs {
|
||||||
/*
|
/*
|
||||||
|
@ -1156,6 +1150,11 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
|
||||||
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
|
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
|
||||||
__attribute__((nonnull));
|
__attribute__((nonnull));
|
||||||
|
|
||||||
|
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
|
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
||||||
|
GetPhysAddrResult *result, bool *is_subpage,
|
||||||
|
ARMMMUFaultInfo *fi, uint32_t *mregion);
|
||||||
|
|
||||||
void arm_log_exception(CPUState *cs);
|
void arm_log_exception(CPUState *cs);
|
||||||
|
|
||||||
#endif /* !CONFIG_USER_ONLY */
|
#endif /* !CONFIG_USER_ONLY */
|
||||||
|
|
|
@ -2770,15 +2770,10 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
|
||||||
V8M_SAttributes sattrs = {};
|
V8M_SAttributes sattrs = {};
|
||||||
uint32_t tt_resp;
|
uint32_t tt_resp;
|
||||||
bool r, rw, nsr, nsrw, mrvalid;
|
bool r, rw, nsr, nsrw, mrvalid;
|
||||||
int prot;
|
|
||||||
ARMMMUFaultInfo fi = {};
|
|
||||||
MemTxAttrs attrs = {};
|
|
||||||
hwaddr phys_addr;
|
|
||||||
ARMMMUIdx mmu_idx;
|
ARMMMUIdx mmu_idx;
|
||||||
uint32_t mregion;
|
uint32_t mregion;
|
||||||
bool targetpriv;
|
bool targetpriv;
|
||||||
bool targetsec = env->v7m.secure;
|
bool targetsec = env->v7m.secure;
|
||||||
bool is_subpage;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Work out what the security state and privilege level we're
|
* Work out what the security state and privilege level we're
|
||||||
|
@ -2809,18 +2804,21 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
|
||||||
* inspecting the other MPU state.
|
* inspecting the other MPU state.
|
||||||
*/
|
*/
|
||||||
if (arm_current_el(env) != 0 || alt) {
|
if (arm_current_el(env) != 0 || alt) {
|
||||||
|
GetPhysAddrResult res = {};
|
||||||
|
ARMMMUFaultInfo fi = {};
|
||||||
|
bool is_subpage;
|
||||||
|
|
||||||
/* We can ignore the return value as prot is always set */
|
/* We can ignore the return value as prot is always set */
|
||||||
pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
|
pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
|
||||||
&phys_addr, &attrs, &prot, &is_subpage,
|
&res, &is_subpage, &fi, &mregion);
|
||||||
&fi, &mregion);
|
|
||||||
if (mregion == -1) {
|
if (mregion == -1) {
|
||||||
mrvalid = false;
|
mrvalid = false;
|
||||||
mregion = 0;
|
mregion = 0;
|
||||||
} else {
|
} else {
|
||||||
mrvalid = true;
|
mrvalid = true;
|
||||||
}
|
}
|
||||||
r = prot & PAGE_READ;
|
r = res.prot & PAGE_READ;
|
||||||
rw = prot & PAGE_WRITE;
|
rw = res.prot & PAGE_WRITE;
|
||||||
} else {
|
} else {
|
||||||
r = false;
|
r = false;
|
||||||
rw = false;
|
rw = false;
|
||||||
|
|
|
@ -1701,8 +1701,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
|
||||||
|
|
||||||
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
MMUAccessType access_type, ARMMMUIdx mmu_idx,
|
||||||
hwaddr *phys_ptr, MemTxAttrs *txattrs,
|
GetPhysAddrResult *result, bool *is_subpage,
|
||||||
int *prot, bool *is_subpage,
|
|
||||||
ARMMMUFaultInfo *fi, uint32_t *mregion)
|
ARMMMUFaultInfo *fi, uint32_t *mregion)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -1724,8 +1723,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
|
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
|
||||||
|
|
||||||
*is_subpage = false;
|
*is_subpage = false;
|
||||||
*phys_ptr = address;
|
result->phys = address;
|
||||||
*prot = 0;
|
result->prot = 0;
|
||||||
if (mregion) {
|
if (mregion) {
|
||||||
*mregion = -1;
|
*mregion = -1;
|
||||||
}
|
}
|
||||||
|
@ -1807,7 +1806,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
|
|
||||||
if (matchregion == -1) {
|
if (matchregion == -1) {
|
||||||
/* hit using the background region */
|
/* hit using the background region */
|
||||||
get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
|
get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
|
||||||
} else {
|
} else {
|
||||||
uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2);
|
uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2);
|
||||||
uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1);
|
uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1);
|
||||||
|
@ -1822,9 +1821,9 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
xn = 1;
|
xn = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
|
result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
|
||||||
if (*prot && !xn && !(pxn && !is_user)) {
|
if (result->prot && !xn && !(pxn && !is_user)) {
|
||||||
*prot |= PAGE_EXEC;
|
result->prot |= PAGE_EXEC;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* We don't need to look the attribute up in the MAIR0/MAIR1
|
* We don't need to look the attribute up in the MAIR0/MAIR1
|
||||||
|
@ -1837,7 +1836,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool v8m_is_sau_exempt(CPUARMState *env,
|
static bool v8m_is_sau_exempt(CPUARMState *env,
|
||||||
|
@ -2036,8 +2035,7 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
|
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
|
||||||
&result->phys, &result->attrs, &result->prot,
|
result, &mpu_is_subpage, fi, NULL);
|
||||||
&mpu_is_subpage, fi, NULL);
|
|
||||||
result->page_size =
|
result->page_size =
|
||||||
sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
|
sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue