qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 07/22] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN


From: Pierrick Bouvier
Subject: Re: [PATCH 07/22] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN
Date: Wed, 20 Mar 2024 09:36:24 +0400
User-agent: Mozilla Thunderbird

On 3/19/24 23:56, Richard Henderson wrote:
On 3/19/24 03:32, Pierrick Bouvier wrote:
   static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb)
   {
-    TCGOp *op;
+    TCGOp *op, *next;
       int insn_idx = -1;
       pr_ops();
-    QTAILQ_FOREACH(op, &tcg_ctx->ops, link) {
+    /*
+     * While injecting code, we cannot afford to reuse any ebb temps
+     * that might be live within the existing opcode stream.
+     * The simplest solution is to release them all and create new.
+     */
+    memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps));
+

Not an expert at this, but wouldn't that break an existing TB that already has 
some ops on
those temps?

No, this only affects allocation of new temps -- if free_temps is empty, a new 
temp will
be allocated from tcg_ctx->nb_temps++.

Zeroing free_temps here ensures that we *do not* reuse a temp that might 
already be live
across any plugin insertion point.  Between insertion points, we will free 
plugin temps
and only reuse those.


Thanks, by looking at tcg_temp_new_internal fn, and with your explaination, it makes more sense.


r~

reply via email to

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