qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 34/34] target-alpha: Emulate LL/SC using cmpx


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v3 34/34] target-alpha: Emulate LL/SC using cmpxchg helpers
Date: Thu, 15 Sep 2016 09:48:15 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 09/15/2016 07:38 AM, Alex Bennée wrote:
+    lab_fail = gen_new_label();
> +    lab_done = gen_new_label();
> +    tcg_gen_brcond_i64(TCG_COND_NE, addr, cpu_lock_addr, lab_fail);
> +    tcg_temp_free_i64(addr);
>
> -        lab_fail = gen_new_label();
> -        lab_done = gen_new_label();
> -        tcg_gen_brcond_i64(TCG_COND_NE, addr, cpu_lock_addr, lab_fail);
> +    val = tcg_temp_new_i64();
> +    tcg_gen_atomic_cmpxchg_i64(val, cpu_lock_addr, cpu_lock_value,
> +                               load_gpr(ctx, ra), mem_idx, op);
> +    free_context_temps(ctx);
I don't quite follow what free_context_temps() is doing and why it needs
to be done twice during the building of this instructions TCGOps?


It's releasing the zero, sink, imm TCGv temporaries from DisasContext, as they're going out of scope within each basic block. Since they're freed, they'll be re-created as necessary in the next basic block.

The two (unlikely) relevant events are: (1) address register = zero register, so the zero temp becomes invalid, and (2) dest register = zero register, so the zero/sink temps become invalid.

It's the kind of thing that really shouldn't ever happen for non-malicious code, but you don't want qemu to abort when invalid temps are used. Perhaps a comment is warranted here...


r~



reply via email to

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