>
> -- a/target/riscv/tcg/cpu_helper.c
> +++ b/target/riscv/tcg/cpu_helper.c
> @@ -943,11 +943,22 @@ void riscv_cpu_set_mode(CPURISCVState *env,
> privilege_mode_t newpriv,
>  {
>      g_assert(newpriv <= PRV_M && newpriv != PRV_RESERVED);
>
> +    CPUState *cs = env_cpu(env);
> +
>      if (newpriv != env->priv || env->virt_enabled != virt_en) {
>          if (icount_enabled()) {
>              riscv_itrigger_update_priv(env);
>          }
>
> +        if (newpriv != env->priv) {
> +            RISCVCPU *cpu = RISCV_CPU(cs);
> +
> +            if (cpu->trencoder &&
> +                TRACE_ENCODER(cpu->trencoder)->trace_running) {
> +                trencoder_trace_ppccd(cpu->trencoder, env->pc);
> +            }
> +        }
>
On the trap-entry path, env->pc has already been updated to the handler
address, but env->priv still holds the previous privilege level.
Emitting a PPCCD sync packet here therefore pairs the handler PC with
the old privilege level.

Reply via email to