qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH v2] accel/tcg: re-factor plugin_inject_cb so we can assert insn_idx is valid
Date: Tue, 14 Sep 2021 05:59:19 -0700	[thread overview]
Message-ID: <13d54353-6223-cfca-908a-6c17d13294cc@linaro.org> (raw)
In-Reply-To: <20210914120418.1388698-1-alex.bennee@linaro.org>

On 9/14/21 5:04 AM, Alex Bennée wrote:
> Coverity doesn't know enough about how we have arranged our plugin TCG
> ops to know we will always have incremented insn_idx before injecting
> the callback. Let us assert it for the benefit of Coverity and protect
> ourselves from accidentally breaking the assumption and triggering
> harder to grok errors deeper in the code if we attempt a negative
> indexed array lookup.
> 
> However to get to this point we re-factor the code and remove the
> second hand instruction boundary detection in favour of scanning the
> full set of ops and using the existing INDEX_op_insn_start to cleanly
> detect when the instruction has started. As we no longer need the
> plugin specific list of ops we delete that.
> 
> My initial benchmarks shows no discernible impact of dropping the
> plugin specific ops list.
> 
> Fixes: Coverity 1459509
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/tcg/tcg.h      |   3 -
>   accel/tcg/plugin-gen.c | 157 ++++++++++++++++++++++-------------------
>   2 files changed, 85 insertions(+), 75 deletions(-)
> 
> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
> index 44ccd86f3e..49a02db7e6 100644
> --- a/include/tcg/tcg.h
> +++ b/include/tcg/tcg.h
> @@ -604,9 +604,6 @@ struct TCGContext {
>   
>       /* descriptor of the instruction being translated */
>       struct qemu_plugin_insn *plugin_insn;
> -
> -    /* list to quickly access the injected ops */
> -    QSIMPLEQ_HEAD(, TCGOp) plugin_ops;
>   #endif
>   
>       GHashTable *const_table[TCG_TYPE_COUNT];
> diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
> index 88e25c6df9..f145b815c0 100644
> --- a/accel/tcg/plugin-gen.c
> +++ b/accel/tcg/plugin-gen.c
> @@ -163,11 +163,7 @@ static void gen_empty_mem_helper(void)
>   static void gen_plugin_cb_start(enum plugin_gen_from from,
>                                   enum plugin_gen_cb type, unsigned wr)
>   {
> -    TCGOp *op;
> -
>       tcg_gen_plugin_cb_start(from, type, wr);
> -    op = tcg_last_op();
> -    QSIMPLEQ_INSERT_TAIL(&tcg_ctx->plugin_ops, op, plugin_link);

The plugin_link field of TCGOp is now dead too.  Otherwise,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


      reply	other threads:[~2021-09-14 13:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 12:04 [RFC PATCH v2] accel/tcg: re-factor plugin_inject_cb so we can assert insn_idx is valid Alex Bennée
2021-09-14 12:59 ` Richard Henderson [this message]

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=13d54353-6223-cfca-908a-6c17d13294cc@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).