target/arm: Convert get_phys_addr_v6() to not return FSC values

Make get_phys_addr_v6() return a fault type in the ARMMMUFaultInfo
structure, which we convert to the FSC at the callsite.

Backports commit f06cf243945ccb24cb9578304306ae7fcb4cf3fd from qemu
This commit is contained in:
Peter Maydell 2018-03-05 13:39:10 -05:00 committed by Lioncash
parent 4ccf3c3927
commit c6496ec00a
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -7648,11 +7648,10 @@ do_fault:
static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
MMUAccessType access_type, ARMMMUIdx mmu_idx, MMUAccessType access_type, ARMMMUIdx mmu_idx,
hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
target_ulong *page_size, uint32_t *fsr, target_ulong *page_size, ARMMMUFaultInfo *fi)
ARMMMUFaultInfo *fi)
{ {
CPUState *cs = CPU(arm_env_get_cpu(env)); CPUState *cs = CPU(arm_env_get_cpu(env));
int code; int level = 1;
uint32_t table; uint32_t table;
uint32_t desc; uint32_t desc;
uint32_t xn; uint32_t xn;
@ -7669,7 +7668,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
/* Lookup l1 descriptor. */ /* Lookup l1 descriptor. */
if (!get_level1_table_address(env, mmu_idx, &table, address)) { if (!get_level1_table_address(env, mmu_idx, &table, address)) {
/* Section translation fault if page walk is disabled by PD0 or PD1 */ /* Section translation fault if page walk is disabled by PD0 or PD1 */
code = 5; fi->type = ARMFault_Translation;
goto do_fault; goto do_fault;
} }
desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx), desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx),
@ -7679,7 +7678,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
/* Section translation fault, or attempt to use the encoding /* Section translation fault, or attempt to use the encoding
* which is Reserved on implementations without PXN. * which is Reserved on implementations without PXN.
*/ */
code = 5; fi->type = ARMFault_Translation;
goto do_fault; goto do_fault;
} }
if ((type == 1) || !(desc & (1 << 18))) { if ((type == 1) || !(desc & (1 << 18))) {
@ -7691,13 +7690,13 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
} else { } else {
dacr = env->cp15.dacr_s; dacr = env->cp15.dacr_s;
} }
if (type == 1) {
level = 2;
}
domain_prot = (dacr >> (domain * 2)) & 3; domain_prot = (dacr >> (domain * 2)) & 3;
if (domain_prot == 0 || domain_prot == 2) { if (domain_prot == 0 || domain_prot == 2) {
if (type != 1) { /* Section or Page domain fault */
code = 9; /* Section domain fault. */ fi->type = ARMFault_Domain;
} else {
code = 11; /* Page domain fault. */
}
goto do_fault; goto do_fault;
} }
if (type != 1) { if (type != 1) {
@ -7715,7 +7714,6 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); ap = ((desc >> 10) & 3) | ((desc >> 13) & 4);
xn = desc & (1 << 4); xn = desc & (1 << 4);
pxn = desc & 1; pxn = desc & 1;
code = 13;
ns = extract32(desc, 19, 1); ns = extract32(desc, 19, 1);
} else { } else {
if (arm_feature(env, ARM_FEATURE_PXN)) { if (arm_feature(env, ARM_FEATURE_PXN)) {
@ -7729,7 +7727,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
ap = ((desc >> 4) & 3) | ((desc >> 7) & 4); ap = ((desc >> 4) & 3) | ((desc >> 7) & 4);
switch (desc & 3) { switch (desc & 3) {
case 0: /* Page translation fault. */ case 0: /* Page translation fault. */
code = 7; fi->type = ARMFault_Translation;
goto do_fault; goto do_fault;
case 1: /* 64k page. */ case 1: /* 64k page. */
phys_addr = (desc & 0xffff0000) | (address & 0xffff); phys_addr = (desc & 0xffff0000) | (address & 0xffff);
@ -7745,7 +7743,6 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
/* Never happens, but compiler isn't smart enough to tell. */ /* Never happens, but compiler isn't smart enough to tell. */
abort(); abort();
} }
code = 15;
} }
if (domain_prot == 3) { if (domain_prot == 3) {
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
@ -7753,15 +7750,17 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
if (pxn && !regime_is_user(env, mmu_idx)) { if (pxn && !regime_is_user(env, mmu_idx)) {
xn = 1; xn = 1;
} }
if (xn && access_type == MMU_INST_FETCH) if (xn && access_type == MMU_INST_FETCH) {
fi->type = ARMFault_Permission;
goto do_fault; goto do_fault;
}
if (arm_feature(env, ARM_FEATURE_V6K) && if (arm_feature(env, ARM_FEATURE_V6K) &&
(regime_sctlr(env, mmu_idx) & SCTLR_AFE)) { (regime_sctlr(env, mmu_idx) & SCTLR_AFE)) {
/* The simplified model uses AP[0] as an access control bit. */ /* The simplified model uses AP[0] as an access control bit. */
if ((ap & 1) == 0) { if ((ap & 1) == 0) {
/* Access flag fault. */ /* Access flag fault. */
code = (code == 15) ? 6 : 3; fi->type = ARMFault_AccessFlag;
goto do_fault; goto do_fault;
} }
*prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); *prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1);
@ -7773,6 +7772,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
} }
if (!(*prot & (1 << access_type))) { if (!(*prot & (1 << access_type))) {
/* Access permission fault. */ /* Access permission fault. */
fi->type = ARMFault_Permission;
goto do_fault; goto do_fault;
} }
} }
@ -7786,7 +7786,8 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
*phys_ptr = phys_addr; *phys_ptr = phys_addr;
return false; return false;
do_fault: do_fault:
*fsr = code | (domain << 4); fi->domain = domain;
fi->level = level;
return true; return true;
} }
@ -9042,8 +9043,11 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
return get_phys_addr_lpae(env, address, access_type, mmu_idx, phys_ptr, return get_phys_addr_lpae(env, address, access_type, mmu_idx, phys_ptr,
attrs, prot, page_size, fsr, fi, cacheattrs); attrs, prot, page_size, fsr, fi, cacheattrs);
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
return get_phys_addr_v6(env, address, access_type, mmu_idx, phys_ptr, bool ret = get_phys_addr_v6(env, address, access_type, mmu_idx,
attrs, prot, page_size, fsr, fi); phys_ptr, attrs, prot, page_size, fi);
*fsr = arm_fi_to_sfsc(fi);
return ret;
} else { } else {
bool ret = get_phys_addr_v5(env, address, access_type, mmu_idx, bool ret = get_phys_addr_v5(env, address, access_type, mmu_idx,
phys_ptr, prot, page_size, fi); phys_ptr, prot, page_size, fi);