Skip to contentSkip to conversation

tcg/ppc: Do not overwrite lower address word on Darwin and AIX

RFC In review Andreas Färber 2 participants 4 messages May 6, 2012

lore
Share & tools
lore
#0 lore raw

RFC 1/1 tcg/ppc: Do not overwrite lower address word on Darwin and AIX

For targets where TARGET_LONG_BITS != 32, i.e. 64-bit guests, addr_reg is moved to r4. For hosts with TCG_TARGET_CALL_ALIGN_ARGS either data_reg2 or data_reg or a masked version thereof would overwrite r4. Place it in r5 instead, matching TCG_TARGET_CALL_ALIGN_ARGS hosts.

This might explain crashes observed on Darwin/ppc but not on ppc64.

---
 tcg/ppc/tcg-target.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
tcg/ppc/tcg-target.c +0 -4
index dc40716..4b85c89 100644
@@ -816,11 +816,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
 #else
     tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2);
     tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg);
-#ifdef TCG_TARGET_CALL_ALIGN_ARGS
     ir = 5;
-#else
-    ir = 4;
-#endif
 #endif
 
     switch (opc) {
Signature · 1 line
1.7.7
#1 lore raw
Quoted 19 lines · Andreas F?rber

For targets where TARGET_LONG_BITS != 32, i.e. 64-bit guests, addr_reg is moved to r4. For hosts with TCG_TARGET_CALL_ALIGN_ARGS either data_reg2 or data_reg or a masked version thereof would overwrite r4. Place it in r5 instead, matching TCG_TARGET_CALL_ALIGN_ARGS hosts.

This might explain crashes observed on Darwin/ppc but not on ppc64.

---
 tcg/ppc/tcg-target.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
tcg/ppc/tcg-target.c +0 -0
index dc40716..4b85c89 100644
@@ -816,11 +816,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
 #else

tcg/ppc/tcg-target.c static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc) · line 822

Quoted 10 lines
tcg/ppc/tcg-target.c +0 -4
     tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2);
     tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg);
-#ifdef TCG_TARGET_CALL_ALIGN_ARGS
     ir = 5;
-#else
-    ir = 4;
-#endif
 #endif
 
     switch (opc) {

Right you are.

Signature · 1 line
mailto:[email protected]
#2 lore raw

Am 06.05.2012 22:01, schrieb malc:

Quoted 29 lines · Andreas F?rber
Quoted 28 lines

For targets where TARGET_LONG_BITS != 32, i.e. 64-bit guests, addr_reg is moved to r4. For hosts [without] TCG_TARGET_CALL_ALIGN_ARGS either data_reg2 or data_reg or a masked version thereof would overwrite r4. Place it in r5 instead, matching TCG_TARGET_CALL_ALIGN_ARGS hosts.

This might explain crashes observed on Darwin/ppc but not on ppc64.

---
 tcg/ppc/tcg-target.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
tcg/ppc/tcg-target.c +0 -4
index dc40716..4b85c89 100644
@@ -816,11 +816,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
 #else
     tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2);
     tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg);
-#ifdef TCG_TARGET_CALL_ALIGN_ARGS
     ir = 5;
-#else
-    ir = 4;
-#endif
 #endif
 
Quoted 4 lines

tcg/ppc/tcg-target.c static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc) · line 822

Quoted 2 lines
tcg/ppc/tcg-target.c +0 -0
     switch (opc) {

Right you are.

Confirmed with qemu-system-x86_64 on Darwin/ppc - hangs without, works with patch. Thanks for making me aware of that line of code. :)

I'll have a suggestion how to simplify your updated patch and will resubmit fixed as [PATCH] series after testing. Hoping you can get a non-Umlaut-broken version from Patchwork. ;)

Cheers,
Andreas

#3 lore raw
In reply to Andreas Färber

Am 06.05.2012 21:38, schrieb Andreas Färber:

Quoted 2 lines

For targets where TARGET_LONG_BITS != 32, i.e. 64-bit guests, addr_reg is moved to r4. For hosts with TCG_TARGET_CALL_ALIGN_ARGS

Er, obviously I meant "without". :)

/-F

Quoted 26 lines

either data_reg2 or data_reg or a masked version thereof would overwrite r4. Place it in r5 instead, matching TCG_TARGET_CALL_ALIGN_ARGS hosts.

This might explain crashes observed on Darwin/ppc but not on ppc64.

---
 tcg/ppc/tcg-target.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
tcg/ppc/tcg-target.c +0 -4
index dc40716..4b85c89 100644
@@ -816,11 +816,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
 #else
     tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2);
     tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg);
-#ifdef TCG_TARGET_CALL_ALIGN_ARGS
     ir = 5;
-#else
-    ir = 4;
-#endif
 #endif
 
     switch (opc) {