Skip to contentSkip to conversation

Bug in ppc/BookE wait instruction

Qemu-devel Jakub Horak 3 participants 5 messages Jun 3, 2016 – Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello,
I think there's a bug in "wait" instruction code generator for PowerPC architecture. It doesn't make sense to store a non-initialized register.

Best regards,
Jakub Horak

target-ppc/translate.c +1 -1
index f5ceae5..6af567b 100644
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);
#1 lore raw

On 03/06/16 16:45, Jakub Horak wrote:

(Added David as PPC maintainer and qemu-ppc mailing list)

Quoted 14 lines

Hello,
I think there's a bug in "wait" instruction code generator for PowerPC architecture. It doesn't make sense to store a non-initialized register.

Best regards,
Jakub Horak

target-ppc/translate.c +0 -0
index f5ceae5..6af567b 100644

target-ppc/translate.c static void gen_sync(DisasContext *ctx) · line 3445

Quoted 8 lines
target-ppc/translate.c +1 -1
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);

ATB,

Mark.

#2 lore raw
In reply to Jakub Horak
Quoted 6 lines · Jakub Horak

Hello,
I think there's a bug in "wait" instruction code generator for PowerPC architecture. It doesn't make sense to store a non-initialized register.

Best regards,
Jakub Horak

The fix looks correct, but I need a Signed-off-by line in order to apply it.

In future, please send such patches to myself and Alex Graf (target-ppc maintainers) the qemu-ppc list as well as qemu-devel. I wouldn't have spotted this if Marc Cave-Ayland hadn't copied it to me.

Quoted 16 lines
target-ppc/translate.c +1 -1
index f5ceae5..6af567b 100644
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw

Hello,

Quoted 10 lines · David Gibson
Quoted 6 lines · Jakub Horak

Hello,
I think there's a bug in "wait" instruction code generator for PowerPC architecture. It doesn't make sense to store a non-initialized register.

Best regards,
Jakub Horak

The fix looks correct, but I need a Signed-off-by line in order to apply it.

Here you go:

Fixed bug in code generator.

target-ppc/translate.c +1 -1
index f5ceae5..6af567b 100644
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);
Quoted 4 lines

In future, please send such patches to myself and Alex Graf (target-ppc maintainers) the qemu-ppc list as well as qemu-devel. I wouldn't have spotted this if Marc Cave-Ayland hadn't copied it to me.

Sorry, I'll be more thoughtful next time.

Best regards,
Jakub

Quoted 23 lines
Quoted 17 lines
target-ppc/translate.c +1 -1
index f5ceae5..6af567b 100644
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw
Quoted 37 lines · Jakub Horak

Hello,

Quoted 10 lines · David Gibson
Quoted 6 lines · Jakub Horak

Hello,
I think there's a bug in "wait" instruction code generator for PowerPC architecture. It doesn't make sense to store a non-initialized register.

Best regards,
Jakub Horak

The fix looks correct, but I need a Signed-off-by line in order to apply it.

Here you go:

Fixed bug in code generator.

target-ppc/translate.c +1 -1
index f5ceae5..6af567b 100644
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);
Quoted 3 lines
Quoted 5 lines
Quoted 3 lines

In future, please send such patches to myself and Alex Graf (target-ppc maintainers) the qemu-ppc list as well as qemu-devel. I wouldn't have spotted this if Marc Cave-Ayland hadn't copied it to me.

Sorry, I'll be more thoughtful next time.

Sorry, I forgot about this one after you resent, I've now applied to ppc-for-2.7.

Quoted 25 lines

Best regards,
Jakub

Quoted 18 lines
Quoted 17 lines
target-ppc/translate.c +1 -1
index f5ceae5..6af567b 100644
@@ -3439,7 +3439,7 @@ static void gen_sync(DisasContext *ctx)
 /* wait */
 static void gen_wait(DisasContext *ctx)
 {
-    TCGv_i32 t0 = tcg_temp_new_i32();
+    TCGv_i32 t0 = tcg_const_i32(1);
     tcg_gen_st_i32(t0, cpu_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
     tcg_temp_free_i32(t0);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson