qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] ppc: Prevent inifnite loop in decrementer auto-


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH] ppc: Prevent inifnite loop in decrementer auto-reload.
Date: Tue, 10 Jan 2017 11:28:15 +1100
User-agent: Mutt/1.7.1 (2016-10-04)

On Mon, Jan 09, 2017 at 12:23:38PM +0100, Roman Kapl wrote:
> If the DECAR register is set to 0, QEMU tries to reload the decrementer with
> zero in an inifinite loop. According to PPC documentation, the decrementer is
> triggered on 1->0 transition, so avoid reloading the decrementer if if is
> already zero.
> 
> The problem does not manifest under Linux, but it is valid to set DECAR to 
> zero
> (and may make sense as part of decrementer initialization when interrupts are
> disabled).
> 
> Signed-off-by: Roman Kapl <address@hidden>

Applied, fixing the coding style nit (no space after if) in the
process.  Please remember to run checkpatch.pl in future.

> ---
>  hw/ppc/ppc_booke.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c
> index ab8d026..f8d5c28 100644
> --- a/hw/ppc/ppc_booke.c
> +++ b/hw/ppc/ppc_booke.c
> @@ -198,8 +198,12 @@ static void booke_decr_cb(void *opaque)
>      booke_update_irq(cpu);
>  
>      if (env->spr[SPR_BOOKE_TCR] & TCR_ARE) {
> -        /* Auto Reload */
> -        cpu_ppc_store_decr(env, env->spr[SPR_BOOKE_DECAR]);
> +        /* Do not reload 0, it is already there. It would just trigger
> +         * the timer again and lead to infinite loop */
> +        if(env->spr[SPR_BOOKE_DECAR] != 0) {
> +            /* Auto Reload */
> +            cpu_ppc_store_decr(env, env->spr[SPR_BOOKE_DECAR]);
> +        }
>      }
>  }
>  

-- 
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

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]