qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Emilio Cota <cota@braap.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, alex.bennee@linaro.org,
	aaron@os.amperecomputing.com,
	frederic.petrot@univ-grenoble-alpes.fr
Subject: Re: [PATCH 1/2] tcg: Clear plugin_mem_cbs on TB exit
Date: Wed, 1 Mar 2023 07:05:28 -0500	[thread overview]
Message-ID: <Y/8/iCIOVdAwcgW0@cota-l14> (raw)
In-Reply-To: <20230301024737.1210851-2-richard.henderson@linaro.org>

As I mentioned in the patch that is being superseded here
I like this approach -- it is simpler and generates less
code.

I'd also like to see the plugin_gen_disable_mem_helpers
function go away, and a mention somewhere that now we are
intentionally not clearing cpu->plugin_mem_cbs until TB exit
(before we weren't doing that either, but that was unintentional
due to a bug).  So, for instance when doing a goto_tb from a
TB with helpers, we leave plugin_mem_cbs set. This is not a
problem in practice because if subsequent TB's use helpers,
they will overwrite the pointer.

Some more comments below.

On Tue, Feb 28, 2023 at 16:47:36 -1000, Richard Henderson wrote:
> Do this in cpu_tb_exec (normal exit) and cpu_loop_exit (exception),
> adjacent to where we reset can_do_io.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1381
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  accel/tcg/cpu-exec-common.c | 4 ++++
>  accel/tcg/cpu-exec.c        | 5 +++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c
> index c7bc8c6efa..e136b0843c 100644
> --- a/accel/tcg/cpu-exec-common.c
> +++ b/accel/tcg/cpu-exec-common.c
> @@ -65,6 +65,10 @@ void cpu_loop_exit(CPUState *cpu)
>  {
>      /* Undo the setting in cpu_tb_exec.  */
>      cpu->can_do_io = 1;
> +#ifdef CONFIG_PLUGIN
> +    /* Undo any setting in generated code. */
> +    cpu->plugin_mem_cbs = NULL;
> +#endif
>      siglongjmp(cpu->jmp_env, 1);
>  }
>  
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 56aaf58b9d..2831fcafee 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -459,6 +459,9 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
>      qemu_thread_jit_execute();
>      ret = tcg_qemu_tb_exec(env, tb_ptr);
>      cpu->can_do_io = 1;
> +#ifdef CONFIG_PLUGIN
> +    cpu->plugin_mem_cbs = NULL;
> +#endif

We should use qemu_plugin_disable_mem_helpers, which avoids the
ifdef.

Also note that there are existing calls to that function that
should now go away because they happen after the clearings here.

Thanks,

		Emilio


  reply	other threads:[~2023-03-01 12:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01  2:47 [PATCH 0/2] plugin: fix clearing of plugin_mem_cbs on TB exit Richard Henderson
2023-03-01  2:47 ` [PATCH 1/2] tcg: Clear " Richard Henderson
2023-03-01 12:05   ` Emilio Cota [this message]
2023-03-02 18:47     ` Richard Henderson
2023-03-02 19:16     ` Richard Henderson
2023-03-01  2:47 ` [PATCH 2/2] include/qemu/plugin: Remove QEMU_PLUGIN_ASSERT Richard Henderson
2023-03-03 16:57 ` [PATCH 0/2] plugin: fix clearing of plugin_mem_cbs on TB exit Alex Bennée

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=Y/8/iCIOVdAwcgW0@cota-l14 \
    --to=cota@braap.org \
    --cc=aaron@os.amperecomputing.com \
    --cc=alex.bennee@linaro.org \
    --cc=frederic.petrot@univ-grenoble-alpes.fr \
    --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 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).