This series adds initial librpmi-backed RPMI support for the RISC-V virt machine. It covers the optional librpmi build dependency, the RPMI transport and Base service, virt FDT wiring, opt-in machine support, 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. The upstream repository is available at: https://github.com/riscv-software-src/librpmi The documentation patch adds librpmi build instructions, "RPMI qtest coverage", and "RPMI firmware and guest smoke" sections to docs/system/riscv/virt.rst. Changes since v9: - [02/10] hw/misc: add RISC-V RPMI transport and Base support: - Store RPMI doorbell writes in little-endian order using QEMU's stl_le_p() helper before physical_memory_write(). - Validate the complete shared-memory fill range before writing. - Return RPMI_ERR_BAD_RANGE for invalid shared-memory accesses to match current librpmi. - [06/10] riscv: add RPMI HSM service: - Honor the HART_START start_addr parameter by setting the target hart PC before starting it. - Keep HART_SUSPEND as a state-transition operation without forcing QEMU CPU PC to the resume address. Directly rewriting PC here made the Linux guest hang before login in the HSM stop smoke test. - [07/10] riscv: add RPMI system suspend service: - Preserve the system-suspend resume address for RPMI request state, but resume the boot hart without directly rewriting QEMU CPU PC. - [09/10] tests/qtest: cover initial RISC-V RPMI services: - Keep qtest coverage for HART_START PC programming. - Validate HART_SUSPEND state transition without requiring a QEMU CPU PC rewrite. - Series-wide: - Rebase on current QEMU master, commit 0a1ebd448b38. 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 the reboot path. 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 service 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 a dedicated hw/misc/riscv_rpmi-stub.c file. - Add a matching RPMI FDT helper stub file 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 RPMI machine callback API. - [06/10] riscv: add RPMI HSM service: - Drop the unused machine-opaque argument from the RPMI machine callback API. - [07/10] riscv: add RPMI system suspend service: - Drop the unused machine-opaque argument from the RPMI machine 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 build steps, Debian/RPM package targets, 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: - Add RPMI v1.0 Ratified context and specification references. 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 Kconfig.host | 3 + MAINTAINERS | 3 + docs/system/riscv/virt.rst | 80 +++ hw/misc/Kconfig | 4 + hw/misc/meson.build | 6 + hw/misc/riscv_rpmi-stub.c | 16 + hw/misc/riscv_rpmi.c | 558 ++++++++++++++++++ hw/misc/riscv_rpmi_hsm.c | 289 ++++++++++ hw/misc/riscv_rpmi_internal.h | 43 ++ hw/misc/riscv_rpmi_sysreset.c | 206 +++++++ hw/misc/riscv_rpmi_syssusp.c | 194 +++++++ hw/riscv/Kconfig | 1 + hw/riscv/meson.build | 3 + hw/riscv/rpmi-fdt-stub.c | 38 ++ hw/riscv/rpmi-fdt.c | 103 ++++ hw/riscv/virt.c | 176 +++++- include/hw/misc/riscv_rpmi.h | 114 ++++ include/hw/riscv/rpmi-fdt.h | 41 ++ include/hw/riscv/virt.h | 3 + meson.build | 14 + meson_options.txt | 2 + scripts/meson-buildoptions.sh | 3 + tests/functional/riscv64/meson.build | 2 + tests/functional/riscv64/test_rpmi_virt.py | 184 ++++++ tests/qtest/meson.build | 2 + tests/qtest/riscv-rpmi-test.c | 625 +++++++++++++++++++++ 26 files changed, 2711 insertions(+), 2 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 tests/functional/riscv64/test_rpmi_virt.py create mode 100644 tests/qtest/riscv-rpmi-test.c base-commit: 0a1ebd448b38afaa118597cbb633dbec24ef74d3 -- 2.43.0
