qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Rowan Hart <rowanbhart@gmail.com>
Cc: "Julian Ganz" <neither@nut.email>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v9 3/9] plugins: Add enforcement of QEMU_PLUGIN_CB flags in register R/W callbacks
Date: Mon, 09 Jun 2025 16:20:48 +0100	[thread overview]
Message-ID: <87ikl5kkkv.fsf@draig.linaro.org> (raw)
In-Reply-To: <CAE5MsNZG2S2s=bqJ_kAj=p65_mNf7s0UTpAN1vt75iwm2+YD8A@mail.gmail.com> (Rowan Hart's message of "Mon, 9 Jun 2025 07:55:18 -0700")

Rowan Hart <rowanbhart@gmail.com> writes:

>  However, it should be safe at least for a subset of those callbacks and
>
>  I believe there are very valid use-cases for allowing such usage. For
>  example, we are currently working on a plugin API exposing traps. In
>  those callbacks, users may want to peek at some registers such as
>  "ecause" and "tval" (on RISC-V). We certainly will want to do so for the
>  use-case we are pushing that API for.
>
>  We could add a QEMU_PLUGIN_CB flag parameter to the respective
>  registration functions. But since they are not run from translated
>  blocks but _outside_ that context, I feel they would just clutter the
>  API without introducing any real benefit. That is, if there is no valid
>  safety or correctness concern that I'm not aware of.
>
> This makes sense, I think we could just set QEMU_PLUGIN_CB_RW_REGS for these callbacks if they're always called in a state
> where the stated requirements are met (I think they are). This would avoid breaking compatibility while maintaining the
> functionality. Same as you, I looked around and it seems like the vcpu_(init|idle|exit) locations are definitely okay, I'll check
> into the tb_trans callback, I'm not entirely sure about it.

It should be OK here too.

The CB_RW_REGS flags are only needed for callback from within the
translated code - much like their cousins the TCG helpers. All register
state should rectified if we are no longer running translated code -
indeed currently it is rectified by the time we leave the translated
block and before we start the next one.

There are some edge cases when we handle exceptions but we should have
fixed up any register state before we longjmp back to the start of the
run loop.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2025-06-09 15:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-08 23:08 [PATCH v9 0/9] Add additional plugin API functions to read and write memory and registers Rowan Hart
2025-06-08 23:08 ` [PATCH v9 1/9] gdbstub: Expose gdb_write_register function to consumers of gdbstub Rowan Hart
2025-06-08 23:08 ` [PATCH v9 2/9] plugins: Add register write API Rowan Hart
2025-06-08 23:08 ` [PATCH v9 3/9] plugins: Add enforcement of QEMU_PLUGIN_CB flags in register R/W callbacks Rowan Hart
2025-06-09 13:56   ` Julian Ganz
2025-06-09 14:55     ` Rowan Hart
2025-06-09 15:20       ` Alex Bennée [this message]
2025-06-08 23:08 ` [PATCH v9 4/9] plugins: Add memory virtual address write API Rowan Hart
2025-06-08 23:08 ` [PATCH v9 5/9] plugins: Add memory hardware address read/write API Rowan Hart
2025-06-08 23:08 ` [PATCH v9 6/9] plugins: Add patcher plugin and test Rowan Hart
2025-06-08 23:08 ` [PATCH v9 7/9] plugins: Add hypercalls " Rowan Hart
2025-06-08 23:08 ` [PATCH v9 8/9] plugins: Remove use of qemu_plugin_read_register where it is not permitted Rowan Hart
2025-06-08 23:08 ` [PATCH v9 9/9] plugins: Update plugin version and add notes Rowan Hart
2025-06-09 19:42 ` [PATCH v9 0/9] Add additional plugin API functions to read and write memory and registers Rowan Hart

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=87ikl5kkkv.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=neither@nut.email \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rowanbhart@gmail.com \
    --cc=wangyanan55@huawei.com \
    --cc=zhao1.liu@intel.com \
    /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).