target/arm: Use GetPhysAddrResult in get_phys_addr_v6

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20220822152741.1617527-5-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:
Richard Henderson 2022-08-22 08:26:39 -07:00 committed by Peter Maydell
parent 03ee9bbe70
commit 60a6a180b1

View File

@ -536,8 +536,7 @@ 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, GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
target_ulong *page_size, ARMMMUFaultInfo *fi)
{ {
ARMCPU *cpu = env_archcpu(env); ARMCPU *cpu = env_archcpu(env);
int level = 1; int level = 1;
@ -597,11 +596,11 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
phys_addr = (desc & 0xff000000) | (address & 0x00ffffff); phys_addr = (desc & 0xff000000) | (address & 0x00ffffff);
phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32; phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32;
phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36; phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36;
*page_size = 0x1000000; result->page_size = 0x1000000;
} else { } else {
/* Section. */ /* Section. */
phys_addr = (desc & 0xfff00000) | (address & 0x000fffff); phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);
*page_size = 0x100000; result->page_size = 0x100000;
} }
ap = ((desc >> 10) & 3) | ((desc >> 13) & 4); ap = ((desc >> 10) & 3) | ((desc >> 13) & 4);
xn = desc & (1 << 4); xn = desc & (1 << 4);
@ -627,12 +626,12 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
case 1: /* 64k page. */ case 1: /* 64k page. */
phys_addr = (desc & 0xffff0000) | (address & 0xffff); phys_addr = (desc & 0xffff0000) | (address & 0xffff);
xn = desc & (1 << 15); xn = desc & (1 << 15);
*page_size = 0x10000; result->page_size = 0x10000;
break; break;
case 2: case 3: /* 4k page. */ case 2: case 3: /* 4k page. */
phys_addr = (desc & 0xfffff000) | (address & 0xfff); phys_addr = (desc & 0xfffff000) | (address & 0xfff);
xn = desc & 1; xn = desc & 1;
*page_size = 0x1000; result->page_size = 0x1000;
break; break;
default: default:
/* Never happens, but compiler isn't smart enough to tell. */ /* Never happens, but compiler isn't smart enough to tell. */
@ -640,7 +639,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
} }
} }
if (domain_prot == 3) { if (domain_prot == 3) {
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
} else { } else {
if (pxn && !regime_is_user(env, mmu_idx)) { if (pxn && !regime_is_user(env, mmu_idx)) {
xn = 1; xn = 1;
@ -658,14 +657,14 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
fi->type = ARMFault_AccessFlag; fi->type = ARMFault_AccessFlag;
goto do_fault; goto do_fault;
} }
*prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1); result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1);
} else { } else {
*prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot); result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
} }
if (*prot && !xn) { if (result->prot && !xn) {
*prot |= PAGE_EXEC; result->prot |= PAGE_EXEC;
} }
if (!(*prot & (1 << access_type))) { if (!(result->prot & (1 << access_type))) {
/* Access permission fault. */ /* Access permission fault. */
fi->type = ARMFault_Permission; fi->type = ARMFault_Permission;
goto do_fault; goto do_fault;
@ -676,9 +675,9 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
* the CPU doesn't support TZ or this is a non-secure translation * the CPU doesn't support TZ or this is a non-secure translation
* regime, because the attribute will already be non-secure. * regime, because the attribute will already be non-secure.
*/ */
attrs->secure = false; result->attrs.secure = false;
} }
*phys_ptr = phys_addr; result->phys = phys_addr;
return false; return false;
do_fault: do_fault:
fi->domain = domain; fi->domain = domain;
@ -2518,8 +2517,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
result, fi); result, fi);
} 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, return get_phys_addr_v6(env, address, access_type, mmu_idx,
&result->phys, &result->attrs, result, fi);
&result->prot, &result->page_size, fi);
} else { } else {
return get_phys_addr_v5(env, address, access_type, mmu_idx, return get_phys_addr_v5(env, address, access_type, mmu_idx,
&result->phys, &result->prot, &result->phys, &result->prot,