From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Julian Ganz" <nenut@skiff.uberspace.de>
Cc: "Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Julian Ganz" <neither@nut.email>,
qemu-devel@nongnu.org
Subject: Re: [RFC PATCH v2 0/7] tcg-plugins: add hooks for interrupts, exceptions and traps
Date: Tue, 22 Oct 2024 09:58:18 +0100 [thread overview]
Message-ID: <87wmi0ms45.fsf@draig.linaro.org> (raw)
In-Reply-To: <ab29d100610abcc59ce2305a1ace1ac0b53340a3@skiff.uberspace.de> (Julian Ganz's message of "Tue, 22 Oct 2024 08:21:22 +0000")
"Julian Ganz" <nenut@skiff.uberspace.de> writes:
> Hi, Pierrick,
>
> October 21, 2024 at 11:59 PM, "Pierrick Bouvier" wrote:
>> On 10/21/24 14:02, Julian Ganz wrote:
>> > The motivation for this API is a plugin that simulates a RISC-V tracing
>> > unit (and produces a trace). For that we actually also needed to
>> > track the "regular" control flow, i.e. find out whether a branch was
>> > taken or where a jump went. That wasn't hard, especially considering
>> > that the TCG API already gives you (more or less) basic blocks. Still,
>> > we ended up tracing every instruction because that made some of the logic
>> > much simpler and easier to reason about.
>> > We realized that we need a trap API because they:
>> > * can occur at any time/point of execusion
>> > * usually come with additional effects such as mode changes.
>> >
>> Thanks for sharing your insights.
>> I think there is definitely value in what you offer, and I'm trying
>> to think how we could extend it in the future easily, without having
>> another callback when a new event appear. In my experience on
>> plugins, the least callbacks we have, and the simpler they are, the
>> better it is.
>>
>> Maybe we could have a single API like:
>>
<snip>
>
> Traps are just too diverse, imo there is too little overlap between
> different architectures, with the sole exception maybe being the PC
> prior to the trap. "Interrupt id" sounds like a reasonably common
> concept, but then you would need to define a mapping for each and every
> architecture. What integer type do you use? In RISC-V, for example,
> exceptions and interrupt "ids" are differentiated via the most
> significant bit. Dou keep that or do you zero it? And then there's
> ring/privilage mode, cause (sometimes for each mode), ...
>
> It would also complicate call sites for hooks in target code. You'd
> either need awkwardly long function signitures or setup code for that
> struct. Both are things you don't want, as a hook call site should
> never distract from the actual logic surrounding them. You could
> probably have something reasonable in Rust, using a builder/command
> pattern. But in C this would require too much boiler plate code than
> I'd be comfortable with.
How easy would it be to expose a Rust API? I'm curious because now we
are looking to integrate Rust into QEMU we could consider transitioning
to a Rust API for plugins. It has been done before:
https://github.com/novafacing/qemu-rs/tree/main/qemu-plugin-sys
and
https://github.com/novafacing/qemu-rs/tree/main/qemu-plugin
I'm curious as to what it would look like. I don't know how tenable it
would be to run 2 plugin APIs side-by-side long term though. We would
probably want to make a choice. Also how would that affect other C like
APIs like python?
>
> Regards,
> Julian
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2024-10-22 8:58 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 12:24 [PATCH] tcg-plugins: add a hook for interrupts, exceptions and traps Julian Ganz
2023-10-23 13:08 ` Alex Bennée
2023-10-23 18:45 ` Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 0/7] tcg-plugins: add hooks " Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 1/7] plugins: add API for registering trap related callbacks Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 2/7] plugins: add hooks for new " Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 3/7] contrib/plugins: add plugin showcasing new trap related API Julian Ganz
2024-10-21 18:06 ` Pierrick Bouvier
2024-10-21 18:07 ` Pierrick Bouvier
2024-10-21 20:22 ` Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 4/7] target/arm: call plugin trap callbacks Julian Ganz
2024-10-21 12:58 ` Peter Maydell
2024-10-21 16:25 ` Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 5/7] target/avr: " Julian Ganz
2024-10-19 17:29 ` Michael Rolnik
2024-10-19 16:39 ` [RFC PATCH v2 6/7] target/riscv: " Julian Ganz
2024-10-19 16:39 ` [RFC PATCH v2 7/7] target/sparc: " Julian Ganz
2024-10-20 19:37 ` [RFC PATCH v2 0/7] tcg-plugins: add hooks for interrupts, exceptions and traps Alex Bennée
2024-10-21 18:00 ` Pierrick Bouvier
2024-10-21 18:47 ` Alex Bennée
2024-10-21 20:45 ` Pierrick Bouvier
2024-10-21 21:02 ` Julian Ganz
2024-10-21 21:59 ` Pierrick Bouvier
2024-10-22 8:21 ` Julian Ganz
2024-10-22 8:58 ` Alex Bennée [this message]
2024-10-22 20:12 ` Julian Ganz
2024-10-22 21:15 ` Pierrick Bouvier
2024-10-23 12:56 ` Julian Ganz
2024-10-23 13:57 ` Alex Bennée
2024-10-23 15:21 ` Pierrick Bouvier
2024-10-23 15:16 ` Pierrick Bouvier
2024-10-23 16:12 ` Julian Ganz
2024-10-23 16:39 ` Pierrick Bouvier
2024-10-23 17:12 ` Julian Ganz
2024-10-23 17:53 ` 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=87wmi0ms45.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=neither@nut.email \
--cc=nenut@skiff.uberspace.de \
--cc=pierrick.bouvier@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 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.