aboutsummaryrefslogtreecommitdiff
path: root/target/arm
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2024-01-09 14:43:49 +0000
committerPeter Maydell <peter.maydell@linaro.org>2024-01-09 14:43:49 +0000
commit29eda9cd1987d69b089ed5413c8e39aecd618e17 (patch)
treef3f066163cfb19a13b12ecbf5d7fcfcc282a7cda /target/arm
parentb7ecc3da6c87f8a57805acfc46922684f8a26eea (diff)
downloadqemu-29eda9cd1987d69b089ed5413c8e39aecd618e17.zip
qemu-29eda9cd1987d69b089ed5413c8e39aecd618e17.tar.gz
qemu-29eda9cd1987d69b089ed5413c8e39aecd618e17.tar.bz2
target/arm: Set SPSR_EL1.M correctly when nested virt is enabled
FEAT_NV requires that when HCR_EL2.{NV,NV1} == {1,0} and an exception is taken from EL1 to EL1 then the reported EL in SPSR_EL1.M should be EL2, not EL1. Implement this behaviour. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Tested-by: Miguel Luis <miguel.luis@oracle.com>
Diffstat (limited to 'target/arm')
-rw-r--r--target/arm/helper.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 7c7f92c..e48b03b 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -11249,6 +11249,12 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
old_mode = pstate_read(env);
aarch64_save_sp(env, arm_current_el(env));
env->elr_el[new_el] = env->pc;
+
+ if (cur_el == 1 && new_el == 1 &&
+ ((arm_hcr_el2_eff(env) & (HCR_NV | HCR_NV1)) == HCR_NV)) {
+ /* I_ZJRNN: report EL2 in the SPSR by setting M[3:2] to 0b10 */
+ old_mode = deposit32(old_mode, 2, 2, 2);
+ }
} else {
old_mode = cpsr_read_for_spsr_elx(env);
env->elr_el[new_el] = env->regs[15];