target/arm: Split s2walk_secure from ipa_secure in get_phys_addr

The starting security state comes with the translation regime,
not the current state of arm_is_secure_below_el3().

Create a new local variable, s2walk_secure, which does not need
to be written back to result->attrs.secure -- we compute that
value later, after the S2 walk is complete.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20221001162318.153420-2-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2022-10-01 09:22:37 -07:00 committed by Peter Maydell
parent 86a85d73e3
commit c7637be307

View file

@ -2298,7 +2298,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
hwaddr ipa; hwaddr ipa;
int s1_prot; int s1_prot;
int ret; int ret;
bool ipa_secure; bool ipa_secure, s2walk_secure;
ARMCacheAttrs cacheattrs1; ARMCacheAttrs cacheattrs1;
ARMMMUIdx s2_mmu_idx; ARMMMUIdx s2_mmu_idx;
bool is_el0; bool is_el0;
@ -2313,17 +2313,17 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
ipa = result->phys; ipa = result->phys;
ipa_secure = result->attrs.secure; ipa_secure = result->attrs.secure;
if (arm_is_secure_below_el3(env)) { if (is_secure) {
if (ipa_secure) { /* Select TCR based on the NS bit from the S1 walk. */
result->attrs.secure = !(env->cp15.vstcr_el2 & VSTCR_SW); s2walk_secure = !(ipa_secure
} else { ? env->cp15.vstcr_el2 & VSTCR_SW
result->attrs.secure = !(env->cp15.vtcr_el2 & VTCR_NSW); : env->cp15.vtcr_el2 & VTCR_NSW);
}
} else { } else {
assert(!ipa_secure); assert(!ipa_secure);
s2walk_secure = false;
} }
s2_mmu_idx = (result->attrs.secure s2_mmu_idx = (s2walk_secure
? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2); ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2);
is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0;
@ -2366,7 +2366,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
result->cacheattrs); result->cacheattrs);
/* Check if IPA translates to secure or non-secure PA space. */ /* Check if IPA translates to secure or non-secure PA space. */
if (arm_is_secure_below_el3(env)) { if (is_secure) {
if (ipa_secure) { if (ipa_secure) {
result->attrs.secure = result->attrs.secure =
!(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)); !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW));