On Wed, 2026-11-11 at 04:06 -0300, Daniel Henrique Barboza wrote:
> We're leaving env->itrigger_enabled untouched during reset() while at
> the same time resetting triggers to AD_MATCH (type 2).
>
> So, in case we reset the CPU during an itrigger session, translation
> code will enter itrigger_match helper every time (via ctx->itrigger),
> and the helper will do nothing since there's no type 3 triggers set.
> And we'll keep doing that until something else clears
> env->itrigger_enabled. This is a niche case that it's a bit hard to
> hit
> but it will cost a bit of performance for no good reason.
>
> Found while reviewing an itrigger related patch.
>
> Fixes: 577f02869488 ("target/riscv: Add itrigger_enabled field to
> CPURISCVState").
> Signed-off-by: Daniel Henrique Barboza
> <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Alistair
> ---
> target/riscv/tcg/debug.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/target/riscv/tcg/debug.c b/target/riscv/tcg/debug.c
> index 8b58cbd07a..988bc815d7 100644
> --- a/target/riscv/tcg/debug.c
> +++ b/target/riscv/tcg/debug.c
> @@ -1213,4 +1213,5 @@ void riscv_trigger_reset_hold(CPURISCVState
> *env)
> }
>
> env->mcontext = 0;
> + env->itrigger_enabled = false;
> }