Newer Arm CPUs need not implement AArch32 at all exception levels (and Armv9 forbids implementing AArch32 at any EL except EL0). All our current CPU models implement both AArch32 and AArch64 at every exception levels, so we currently get away with failing to enforce that the guest isn't trying to do an exception return to AArch32 when the target EL doesn't support AArch32.
This patchset adds the missing checks: * SCR_EL3.RW has an effective value of 1 if EL2 is AArch64-only * HCR_EL2.RW is RAO/WI if EL1 is AArch64-only * return to AArch32 when no EL supports AArch32 is an illegal exception return To do this it needs to start off with some cleanup. This is because we need to add a cpu_isar_feature() check to arm_el_is_aa64(), but we don't want to include cpu-features.h in cpu.h. arm_el_is_aa64() is really an internal part of the CPU implementation, so we can move it to internals.h; this means also moving some other functions in cpu.h that are defined as inline functions and which call arm_el_is_aa64(). Removing some unused macros from linux-user allows us to avoid having linux-user include internals.h. (No doubt there are other functions that could be moved out of cpu.h, but I stuck to only the ones that I actually needed to move.) thanks -- PMM Peter Maydell (10): target/arm: Move A32_BANKED_REG_{GET,SET} macros to cpregs.h target/arm: Un-inline access_secure_reg() linux-user/aarch64: Remove unused get/put_user macros linux-user/arm: Remove unused get_put_user macros target/arm: Move arm_cpu_data_is_big_endian() etc to internals.h target/arm: Move arm_current_el() and arm_el_is_aa64() to internals.h target/arm: SCR_EL3.RW should be treated as 1 if EL2 doesn't support AArch32 target/arm: HCR_EL2.RW should be RAO/WI if EL1 doesn't support AArch32 target/arm: Add cpu local variable to exception_return helper target/arm: Forbid return to AArch32 when CPU is AArch64-only target/arm/cpregs.h | 28 +++++++ target/arm/cpu.h | 153 +--------------------------------- target/arm/internals.h | 133 +++++++++++++++++++++++++++++ hw/intc/arm_gicv3_cpuif.c | 1 + linux-user/aarch64/cpu_loop.c | 48 ----------- linux-user/arm/cpu_loop.c | 43 +--------- target/arm/arch_dump.c | 1 + target/arm/helper.c | 16 +++- target/arm/tcg/helper-a64.c | 12 ++- target/arm/tcg/hflags.c | 9 ++ 10 files changed, 202 insertions(+), 242 deletions(-) -- 2.43.0