target-sparc: fix register corruption in ldstub if there is no write permission
authorArtyom Tarasenko <atar4qemu@gmail.com>
Fri, 24 Jun 2016 12:34:30 +0000 (14:34 +0200)
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Fri, 24 Jun 2016 17:18:32 +0000 (18:18 +0100)
Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
target-sparc/translate.c

index afd46b878f07431e89cd79c48d6450abd12a1dbf..0f4faf70624fd5b0aff40971a104ca25becd932e 100644 (file)
@@ -4679,12 +4679,15 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
                 case 0xd:       /* ldstub -- XXX: should be atomically */
                     {
                         TCGv r_const;
+                        TCGv tmp = tcg_temp_new();
 
                         gen_address_mask(dc, cpu_addr);
-                        tcg_gen_qemu_ld8u(cpu_val, cpu_addr, dc->mem_idx);
+                        tcg_gen_qemu_ld8u(tmp, cpu_addr, dc->mem_idx);
                         r_const = tcg_const_tl(0xff);
                         tcg_gen_qemu_st8(r_const, cpu_addr, dc->mem_idx);
+                        tcg_gen_mov_tl(cpu_val, tmp);
                         tcg_temp_free(r_const);
+                        tcg_temp_free(tmp);
                     }
                     break;
                 case 0x0f: