From: "Alex Bennée" <alex.bennee@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: qemu-devel@nongnu.org, Mahmoud Mandour <ma.mandourr@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Alexandre Iooss <erdnaxe@crans.org>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH 4/5] plugins: conditional callbacks
Date: Mon, 11 Mar 2024 15:43:41 +0000 [thread overview]
Message-ID: <87zfv4pydu.fsf@draig.linaro.org> (raw)
In-Reply-To: <20240229055359.972151-5-pierrick.bouvier@linaro.org> (Pierrick Bouvier's message of "Thu, 29 Feb 2024 09:53:58 +0400")
Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> Extend plugins API to support callback called with a given criteria
> (evaluated inline).
>
> Added functions:
> - qemu_plugin_register_vcpu_tb_exec_cond_cb
> - qemu_plugin_register_vcpu_insn_exec_cond_cb
>
> They expect as parameter a condition, a qemu_plugin_u64_t (op1) and an
> immediate (op2). Callback is called if op1 |cond| op2 is true.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
<snip>
>
> +static TCGCond plugin_cond_to_tcgcond(enum qemu_plugin_cond cond)
> +{
> + switch (cond) {
> + case QEMU_PLUGIN_COND_EQ:
> + return TCG_COND_EQ;
> + case QEMU_PLUGIN_COND_NE:
> + return TCG_COND_NE;
> + case QEMU_PLUGIN_COND_LT:
> + return TCG_COND_LTU;
> + case QEMU_PLUGIN_COND_LE:
> + return TCG_COND_LEU;
> + case QEMU_PLUGIN_COND_GT:
> + return TCG_COND_GTU;
> + case QEMU_PLUGIN_COND_GE:
> + return TCG_COND_GEU;
> + default:
> + /* ALWAYS and NEVER conditions should never reach */
> + g_assert_not_reached();
> + }
> +}
> +
> +static TCGOp *append_cond_udata_cb(const struct qemu_plugin_dyn_cb *cb,
> + TCGOp *begin_op, TCGOp *op, int *cb_idx)
> +{
> + char *ptr = cb->cond_cb.entry.score->data->data;
> + size_t elem_size = g_array_get_element_size(
> + cb->cond_cb.entry.score->data);
> + size_t offset = cb->cond_cb.entry.offset;
> + /* Condition should be negated, as calling the cb is the "else" path */
> + TCGCond cond = tcg_invert_cond(plugin_cond_to_tcgcond(cb->cond_cb.cond));
> +
> + op = copy_const_ptr(&begin_op, op, ptr);
> + op = copy_ld_i32(&begin_op, op);
> + op = copy_mul_i32(&begin_op, op, elem_size);
> + op = copy_ext_i32_ptr(&begin_op, op);
> + op = copy_const_ptr(&begin_op, op, ptr + offset);
> + op = copy_add_ptr(&begin_op, op);
> + op = copy_ld_i64(&begin_op, op);
> + op = copy_brcondi_i64(&begin_op, op, cond, cb->cond_cb.imm);
> + op = copy_call(&begin_op, op, cb->f.vcpu_udata, cb_idx);
> + op = copy_set_label(&begin_op, op);
> + return op;
I think we are missing something here to ensure that udata is set
correctly for the callback, see my RFC:
Subject: [RFC PATCH] contrib/plugins: control flow plugin (WIP!)
Date: Mon, 11 Mar 2024 15:34:32 +0000
Message-Id: <20240311153432.1395190-1-alex.bennee@linaro.org>
which is seeing the same value every time in the callback.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2024-03-11 15:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 5:53 [PATCH 0/5] TCG plugins new inline operations Pierrick Bouvier
2024-02-29 5:53 ` [PATCH 1/5] plugins: prepare introduction of new inline ops Pierrick Bouvier
2024-02-29 5:53 ` [PATCH 2/5] plugins: add new inline op STORE_U64 Pierrick Bouvier
2024-02-29 5:53 ` [PATCH 3/5] tests/plugin/inline: add test for STORE_U64 inline op Pierrick Bouvier
2024-02-29 5:53 ` [PATCH 4/5] plugins: conditional callbacks Pierrick Bouvier
2024-03-11 10:08 ` Alex Bennée
2024-03-12 6:03 ` Pierrick Bouvier
2024-03-12 15:04 ` Alex Bennée
2024-03-12 16:04 ` Pierrick Bouvier
2024-03-11 15:43 ` Alex Bennée [this message]
2024-03-12 6:03 ` Pierrick Bouvier
2024-03-12 7:37 ` Pierrick Bouvier
2024-02-29 5:53 ` [PATCH 5/5] tests/plugin/inline: add test for condition callback Pierrick Bouvier
2024-03-08 10:41 ` [PATCH 0/5] TCG plugins new inline operations Pierrick Bouvier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zfv4pydu.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=pbonzini@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.