Skip to content

riscv: add initial RPMI virt support

Subrahmanya Lingappa qemu-devel qemu-riscv 15 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v16 Latest10 patches 0 repliesNew
  2. v1510 patches 6 repliesSuperseded
  3. v1410 patches 0 repliesSuperseded
Earlier versions · 12
VersionPostedPatchesRepliesStatus
v1310 patches0 repliesSuperseded
v1210 patches2 repliesSuperseded
v1110 patches3 repliesSuperseded
v1010 patches3 repliesSuperseded
v910 patches2 repliesSuperseded
v810 patches12 repliesSuperseded
v710 patches0 repliesSuperseded
v610 patches0 repliesSuperseded
v510 patches0 repliesSuperseded
v410 patches0 repliesSuperseded
v310 patches20 repliesSuperseded
v210 patches2 repliesSuperseded

Changes in v16 from the cover letter · 25 lines

- Series wide:
- most of the minor changes done were to fix the sashiko comments.
- [01/10] build: add optional librpmi dependency:
- Warn and disable RPMI when auto mode finds an incompatible librpmi; retain the error for explicit enablement.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Clear the doorbell latch on unsupported writes without dispatching.
- Reject shared memory above librpmi's 32-bit size limit before allocation.
- Put the no-op environment-lock rationale next to the platform hooks.
- [06/10] riscv: add RPMI HSM service:
- Remove the unreachable failure branch around reset with error_abort.
- [07/10] riscv: add RPMI system suspend service:
- Derive resume alignment from the target hart's active ISA, including when a writable MISA has disabled compressed instructions.
- Remove the corresponding unreachable suspend-reset failure branch.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Document a pinned OpenSBI build and the thorough guest-test command; state the firmware prerequisite and distinguish passes from skips.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Test unsupported doorbell values and resume alignment after clearing active MISA.C through the qtest CSR interface.
- Remove dumped DTBs before exit-status checks and fatal assertions, including abnormal QEMU exits and read failures.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Use pinned kernel/rootfs assets with optional overrides and clean up setup failures; escape commas in overlay filenames.
- Verify a live CPU1-pinned busy worker before the HSM cycle. Use Python's affinity API because the pinned rootfs does not provide taskset.
- Remove the unused class timeout; retain Meson's 420-second limit.
- Accept transient start denials after a completed stop; retain strict stop-only and fatal-stop diagnostic checks.
- Provision pinned librpmi/OpenSBI in CI, explicitly enable RPMI, and require six guest passes without skips.
- Drop Reviewed-by tags from the changed dependency and documentation commits; retain tags on unchanged patches.

Patches in v16 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10build: add optional librpmi dependencyKconfig.host meson.build meson_options.txt +1 more+27 -00 replies
2/10hw/misc: add RISC-V RPMI transport and Base supportMAINTAINERS hw/misc/Kconfig hw/misc/meson.build +4 more+665 -00 replies
3/10hw/riscv: add RPMI FDT helpershw/riscv/meson.build hw/riscv/rpmi-fdt-stub.c hw/riscv/rpmi-fdt.c +1 more+153 -00 replies
4/10hw/riscv/virt: add opt-in RPMI base supporthw/riscv/Kconfig hw/riscv/virt.c include/hw/riscv/virt.h+94 -00 replies
5/10riscv: add RPMI system reset servicehw/misc/meson.build hw/misc/riscv_rpmi.c hw/misc/riscv_rpmi_internal.h +6 more+322 -100 replies
6/10riscv: add RPMI HSM servicehw/misc/meson.build hw/misc/riscv_rpmi.c hw/misc/riscv_rpmi_hsm.c +8 more+453 -10 replies
7/10riscv: add RPMI system suspend servicehw/misc/meson.build hw/misc/riscv_rpmi.c hw/misc/riscv_rpmi_hsm.c +4 more+271 -80 replies
8/10docs/system/riscv: document initial virt RPMI supportdocs/system/riscv/virt.rst+99 -00 replies
9/10tests/qtest: cover initial RISC-V RPMI servicesMAINTAINERS tests/qtest/meson.build tests/qtest/riscv-rpmi-test.c+820 -00 replies
10/10tests/functional: add initial RPMI virt guest smoke.gitlab-ci.d/buildtest.yml scripts/ci/build-rpmi-deps.sh scripts/ci/check-rpmi-guests.py +2 more+455 -00 replies

Reviews trailers per patch

2 of 10 patches have a Reviewed-by or Acked-by.

PatchDaniel Henrique Barboza
1/10
2/10
3/10R-b
4/10
5/10R-b
6/10
7/10
8/10
9/10
10/10

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v16 thread

Cover letter [PATCH v16 00/10] riscv: add initial RPMI virt support

This series adds initial librpmi-backed RPMI support for the RISC-V virt machine. It covers the optional librpmi build dependency, RPMI transport and Base support, virt FDT wiring, System Reset, HSM, System Suspend, documentation, qtests, and a Linux guest smoke test.

librpmi provides the host-side RPMI service-group implementation used by this QEMU device model:

https://github.com/riscv-software-src/librpmi

Dependencies:
- librpmi 1.0.0 or newer, available from the upstream repository above or from the distribution packages documented in docs/system/riscv/virt.rst.
- RPMI-capable OpenSBI firmware for the functional guest test. The CI jobs provision a pinned source build; kernel and rootfs use pinned assets unless overridden.

Changes since v15:
- Series wide:
- most of the minor changes done were to fix the sashiko comments.
- [01/10] build: add optional librpmi dependency:
- Warn and disable RPMI when auto mode finds an incompatible librpmi; retain the error for explicit enablement.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Clear the doorbell latch on unsupported writes without dispatching.
- Reject shared memory above librpmi's 32-bit size limit before allocation.
- Put the no-op environment-lock rationale next to the platform hooks.
- [06/10] riscv: add RPMI HSM service:
- Remove the unreachable failure branch around reset with error_abort.
- [07/10] riscv: add RPMI system suspend service:
- Derive resume alignment from the target hart's active ISA, including when a writable MISA has disabled compressed instructions.
- Remove the corresponding unreachable suspend-reset failure branch.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Document a pinned OpenSBI build and the thorough guest-test command; state the firmware prerequisite and distinguish passes from skips.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Test unsupported doorbell values and resume alignment after clearing active MISA.C through the qtest CSR interface.
- Remove dumped DTBs before exit-status checks and fatal assertions, including abnormal QEMU exits and read failures.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Use pinned kernel/rootfs assets with optional overrides and clean up setup failures; escape commas in overlay filenames.
- Verify a live CPU1-pinned busy worker before the HSM cycle. Use Python's affinity API because the pinned rootfs does not provide taskset.
- Remove the unused class timeout; retain Meson's 420-second limit.
- Accept transient start denials after a completed stop; retain strict stop-only and fatal-stop diagnostic checks.
- Provision pinned librpmi/OpenSBI in CI, explicitly enable RPMI, and require six guest passes without skips.
- Drop Reviewed-by tags from the changed dependency and documentation commits; retain tags on unchanged patches.

Changes since v14:
- [07/10] riscv: add RPMI system suspend service:
- Check the callback hart index and target CPU before dereferencing configured hart state.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Check invalid System Suspend hart-ID rejection without a suspend event.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Set the outer Meson timeout to 420 seconds.
- Fail on the suspend failure marker without matching echoed shell input.

Changes since v13:
- Series-wide:
- Rebase onto QEMU master at

    74f7bf4c59e6b6d50dbc6e124d93440be8be4386.

- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- Size each A2P request/ack queue from one quarter of shared memory after an 8 KiB allowance, increasing it from 1 KiB to 30 KiB. Retain the existing two-queue transport.
- [07/10] riscv: add RPMI system suspend service:
- Reject misaligned resume addresses and addresses outside the target hart's address width before accepting suspend, and require the resume PC to be backed by RAM in the active system-memory map.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Check resume-address alignment with and without compressed instructions, MMIO and unmapped-address rejection, RAM-backed addresses, RV32 width rejection for mapped RAM above 4 GiB, and recovery after rejection/reset without suspend side effects.
- Verify the enlarged DT queue ranges and last-data-slot wraparound, accounting for the head/tail metadata slots.

Changes since v12:
- Series-wide:
- Fix HSM stop completion after guest tests exposed divergence between cached RPMI hart state and actual WFI state, including HART_STOP failures after suspend/wakeup.
- Fold post-v12 review fixes and build corrections into their owning commits; retain the v12 FDT hierarchy/schema fix and earlier fixes.
- Drop earlier Reviewed-by tags from the materially rewritten HSM, System Suspend, and qtest patches.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Keep librpmi calls under existing BQL ownership because its environment lock hooks are no-ops.
- Remove unrelated global event polling from doorbell handling; service state transitions now drive their own event processing.
- Reject request queues too small to hold queue metadata and a data slot.
- Name the minimum queue size RPMI_DATA_SLOT_SIZE instead of repeating the head, tail, and data-slot size expression in queue validation.
- [03/10] hw/riscv: add RPMI FDT helpers:
- Remove duplicate helper arguments by passing the service configuration directly, and allow Base-only callers to omit the mailbox phandle.
- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- Keep this intermediate commit independently buildable before the reset service lands; retain legacy reset nodes until [05/10].
- Keep queue sizing local, drop the unused MSI phandle argument, and document the librpmi and TCG requirements.
- [05/10] riscv: add RPMI system reset service:
- Include the runstate API here so the callback-introducing commit builds independently.
- Preserve little-endian responses without alignment-unsafe buffer casts.
- [06/10] riscv: add RPMI HSM service:
- Complete accepted stop and suspend requests only when the target hart actually enters WFI; no later RPMI request is needed to publish the new state.
- Observe WFI persistently and replay the observer on the target CPU so stop requests arriving after WFI are not missed.
- Run HART_START on the target CPU, keep stopped harts off until that request, publish RPMI state under the BQL, and drain target-CPU work during teardown.
- Reconstruct HSM state on machine reset to avoid stale service state.
- [07/10] riscv: add RPMI system suspend service:
- Align suspend completion and wakeup with the corrected HSM transitions; process only its accepted event and avoid stale wakeup work on teardown.
- Recreate the suspend group around HSM reset reconstruction.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Remove the obsolete RFC caveat now that the binding names are settled.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Match the non-executing qtest accelerator: expect pending states, reject HART_START while stop is pending, and check reset recovery.
- Remove an invalid target-PC assertion and use the negotiated response slot for variable-length replies.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Bound the wait for online after CPU death: Linux's offline mask can precede firmware STOPPED. Keep transient errors visible and require eventual successful start; STOP_PENDING start rejection remains tested.
- Verify completed stop/start transitions, repeated stops, busy-hart stop, reboot recovery, and HSM operation after suspend/wakeup.
- Tighten console checks to prevent echoed commands or stale prompts from producing false passes, and fail on fatal firmware HSM diagnostics.

Changes since v11:
- Series-wide:
- Rebase the complete series onto QEMU master at

    d73149283205645625bfa9fe029cfb68e4c4a9ae.

- Fold the FDT/schema review fix into the original commits.
- [03/10] hw/riscv: add RPMI FDT helpers:
- Emit RPMI service nodes as /soc siblings of the shared-memory mailbox.
- Remove shmem_base from the FDT service helper API.
- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- Update virt FDT wiring for the sibling service-node layout.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Document the sibling service-node hierarchy and updated helper behavior.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Add DTB regression checks for sibling paths, mailbox phandles, service IDs, and rejection of the old mailbox-child hierarchy.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Revalidate librpmi and no-librpmi builds, RPMI qtests, and real guest smoke tests after the FDT/schema fix.

Changes since v10:
- Series-wide:
- Fold the post-v10 mailing-list review fixes into the original commits.
- [01/10] build: add optional librpmi dependency:
- Add Reviewed-by tags from Alistair Francis and Sunil V L.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Replace legacy physical-memory helpers with QEMU address-space APIs.
- Propagate failed shared-memory transactions as RPMI_ERR_IO.
- Use address_space_set() for bulk shared-memory fills.
- Log failures from the void librpmi_env_writel() hook.
- Document the external librpmi_env.h environment-hook contract.

Changes since v9:
- Series-wide:
- Rebase on current QEMU master, commit 0a1ebd448b38.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Move the no-librpmi riscv_rpmi_create() stub into this patch where the public RPMI device API is introduced.
- Use enum rpmi_servicegroup_id for service-group identifiers from the first RPMI config definition, with no-librpmi fallback enum values for optional builds.
- [03/10] hw/riscv: add RPMI FDT helpers:
- Move the no-librpmi RPMI FDT helper stub into this patch where the helper prototypes are introduced.
- [05/10] riscv: add RPMI system reset service:
- Use the librpmi RPMI_SRVGRP_SYSTEM_RESET value directly instead of a QEMU-local service-group alias.
- Introduce the service-ops dispatch table in this patch, with the initial System Reset entry.
- [06/10] riscv: add RPMI HSM service:
- Use the librpmi RPMI_SRVGRP_HSM value directly instead of a QEMU-local service-group alias.
- Add only the HSM service entry on top of the System Reset service ops infrastructure.
- [07/10] riscv: add RPMI system suspend service:
- Use the librpmi RPMI_SRVGRP_SYSTEM_SUSPEND value directly instead of a QEMU-local service-group alias.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Drop future/unimplemented service-group definitions and probes from the qtest coverage. The test now covers only the initial Base, System Reset, HSM and System Suspend services.

Changes since v8:
- Series-wide:
- Rebase on current QEMU master, commit 539bc315538a.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Update the RPMI transport shared-memory helpers for the current physical_memory_read()/physical_memory_write() APIs.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Add qtest coverage documentation alongside the existing firmware and guest smoke test notes.

Changes since v7:
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Drop the redundant internal RiscvRpmiServiceKind field from RiscvRpmiServiceConfig and use service_group as the single dispatch and FDT service identifier.
- [05/10] riscv: add RPMI system reset service:
- Move the RiscvRpmiServiceOps table and service_group lookup infrastructure into this patch, so the HSM and System Suspend patches only add their own service entries.
- [06/10] riscv: add RPMI HSM service:
- Build on the System Reset patch's service_group lookup infrastructure instead of introducing it here.

Changes since v6:
- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- When RPMI is enabled, advertise reboot and shutdown through the RPMI System Reset service instead of the syscon reset nodes.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Extend the functional guest smoke test to check the RPMI reboot and shutdown devices reported by firmware and exercise reboot.

Changes since v5:
- [01/10] build: add optional librpmi dependency:
- Fix the librpmi configure probe to check the system suspend service group API used by this initial series instead of the later logging API.
- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- Keep later SBI MPXY/FDT stubs out of the initial no-librpmi stub file; those stubs now live in the later stack layer where their prototypes are introduced.

Changes since v4:
- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- Drop the unused machine-opaque argument from the RPMI machine callback API.
- Move the no-librpmi riscv_rpmi_create() fallback out of the public header into hw/misc/riscv_rpmi-stub.c.
- Add a matching RPMI FDT helper stub for no-librpmi builds, while keeping the real rpmi-fdt.c source gated on CONFIG_RISCV_RPMI.
- [05/10] riscv: add RPMI system reset service:
- Drop the unused machine-opaque argument from the callback API.
- [06/10] riscv: add RPMI HSM service:
- Drop the unused machine-opaque argument from the callback API.
- [07/10] riscv: add RPMI system suspend service:
- Drop the unused machine-opaque argument from the callback API.

Changes since v3:
- [01/10] build: add optional librpmi dependency:
- Use "RPMI support" for librpmi-related Meson option and summary text.
- Add Reviewed-by tags from Daniel Henrique Barboza and Philippe Mathieu-Daude.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Use the Resettable API instead of device_class_set_legacy_reset().
- [03/10] hw/riscv: add RPMI FDT helpers:
- Gate the RPMI FDT helper source on CONFIG_RISCV_RPMI.
- Add Reviewed-by from Daniel Henrique Barboza.
- [04/10] hw/riscv/virt: add opt-in RPMI base support:
- Mark no-librpmi stub parameters with G_GNUC_UNUSED.
- [05/10] riscv: add RPMI system reset service:
- Add Reviewed-by from Daniel Henrique Barboza.
- [06/10] riscv: add RPMI HSM service:
- Add Reviewed-by from Daniel Henrique Barboza.
- [07/10] riscv: add RPMI system suspend service:
- Add Reviewed-by from Daniel Henrique Barboza.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Add Reviewed-by from Daniel Henrique Barboza.
- [09/10] tests/qtest: cover initial RISC-V RPMI services:
- Add Reviewed-by from Daniel Henrique Barboza.
- [10/10] tests/functional: add initial RPMI virt guest smoke:
- Drop the stale Ventana copyright line.

Changes since v2:
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Document how to obtain and install librpmi for QEMU builds, including source builds, Debian/RPM packages, pkg-config setup, and the minimum librpmi version.

Changes since v1:
- Series-wide:
- Fold reviewer fixes into the original commits.
- [02/10] hw/misc: add RISC-V RPMI transport and Base support:
- Move Base service configuration into the Base support commit.
- [08/10] docs/system/riscv: document initial virt RPMI support:
- Document the RPMI v1.0 ratified context and specification references.

Testing:
- All ten patches build individually with and without librpmi.
- Compatible, incompatible-header and absent-librpmi configuration cases pass; auto mode disables incompatible librpmi and explicit enablement fails.
- Without librpmi, the default virt machine realizes and explicit RPMI enablement rejects with the expected unsupported-build error.
- RPMI qtests immediately after [09/10]: 22/22 subtests passed, including unsupported doorbell writes and active-MISA resume alignment.
- Linux guests immediately after [10/10]: 6/6 passed twice, covering repeated and busy-hart HSM stop/start, stopped-hart reboot recovery, service enumeration, poweroff, reboot, and suspend/wakeup followed by HSM stop/start.

Subrahmanya Lingappa (10):
build: add optional librpmi dependency hw/misc: add RISC-V RPMI transport and Base support hw/riscv: add RPMI FDT helpers hw/riscv/virt: add opt-in RPMI base support
riscv: add RPMI system reset service
riscv: add RPMI HSM service
riscv: add RPMI system suspend service docs/system/riscv: document initial virt RPMI support tests/qtest: cover initial RISC-V RPMI services tests/functional: add initial RPMI virt guest smoke

 .gitlab-ci.d/buildtest.yml                 |  58 ++
 Kconfig.host                               |   3 +
 MAINTAINERS                                |   3 +
 docs/system/riscv/virt.rst                 |  99 ++++
 hw/misc/Kconfig                            |   4 +
 hw/misc/meson.build                        |   8 +
 hw/misc/riscv_rpmi-stub.c                  |  16 +
 hw/misc/riscv_rpmi.c                       | 605 +++++++++++++++++++++
 hw/misc/riscv_rpmi_hsm.c                   | 359 +++++++++++++
 hw/misc/riscv_rpmi_internal.h              |  43 ++
 hw/misc/riscv_rpmi_sysreset.c              | 185 +++++++
 hw/misc/riscv_rpmi_syssusp.c               | 210 ++++++++
 hw/riscv/Kconfig                           |   1 +
 hw/riscv/fdt-common.c                      |   8 +-
 hw/riscv/meson.build                       |   3 +
 hw/riscv/rpmi-fdt-stub.c                   |  24 +
 hw/riscv/rpmi-fdt.c                        |  92 ++++
 hw/riscv/server_platform_ref.c             |   2 +-
 hw/riscv/virt.c                            | 144 ++++-
 include/hw/misc/riscv_rpmi.h               | 112 ++++
 include/hw/riscv/fdt-common.h              |   3 +-
 include/hw/riscv/rpmi-fdt.h                |  34 ++
 include/hw/riscv/virt.h                    |   3 +
 meson.build                                |  19 +
 meson_options.txt                          |   2 +
 scripts/ci/build-rpmi-deps.sh              |  49 ++
 scripts/ci/check-rpmi-guests.py            |  36 ++
 scripts/meson-buildoptions.sh              |   3 +
 target/riscv/cpu-qom.h                     |  16 +
 target/riscv/cpu.c                         |  61 +++
 target/riscv/cpu.h                         |   7 +
 target/riscv/tcg/op_helper.c               |   4 +
 target/riscv/tcg/tcg-cpu.c                 |   1 +
 tests/functional/riscv64/meson.build       |   2 +
 tests/functional/riscv64/test_rpmi_virt.py | 310 +++++++++++
 tests/qtest/meson.build                    |   3 +
 tests/qtest/riscv-rpmi-test.c              | 816 +++++++++++++++++++++++++++++
 37 files changed, 3344 insertions(+), 4 deletions(-)
 create mode 100644 hw/misc/riscv_rpmi-stub.c
 create mode 100644 hw/misc/riscv_rpmi.c
 create mode 100644 hw/misc/riscv_rpmi_hsm.c
 create mode 100644 hw/misc/riscv_rpmi_internal.h
 create mode 100644 hw/misc/riscv_rpmi_sysreset.c
 create mode 100644 hw/misc/riscv_rpmi_syssusp.c
 create mode 100644 hw/riscv/rpmi-fdt-stub.c
 create mode 100644 hw/riscv/rpmi-fdt.c
 create mode 100644 include/hw/misc/riscv_rpmi.h
 create mode 100644 include/hw/riscv/rpmi-fdt.h
 create mode 100644 scripts/ci/build-rpmi-deps.sh
 create mode 100644 scripts/ci/check-rpmi-guests.py
 create mode 100644 tests/functional/riscv64/test_rpmi_virt.py
 create mode 100644 tests/qtest/riscv-rpmi-test.c

base-commit: 74f7bf4c59e6b6d50dbc6e124d93440be8be4386