* [Qemu-devel] [PATCH v3 for-1.1-rc1 1/4] tcg/ppc: Do not overwrite lower address word on Darwin and AIX
2012-05-09 17:26 [Qemu-devel] [PATCH v3 for-1.1-rc1 0/4] tcg/ppc: AREG0 support and Darwin fixes Andreas Färber
@ 2012-05-09 17:26 ` Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 2/4] tcg/ppc: Don't hardcode register numbers Andreas Färber
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2012-05-09 17:26 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, Andreas Färber, agraf, anthony
From: Andreas Färber <andreas.faerber@web.de>
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 fixes immediate crashes of 64-bit guests observed on Darwin/ppc but
not on Darwin/ppc64.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Acked-by: malc <av1474@comtv.ru>
Acked-by: Alexander Graf <agraf@suse.de>
---
tcg/ppc/tcg-target.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c
index dc40716..4b85c89 100644
--- a/tcg/ppc/tcg-target.c
+++ b/tcg/ppc/tcg-target.c
@@ -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) {
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 for-1.1-rc1 2/4] tcg/ppc: Don't hardcode register numbers
2012-05-09 17:26 [Qemu-devel] [PATCH v3 for-1.1-rc1 0/4] tcg/ppc: AREG0 support and Darwin fixes Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 1/4] tcg/ppc: Do not overwrite lower address word on Darwin and AIX Andreas Färber
@ 2012-05-09 17:26 ` Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 3/4] tcg/ppc: Clobber r5 for 64-bit qemu_ld Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode Andreas Färber
3 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2012-05-09 17:26 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, anthony, Andreas Färber
Also assure i64 alignment where necessary.
Alignment code optimization suggested by malc.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Alexander Graf <agraf@suse.de>
---
tcg/ppc/tcg-target.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c
index 4b85c89..b4e0466 100644
--- a/tcg/ppc/tcg-target.c
+++ b/tcg/ppc/tcg-target.c
@@ -552,7 +552,7 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)
{
int addr_reg, data_reg, data_reg2, r0, r1, rbase, bswap;
#ifdef CONFIG_SOFTMMU
- int mem_index, s_bits, r2;
+ int mem_index, s_bits, r2, ir;
void *label1_ptr, *label2_ptr;
#if TARGET_LONG_BITS == 64
int addr_reg2;
@@ -614,14 +614,17 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)
#endif
/* slow path */
+ ir = 3;
#if TARGET_LONG_BITS == 32
- tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg);
- tcg_out_movi (s, TCG_TYPE_I32, 4, mem_index);
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#else
- tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2);
- tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg);
- tcg_out_movi (s, TCG_TYPE_I32, 5, mem_index);
+#ifdef TCG_TARGET_CALL_ALIGN_ARGS
+ ir |= 1;
+#endif
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg2);
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#endif
+ tcg_out_movi (s, TCG_TYPE_I32, ir, mem_index);
tcg_out_call (s, (tcg_target_long) qemu_ld_helpers[s_bits], 1);
switch (opc) {
@@ -810,13 +813,15 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
#endif
/* slow path */
+ ir = 3;
#if TARGET_LONG_BITS == 32
- tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg);
- ir = 4;
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#else
- tcg_out_mov (s, TCG_TYPE_I32, 3, addr_reg2);
- tcg_out_mov (s, TCG_TYPE_I32, 4, addr_reg);
- ir = 5;
+#ifdef TCG_TARGET_CALL_ALIGN_ARGS
+ ir |= 1;
+#endif
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg2);
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#endif
switch (opc) {
@@ -841,7 +846,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
break;
case 3:
#ifdef TCG_TARGET_CALL_ALIGN_ARGS
- ir = 5;
+ ir |= 1;
#endif
tcg_out_mov (s, TCG_TYPE_I32, ir++, data_reg2);
tcg_out_mov (s, TCG_TYPE_I32, ir, data_reg);
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 for-1.1-rc1 3/4] tcg/ppc: Clobber r5 for 64-bit qemu_ld
2012-05-09 17:26 [Qemu-devel] [PATCH v3 for-1.1-rc1 0/4] tcg/ppc: AREG0 support and Darwin fixes Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 1/4] tcg/ppc: Do not overwrite lower address word on Darwin and AIX Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 2/4] tcg/ppc: Don't hardcode register numbers Andreas Färber
@ 2012-05-09 17:26 ` Andreas Färber
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode Andreas Färber
3 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2012-05-09 17:26 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, anthony, Andreas Färber
This accounts for the additional addr_reg2 register.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Alexander Graf <agraf@suse.de>
---
tcg/ppc/tcg-target.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c
index b4e0466..20888e2 100644
--- a/tcg/ppc/tcg-target.c
+++ b/tcg/ppc/tcg-target.c
@@ -244,6 +244,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
tcg_regset_set32(ct->u.regs, 0, 0xffffffff);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R4);
+#if TARGET_LONG_BITS == 64
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5);
+#endif
break;
case 'K': /* qemu_st[8..32] constraint */
ct->ct |= TCG_CT_REG;
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
2012-05-09 17:26 [Qemu-devel] [PATCH v3 for-1.1-rc1 0/4] tcg/ppc: AREG0 support and Darwin fixes Andreas Färber
` (2 preceding siblings ...)
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 3/4] tcg/ppc: Clobber r5 for 64-bit qemu_ld Andreas Färber
@ 2012-05-09 17:26 ` Andreas Färber
2012-05-09 17:53 ` malc
3 siblings, 1 reply; 7+ messages in thread
From: Andreas Färber @ 2012-05-09 17:26 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, agraf, anthony, Andreas Färber
Adjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3,
based on patches by malc.
Also adjust the registers clobbered, based on patch by Alex.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Alexander Graf <agraf@suse.de>
[AF: Do not hardcode r3 for AREG0, requested by Alex]
---
tcg/ppc/tcg-target.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c
index 20888e2..4cde48d 100644
--- a/tcg/ppc/tcg-target.c
+++ b/tcg/ppc/tcg-target.c
@@ -244,9 +244,19 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
tcg_regset_set32(ct->u.regs, 0, 0xffffffff);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R4);
+#ifdef CONFIG_TCG_PASS_AREG0
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5);
+#if TARGET_LONG_BITS == 64
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R6);
+#ifdef TCG_TARGET_CALL_ALIGN_ARGS
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R7);
+#endif
+#endif
+#else /* !AREG0 */
#if TARGET_LONG_BITS == 64
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5);
#endif
+#endif
break;
case 'K': /* qemu_st[8..32] constraint */
ct->ct |= TCG_CT_REG;
@@ -254,9 +264,19 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R3);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R4);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5);
+#ifdef CONFIG_TCG_PASS_AREG0
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R6);
+#if TARGET_LONG_BITS == 64
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R7);
+#ifdef TCG_TARGET_CALL_ALIGN_ARGS
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R8);
+#endif
+#endif
+#else /* !AREG0 */
#if TARGET_LONG_BITS == 64
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R6);
#endif
+#endif
break;
case 'M': /* qemu_st64 constraint */
ct->ct |= TCG_CT_REG;
@@ -266,6 +286,12 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R5);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R6);
tcg_regset_reset_reg(ct->u.regs, TCG_REG_R7);
+#if defined(CONFIG_TCG_PASS_AREG0)
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R8);
+#ifdef TCG_TARGET_CALL_ALIGN_ARGS
+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_R9);
+#endif
+#endif
break;
#else
case 'L':
@@ -512,7 +538,6 @@ static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg)
#include "../../softmmu_defs.h"
#ifdef CONFIG_TCG_PASS_AREG0
-#error CONFIG_TCG_PASS_AREG0 is not supported
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
@@ -618,6 +643,9 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)
/* slow path */
ir = 3;
+#ifdef CONFIG_TCG_PASS_AREG0
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, TCG_AREG0);
+#endif
#if TARGET_LONG_BITS == 32
tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#else
@@ -817,6 +845,9 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
/* slow path */
ir = 3;
+#ifdef CONFIG_TCG_PASS_AREG0
+ tcg_out_mov (s, TCG_TYPE_I32, ir++, TCG_AREG0);
+#endif
#if TARGET_LONG_BITS == 32
tcg_out_mov (s, TCG_TYPE_I32, ir++, addr_reg);
#else
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
2012-05-09 17:26 ` [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode Andreas Färber
@ 2012-05-09 17:53 ` malc
2012-05-09 18:03 ` Andreas Färber
0 siblings, 1 reply; 7+ messages in thread
From: malc @ 2012-05-09 17:53 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-ppc, qemu-devel, anthony, agraf
On Wed, 9 May 2012, Andreas F?rber wrote:
> Adjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3,
> based on patches by malc.
>
> Also adjust the registers clobbered, based on patch by Alex.
ppc64 is similarly broken in pass areg0 case.
[..snip..]
--
mailto:av1474@comtv.ru
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 for-1.1-rc1 4/4] tcg/ppc: Fix CONFIG_TCG_PASS_AREG0 mode
2012-05-09 17:53 ` malc
@ 2012-05-09 18:03 ` Andreas Färber
0 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2012-05-09 18:03 UTC (permalink / raw)
To: malc, anthony; +Cc: qemu-ppc, qemu-devel, agraf
Am 09.05.2012 19:53, schrieb malc:
> On Wed, 9 May 2012, Andreas F?rber wrote:
>
>> Adjust the tcg_out_qemu_{ld,st}() slow paths to pass AREG0 in r3,
>> based on patches by malc.
>>
>> Also adjust the registers clobbered, based on patch by Alex.
>
> ppc64 is similarly broken in pass areg0 case.
>
> [..snip..]
FWIW I plan to review that next. Please don't add any #error before rc1.
Note to Anthony: That's about tcg/ppc64. I'm positive we can fix any
obvious issues there in time for rc2.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 7+ messages in thread