]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target-sparc: fix ldstub sign-extension bug
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Sat, 9 Apr 2016 11:25:12 +0000 (12:25 +0100)
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Mon, 11 Apr 2016 15:25:07 +0000 (16:25 +0100)
ldstub [addr], reg incorrectly reads a signed byte from memory which causes
problems in the 32-bit Solaris mutex code. Here the byte value being read is
0xff which is incorrectly sign-extended to 0xffffffff before being written back
to the target register causing lock detection to behave incorrectly.

This fixes the intermittent hangs and MUTEX_HELD warnings issued to the
console when running 32-bit Solaris images under qemu-system-sparc.

With thanks to Joseph Dery for providing a condensed test image to consistently
reproduce the problem on demand, and Martin Husemann for allowing me access to
real hardware for comparison.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-By: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
target-sparc/translate.c

index 58572c34cf3e518237c6bb2fbde03a2c58c3013a..7998ff57bf09598f63b2a7870f782b0d67ff9ee3 100644 (file)
@@ -4670,7 +4670,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
                         TCGv r_const;
 
                         gen_address_mask(dc, cpu_addr);
-                        tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx);
+                        tcg_gen_qemu_ld8u(cpu_val, cpu_addr, dc->mem_idx);
                         r_const = tcg_const_tl(0xff);
                         tcg_gen_qemu_st8(r_const, cpu_addr, dc->mem_idx);
                         tcg_temp_free(r_const);