All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: Julian Ganz <neither@nut.email>,  qemu-devel@nongnu.org
Subject: Re: [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities
Date: Thu, 09 Jan 2025 13:52:49 +0000	[thread overview]
Message-ID: <87wmf46qmm.fsf@draig.linaro.org> (raw)
In-Reply-To: <6f182c71-2600-4bbf-ab4c-985ed7e99f71@linaro.org> (Pierrick Bouvier's message of "Wed, 4 Dec 2024 14:45:24 -0800")

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> Hi Julian,
>
> thanks for the update!
> Comments below.
>
> On 12/2/24 11:26, Julian Ganz wrote:
>> The plugin API allows registration of callbacks for a variety of VCPU
>> related events, such as VCPU reset, idle and resume. However, traps of
>> any kind, i.e. interrupts or exceptions, were previously not covered.
>> These kinds of events are arguably quite significant and usually go hand
>> in hand with a PC discontinuity. On most platforms, the discontinuity
>> also includes a transition from some "mode" to another. Thus, plugins
>> for the analysis of (virtualized) embedded systems may benefit from or
>> even require the possiblity to perform work on the occurance of an
>> interrupt or exception.
>> This change introduces the concept of such a discontinuity event in
>> the
>> form of an enumeration. Currently only traps are covered. Specifically
>> we (loosely) define interrupts, exceptions and host calls across all
>> platforms. In addition, this change introduces a type to use for
>> callback functions related to such events. Since possible modes and the
>> enumeration of interupts and exceptions vary greatly between different
>> architectures, the callback type only receives the VCPU id, the type of
>> event as well as the old and new PC.
>> ---
>>   include/qemu/plugin.h      |  1 +
>>   include/qemu/qemu-plugin.h | 43 ++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 44 insertions(+)
>> diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
>> index 9726a9ebf3..27a176b631 100644
>> --- a/include/qemu/plugin.h
>> +++ b/include/qemu/plugin.h
>> @@ -59,6 +59,7 @@ union qemu_plugin_cb_sig {
>>       qemu_plugin_udata_cb_t           udata;
>>       qemu_plugin_vcpu_simple_cb_t     vcpu_simple;
>>       qemu_plugin_vcpu_udata_cb_t      vcpu_udata;
>> +    qemu_plugin_vcpu_discon_cb_t     vcpu_discon;
>>       qemu_plugin_vcpu_tb_trans_cb_t   vcpu_tb_trans;
>>       qemu_plugin_vcpu_mem_cb_t        vcpu_mem;
>>       qemu_plugin_vcpu_syscall_cb_t    vcpu_syscall;
>> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
>> index 0fba36ae02..9c67374b7e 100644
>> --- a/include/qemu/qemu-plugin.h
>> +++ b/include/qemu/qemu-plugin.h
>> @@ -154,6 +154,49 @@ typedef void (*qemu_plugin_vcpu_simple_cb_t)(qemu_plugin_id_t id,
>>   typedef void (*qemu_plugin_vcpu_udata_cb_t)(unsigned int vcpu_index,
>>                                               void *userdata);
>>   +
>> +/**
>> + * enum qemu_plugin_discon_type - type of a (potential) PC discontinuity
>> + *
>> + * @QEMU_PLUGIN_DISCON_INTERRUPT: an interrupt, defined across all architectures
>> + *                                as an asynchronous event, usually originating
>> + *                                from outside the CPU
>> + * @QEMU_PLUGIN_DISCON_EXCEPTION: an exception, defined across all architectures
>> + *                                as a synchronous event in response to a
>> + *                                specific instruction being executed
>> + * @QEMU_PLUGIN_DISCON_HOSTCALL: a host call, functionally a special kind of
>> + *                               exception that is not handled by code run by
>> + *                               the vCPU but machinery outside the vCPU
>> + * @QEMU_PLUGIN_DISCON_ALL: all types of disconinuity events currently covered
>> + */
>> +enum qemu_plugin_discon_type {
>> +    QEMU_PLUGIN_DISCON_INTERRUPT = 1,
>> +    QEMU_PLUGIN_DISCON_EXCEPTION = 2,
>> +    QEMU_PLUGIN_DISCON_HOSTCALL = 4,
>> +    QEMU_PLUGIN_DISCON_ALL = 7
>> +};
>
> Matter of style, but would be better to use:
>
> enum qemu_plugin_discon_type {
>      QEMU_PLUGIN_DISCON_INTERRUPT = 1 << 0,
>      QEMU_PLUGIN_DISCON_EXCEPTION = 1 << 1,
>      QEMU_PLUGIN_DISCON_HOSTCALL = 1 << 2,
>      QEMU_PLUGIN_DISCON_ALL = -1
> };
>
<snip>

Is this really a bit field though? If you will only report type of
discontinuity at a time a simple 0 based enum with
QEMU_PLUGIN_DISCON_MAX would be simpler.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  parent reply	other threads:[~2025-01-09 13:53 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 19:26 [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities Julian Ganz
2024-12-03  8:45   ` Julian Ganz
2024-12-04 22:41     ` Pierrick Bouvier
2024-12-05 12:40       ` Julian Ganz
2024-12-05 17:56         ` Pierrick Bouvier
2024-12-05 21:50           ` Julian Ganz
2024-12-05 22:14             ` Julian Ganz
2024-12-05 23:03             ` Pierrick Bouvier
2024-12-06  8:58               ` Julian Ganz
2024-12-06 18:59                 ` Pierrick Bouvier
2024-12-07 13:38                   ` Julian Ganz
2024-12-09 18:52                     ` Pierrick Bouvier
2024-12-04 22:45   ` Pierrick Bouvier
2024-12-05 12:44     ` Julian Ganz
2024-12-05 17:35       ` Pierrick Bouvier
2024-12-05 21:25         ` Julian Ganz
2025-01-09 13:52     ` Alex Bennée [this message]
2025-01-09 22:28       ` Pierrick Bouvier
2025-01-10 11:43       ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks Julian Ganz
2024-12-04 22:45   ` Pierrick Bouvier
2025-01-09 13:57   ` Alex Bennée
2025-01-10 11:40     ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 03/11] plugins: add hooks for new discontinuity related callbacks Julian Ganz
2024-12-04 22:47   ` Pierrick Bouvier
2025-01-09 13:58   ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 04/11] contrib/plugins: add plugin showcasing new dicontinuity related API Julian Ganz
2024-12-04 23:14   ` Pierrick Bouvier
2024-12-05 13:00     ` Julian Ganz
2024-12-05 17:23       ` Pierrick Bouvier
2025-01-09 14:04   ` Alex Bennée
2025-01-09 22:10     ` Pierrick Bouvier
2025-01-10 11:49     ` Julian Ganz
2025-01-10 15:15       ` Alex Bennée
2025-01-10 21:02         ` Pierrick Bouvier
2025-01-11 12:15           ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 05/11] target/alpha: call plugin trap callbacks Julian Ganz
2024-12-04 22:48   ` Pierrick Bouvier
2024-12-02 19:26 ` [RFC PATCH v3 06/11] target/arm: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 07/11] target/avr: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 08/11] target/mips: " Julian Ganz
2025-01-09 13:43   ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 09/11] target/riscv: " Julian Ganz
2024-12-03  4:39   ` Alistair Francis
2024-12-02 19:41 ` [RFC PATCH v3 10/11] target/sparc: " Julian Ganz
2025-01-09 13:46   ` Alex Bennée
2024-12-02 19:41 ` [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc Julian Ganz
2024-12-04 23:33   ` Pierrick Bouvier
2024-12-05 13:10     ` Julian Ganz
2024-12-05 17:30       ` Pierrick Bouvier
2024-12-05 21:22         ` Julian Ganz
2024-12-05 22:28           ` Pierrick Bouvier
2024-12-06  8:42             ` Julian Ganz
2024-12-06 19:02               ` Pierrick Bouvier
2024-12-06 19:42                 ` Richard Henderson
2024-12-06 20:40                   ` Pierrick Bouvier
2024-12-06 22:56                     ` Richard Henderson
2024-12-07 13:47                       ` Julian Ganz
2024-12-07 13:41                   ` Julian Ganz
2024-12-20 11:47     ` Julian Ganz
2024-12-20 21:17       ` Pierrick Bouvier
2024-12-20 21:46         ` Pierrick Bouvier
2025-01-09 16:35         ` Alex Bennée
2025-01-09 16:33       ` Alex Bennée
2025-01-09 22:27         ` Pierrick Bouvier
2025-01-10 11:58         ` Julian Ganz
2024-12-03  8:36 ` [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-04 22:51   ` Pierrick Bouvier
2025-01-09 16:43 ` 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=87wmf46qmm.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=neither@nut.email \
    --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.