diff mbox

Bug in ppc/BookE wait instruction

Message ID 20160603154549.GA31406@ibawizard (mailing list archive)
State New, archived
Headers show

Commit Message

Jakub Horak June 3, 2016, 3:45 p.m. UTC
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

Comments

Mark Cave-Ayland June 3, 2016, 5:11 p.m. UTC | #1
On 03/06/16 16:45, Jakub Horak wrote:

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

> 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
> 
> 
> diff --git a/target-ppc/translate.c b/target-ppc/translate.c
> index f5ceae5..6af567b 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -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.
David Gibson June 6, 2016, 1:34 a.m. UTC | #2
On Fri, Jun 03, 2016 at 05:45:49PM +0200, Jakub Horak wrote:
> 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.

> 
> 
> diff --git a/target-ppc/translate.c b/target-ppc/translate.c
> index f5ceae5..6af567b 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -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);
>
diff mbox

Patch

diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index f5ceae5..6af567b 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -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);