* [Qemu-devel] [PATCH for-2.6] target-sparc: fix ldstub sign-extension bug
@ 2016-04-09 11:43 Mark Cave-Ayland
  2016-04-09 12:49 ` Artyom Tarasenko
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Cave-Ayland @ 2016-04-09 11:43 UTC (permalink / raw)
  To: qemu-devel, peter.maydell, rth, atar4qemu
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>
---
 target-sparc/translate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index 58572c3..7998ff5 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -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);
-- 
1.7.10.4
^ permalink raw reply related	[flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.6] target-sparc: fix ldstub sign-extension bug
  2016-04-09 11:43 [Qemu-devel] [PATCH for-2.6] target-sparc: fix ldstub sign-extension bug Mark Cave-Ayland
@ 2016-04-09 12:49 ` Artyom Tarasenko
  0 siblings, 0 replies; 2+ messages in thread
From: Artyom Tarasenko @ 2016-04-09 12:49 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: qemu-devel, Peter Maydell, Richard Henderson
On Sat, Apr 9, 2016 at 1:43 PM, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
> 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>
> ---
>  target-sparc/translate.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target-sparc/translate.c b/target-sparc/translate.c
> index 58572c3..7998ff5 100644
> --- a/target-sparc/translate.c
> +++ b/target-sparc/translate.c
> @@ -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);
> --
> 1.7.10.4
>
-- 
Regards,
Artyom Tarasenko
SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
^ permalink raw reply	[flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-09 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-09 11:43 [Qemu-devel] [PATCH for-2.6] target-sparc: fix ldstub sign-extension bug Mark Cave-Ayland
2016-04-09 12:49 ` Artyom Tarasenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).