target/arm: Fix aa64 ldp register writeback
PATCH 1/1 target/arm: Fix aa64 ldp register writeback
For "ldp x0, x1, [x0]", if the second load is on a second page and the second page is unmapped, the exception would be raised with x0 already modified. This means the instruction couldn't be restarted.
Reported-by Andrew <[email protected]>
Signed-off-by Richard Henderson <[email protected]>
--- target/arm/translate-a64.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
target/arm/translate-a64.c +16 -12
@@ -2217,29 +2217,33 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn) }else {do_fp_st (s, rt, tcg_addr, size); } - }else { -TCGv_i64 tcg_rt =cpu_reg (s, rt); -if (is_load) { -do_gpr_ld (s, tcg_rt, tcg_addr, size, is_signed, false, - false,0 , false, false); - }else { -do_gpr_st (s, tcg_rt, tcg_addr, size, - false,0 , false, false); - } - } -tcg_gen_addi_i64 (tcg_addr, tcg_addr,1 << size); -if (is_vector) { +tcg_gen_addi_i64 (tcg_addr, tcg_addr,1 << size);if (is_load) {do_fp_ld (s, rt2, tcg_addr, size); }else {do_fp_st (s, rt2, tcg_addr, size); } }else { +TCGv_i64 tcg_rt =cpu_reg (s, rt);TCGv_i64 tcg_rt2 =cpu_reg (s, rt2); +if (is_load) { +TCGv_i64 tmp =tcg_temp_new_i64 (); + +/* Do not modify tcg_rt before recognizing any exception +from the second load. */ +do_gpr_ld (s, tmp, tcg_addr, size, is_signed, false, + false,0 , false, false); +tcg_gen_addi_i64 (tcg_addr, tcg_addr,1 << size);do_gpr_ld (s, tcg_rt2, tcg_addr, size, is_signed, false, false,0 , false, false); + +tcg_gen_mov_i64 (tcg_rt, tmp); +tcg_temp_free_i64 (tmp); }else { +do_gpr_st (s, tcg_rt, tcg_addr, size, + false,0 , false, false); +tcg_gen_addi_i64 (tcg_addr, tcg_addr,1 << size);do_gpr_st (s, tcg_rt2, tcg_addr, size, false,0 , false, false); }
Signature · 1 line
2.13.5
Peter Maydell
AppliedQuoted 4 lines · Richard Henderson
For "ldp x0, x1, [x0]", if the second load is on a second page and the second page is unmapped, the exception would be raised with x0 already modified. This means the instruction couldn't be restarted.
Quoted 8 lines
Reported-by Andrew <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate-a64.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
Applied to target-arm.next, thanks.
-- PMM