Re: [PATCH v3 05/10] riscv: add RPMI system reset service

Philippe Mathieu-Daudé <[email protected]> Mon, 20 Jul 2026 12:59:41 +0200
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-devel
Message-ID <[email protected]>
On 14/7/26 09:56, Subrahmanya Lingappa wrote:
> Add a QEMU implementation of the RPMI System Reset service group.
> 
> The service advertises shutdown and cold reboot reset types, validates
> guest requests, and dispatches accepted requests through the machine
> reset and shutdown callbacks. This lets firmware use RPMI reset commands
> while keeping the board-specific reset policy in the RISC-V virt machine.
> 
> Signed-off-by: Subrahmanya Lingappa <[email protected]>
> ---
>   hw/misc/meson.build           |   1 +
>   hw/misc/riscv_rpmi.c          |  38 ++++++-
>   hw/misc/riscv_rpmi_internal.h |   9 ++
>   hw/misc/riscv_rpmi_sysreset.c | 206 ++++++++++++++++++++++++++++++++++
>   hw/riscv/virt.c               |  40 +++++++
>   include/hw/misc/riscv_rpmi.h  |  13 ++-
>   include/hw/riscv/rpmi-fdt.h   |  11 ++
>   7 files changed, 313 insertions(+), 5 deletions(-)
>   create mode 100644 hw/misc/riscv_rpmi_sysreset.c


> diff --git a/include/hw/misc/riscv_rpmi.h b/include/hw/misc/riscv_rpmi.h
> index b5d8a32f9b..d11db87731 100644
> --- a/include/hw/misc/riscv_rpmi.h
> +++ b/include/hw/misc/riscv_rpmi.h


> +typedef struct RiscvRpmiMachineOps {
> +    void (*system_reset)(void *opaque);
> +    void (*system_shutdown)(void *opaque);

What is the plan for this @opaque argument?

> +} RiscvRpmiMachineOps;
>   typedef struct RiscvRpmiServiceConfig {
>       RiscvRpmiServiceKind kind;
>       const char *node_name;
> @@ -56,7 +62,8 @@ typedef struct RiscvRpmiConfig {
>       uint32_t a2p_req_size;
>       uint32_t p2a_req_size;
>       const char *platform_info;
> -
> +    const RiscvRpmiMachineOps *machine_ops;
> +    void *machine_opaque;
>       const uint32_t *hart_ids;
>       uint32_t hart_count;
>       const RiscvRpmiServiceConfig *services;
> @@ -73,7 +80,9 @@ struct RiscvRpmiState {
>       uint32_t a2p_req_size;
>       uint32_t p2a_req_size;
>       char *platform_info;
> -
> +    const RiscvRpmiMachineOps *machine_ops;
> +    void *machine_opaque;
> +    struct rpmi_service_group *sysreset_group;
>       uint32_t *hart_ids;
>       uint32_t hart_count;
>       const RiscvRpmiServiceConfig *services;