Skip to contentSkip to conversation

target/arm: Fix syndrome for FGT traps on ERET

PATCH In review Peter Maydell 2 participants 2 messages Oct 24, 2023 – Oct 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Fix syndrome for FGT traps on ERET

In commit 442c9d682c94fc2 when we converted the ERET, ERETAA, ERETAB instructions to decodetree, the conversion accidentally lost the correct setting of the syndrome register when taking a trap because of the FEAT_FGT HFGITR_EL1.ERET bit. Instead of reporting a correct full syndrome value with the EC and IL bits, we only reported the low two bits of the syndrome, because the call to syn_erettrap() got dropped.

Fix the syndrome values for these traps by reinstating the syn_erettrap() calls.

Fixes 442c9d682c94fc2 ("target/arm: Convert ERET, ERETAA, ERETAB to decodetree")

---
Spotted by code inspection when I was looking at putting in the ERET trap for FEAT_NV...

---
 target/arm/tcg/translate-a64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/tcg/translate-a64.c +2 -2
index ad78b8b1202..41484d8ae54 100644
@@ -1606,7 +1606,7 @@ static bool trans_ERET(DisasContext *s, arg_ERET *a)
         return false;
     }
     if (s->fgt_eret) {
-        gen_exception_insn_el(s, 0, EXCP_UDEF, 0, 2);
+        gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(0), 2);
         return true;
     }
     dst = tcg_temp_new_i64();
@@ -1633,7 +1633,7 @@ static bool trans_ERETA(DisasContext *s, arg_reta *a)
     }
     /* The FGT trap takes precedence over an auth trap. */
     if (s->fgt_eret) {
-        gen_exception_insn_el(s, 0, EXCP_UDEF, a->m ? 3 : 2, 2);
+        gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(a->m ? 3 : 2), 2);
         return true;
     }
     dst = tcg_temp_new_i64();
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Peter Maydell

In commit 442c9d682c94fc2 when we converted the ERET, ERETAA, ERETAB instructions to decodetree, the conversion accidentally lost the correct setting of the syndrome register when taking a trap because of the FEAT_FGT HFGITR_EL1.ERET bit. Instead of reporting a correct full syndrome value with the EC and IL bits, we only reported the low two bits of the syndrome, because the call to syn_erettrap() got dropped.

Quoted 6 lines

Fix the syndrome values for these traps by reinstating the syn_erettrap() calls.

Fixes 442c9d682c94fc2 ("target/arm: Convert ERET, ERETAA, ERETAB to decodetree")

r~