qemu-ppc
[Top][All Lists]
Advanced

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

Re: [PATCH] target/ppc: fix icount support on Book-e vms accessing SPRs


From: David Gibson
Subject: Re: [PATCH] target/ppc: fix icount support on Book-e vms accessing SPRs
Date: Fri, 5 Mar 2021 12:10:53 +1100

On Wed, Mar 03, 2021 at 05:08:51PM +0300, Vitaly Cheptsov wrote:
65;6203;1c> Failing to guard SPR access with gen_io_start/gen_stop_exception
> causes "Bad icount read" exceptions when running VMs with
> e500mc and e500v2 CPUs with an icount parameter.
> 
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Greg Kurz <groug@kaod.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>

Applied to ppc-for-6.0, thanks.

> ---
>  target/ppc/translate_init.c.inc | 36 +++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc
> index e7324e85cd..09c9ae2c98 100644
> --- a/target/ppc/translate_init.c.inc
> +++ b/target/ppc/translate_init.c.inc
> @@ -567,35 +567,71 @@ static void spr_write_601_ubatl(DisasContext *ctx, int 
> sprn, int gprn)
>  #if !defined(CONFIG_USER_ONLY)
>  static void spr_read_40x_pit(DisasContext *ctx, int gprn, int sprn)
>  {
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_io_start();
> +    }
>      gen_helper_load_40x_pit(cpu_gpr[gprn], cpu_env);
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_stop_exception(ctx);
> +    }
>  }
>  
>  static void spr_write_40x_pit(DisasContext *ctx, int sprn, int gprn)
>  {
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_io_start();
> +    }
>      gen_helper_store_40x_pit(cpu_env, cpu_gpr[gprn]);
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_stop_exception(ctx);
> +    }
>  }
>  
>  static void spr_write_40x_dbcr0(DisasContext *ctx, int sprn, int gprn)
>  {
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_io_start();
> +    }
>      gen_store_spr(sprn, cpu_gpr[gprn]);
>      gen_helper_store_40x_dbcr0(cpu_env, cpu_gpr[gprn]);
>      /* We must stop translation as we may have rebooted */
>      gen_stop_exception(ctx);
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_stop_exception(ctx);
> +    }
>  }
>  
>  static void spr_write_40x_sler(DisasContext *ctx, int sprn, int gprn)
>  {
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_io_start();
> +    }
>      gen_helper_store_40x_sler(cpu_env, cpu_gpr[gprn]);
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_stop_exception(ctx);
> +    }
>  }
>  
>  static void spr_write_booke_tcr(DisasContext *ctx, int sprn, int gprn)
>  {
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_io_start();
> +    }
>      gen_helper_store_booke_tcr(cpu_env, cpu_gpr[gprn]);
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_stop_exception(ctx);
> +    }
>  }
>  
>  static void spr_write_booke_tsr(DisasContext *ctx, int sprn, int gprn)
>  {
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_io_start();
> +    }
>      gen_helper_store_booke_tsr(cpu_env, cpu_gpr[gprn]);
> +    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> +        gen_stop_exception(ctx);
> +    }
>  }
>  #endif
>  

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