Skip to content

Commit 097d68a

Browse files
committed
target/arm: Forbid return to AArch32 when CPU is AArch64-only
In the Arm ARM, rule R_TYTWB states that returning to AArch32 is an illegal exception return if: * AArch32 is not supported at any exception level * the target EL is configured for AArch64 via SCR_EL3.RW or HCR_EL2.RW or via CPU state at reset We check the second of these, but not the first (which can only be relevant for the case of a return to EL0, because if AArch32 is not supported at one of the higher ELs then the RW bits will have an effective value of 1 and the the "configured for AArch64" condition will hold also). Add the missing condition. Although this is technically a bug (because we have one AArch64-only CPU: a64fx) it isn't worth backporting to stable because no sensible guest code will deliberately try to return to a nonexistent execution state to check that it gets an illegal exception return. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]>
1 parent 44ab8c2 commit 097d68a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

target/arm/tcg/helper-a64.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,11 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
678678
goto illegal_return;
679679
}
680680

681+
if (!return_to_aa64 && !cpu_isar_feature(aa64_aa32, cpu)) {
682+
/* Return to AArch32 when CPU is AArch64-only */
683+
goto illegal_return;
684+
}
685+
681686
if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) {
682687
goto illegal_return;
683688
}

0 commit comments

Comments
 (0)