On 14/7/26 09:56, Subrahmanya Lingappa wrote:
Add the virt machine rpmi=on/off option and wire the initial RPMI Base
transport into machine realization.
The option remains disabled by default and requires TCG plus librpmi.
Invalid accelerator/build combinations fail during machine
initialization. When enabled, virt allocates the RPMI shared-memory
transport, creates the RPMI device, configures Base service metadata,
and emits the corresponding device-tree nodes for firmware discovery.
Signed-off-by: Subrahmanya Lingappa <[email protected]>
---
hw/riscv/Kconfig | 1 +
hw/riscv/virt.c | 96 ++++++++++++++++++++++++++++++++++++
include/hw/misc/riscv_rpmi.h | 10 ++++
include/hw/riscv/virt.h | 3 ++
4 files changed, 110 insertions(+)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 33775a61fd..e52ccfae1f 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1410,6 +1452,18 @@ static void virt_machine_init(MachineState *machine)
exit(1);
}
+
+ if (s->have_rpmi) {
+#ifndef CONFIG_LIBRPMI
+ error_report("RISC-V RPMI support is not compiled in");
+ exit(1);
+#else
+ if (kvm_enabled()) {
+ error_report("RISC-V RPMI support is not available with KVM");
+ exit(1);
+ }
+#endif
+ }
diff --git a/include/hw/misc/riscv_rpmi.h b/include/hw/misc/riscv_rpmi.h
index cb2658e57e..b5d8a32f9b 100644
--- a/include/hw/misc/riscv_rpmi.h
+++ b/include/hw/misc/riscv_rpmi.h
@@ -85,6 +85,16 @@ struct RiscvRpmiState {
bool has_shmem;
};
+#ifdef CONFIG_LIBRPMI
DeviceState *riscv_rpmi_create(const RiscvRpmiConfig *cfg, Error **errp);
+#else
+static inline DeviceState *riscv_rpmi_create(const RiscvRpmiConfig *cfg,
+ Error **errp)
+{
+ (void)cfg;
+ (void)errp;
+ return NULL;
+}
+#endif
Could we use a stub file instead?