On Tue, Jul 01, 2025 at 02:18:15PM +0200, Oliver Steffen wrote: > From: Gerd Hoffmann <kra...@redhat.com> > > Add virtio-mmio slots to the q35 machine model, intended to be used by > an SVSM. > > Disabled by default, enable using '-machine q35,x-svsm-virtio-mmio=on'. > > When enabled it is possible to plug up to 4 virtio devices into the > slots virtio-mmio using '-device virtio-${kind}-device'. > > The devices can be found at base address 0xfef00000, each slot on a > separate page. No IRQ is wired up, the SVSM has to drive the devices > in polling mode. > > The base addresses are communicated to the SVSM via the etc/hardware-info > fw_cfg file.
This feels a somewhat uncomfortable in that it ties QEMU to specific impl details of SVSM at a point in time. With the IGVM support for loading guest firmware, we've avoided QEMU needing any knowledge of what the firmware actually is. It is just an opaque blob that is loaded based on its own IGVM metadata. This also made it possible for any hypervisor with IGVM support to be able to load any firmware, including SVSM or equiv impls. It feels like we're snatching defeat from the jaws of victory by still having to hardcode info about SVSM in QEMU. Is there any way to extend IGVM to express that it supports these 4 virtio-mmio slots, at the given address in polling mode, so that hypervisors can auto-discover this facility ? Failing that, can we make it possible to create virtio-mmio slots on the QEMU command line, instead of hardcoding this SVSM-specific setup in QEMU code. > > Signed-off-by: Gerd Hoffmann <kra...@redhat.com> > Signed-off-by: Oliver Steffen <ostef...@redhat.com> > --- > hw/i386/pc.c | 18 +++++++++++++++++- > hw/i386/pc_q35.c | 15 +++++++++++++++ > include/hw/i386/pc.h | 1 + > 3 files changed, 33 insertions(+), 1 deletion(-) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 432ab288a8..e1dbf8846d 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1584,6 +1584,21 @@ static void pc_machine_set_smbios_ep(Object *obj, > Visitor *v, const char *name, > visit_type_SmbiosEntryPointType(v, name, &pcms->smbios_entry_point_type, > errp); > } > > +static bool pc_machine_get_svsm_virtio_mmio(Object *obj, Error **errp) > +{ > + PCMachineState *pcms = PC_MACHINE(obj); > + > + return pcms->svsm_virtio_mmio; > +} > + > +static void pc_machine_set_svsm_virtio_mmio(Object *obj, bool value, > + Error **errp) > +{ > + PCMachineState *pcms = PC_MACHINE(obj); > + > + pcms->svsm_virtio_mmio = value; > +} > + > static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, > const char *name, void *opaque, > Error **errp) > @@ -1844,7 +1859,8 @@ static void pc_machine_class_init(ObjectClass *oc, > const void *data) > "Set IGVM configuration"); > #endif > > - > + object_class_property_add_bool(oc, "x-svsm-virtio-mmio", > + pc_machine_get_svsm_virtio_mmio, pc_machine_set_svsm_virtio_mmio); > } > > static const TypeInfo pc_machine_info = { > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index cf871cfdad..b8511ae52a 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -60,7 +60,9 @@ > #include "hw/mem/nvdimm.h" > #include "hw/uefi/var-service-api.h" > #include "hw/i386/acpi-build.h" > +#include "hw/uefi/hardware-info.h" > #include "target/i386/cpu.h" > +#include "exec/target_page.h" > > /* ICH9 AHCI has 6 ports */ > #define MAX_SATA_PORTS 6 > @@ -335,6 +337,19 @@ static void pc_q35_init(MachineState *machine) > } > } > #endif > + > + if (pcms->svsm_virtio_mmio) { > + for (int dev = 0; dev < 4; dev++) { > + HARDWARE_INFO_SIMPLE_DEVICE hwinfo = { > + .mmio_address = cpu_to_le64(0xfef00000 + dev * > TARGET_PAGE_SIZE), > + }; > + sysbus_create_simple("virtio-mmio", hwinfo.mmio_address, > + /* no irq */ NULL); > + hardware_info_register(HardwareInfoVirtioMmioSvsm, > + &hwinfo, sizeof(hwinfo)); > + } > + } > + > } > > #define DEFINE_Q35_MACHINE(major, minor) \ > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h > index 79b72c54dd..9c9f947087 100644 > --- a/include/hw/i386/pc.h > +++ b/include/hw/i386/pc.h > @@ -51,6 +51,7 @@ typedef struct PCMachineState { > bool i8042_enabled; > bool default_bus_bypass_iommu; > bool fd_bootchk; > + bool svsm_virtio_mmio; > uint64_t max_fw_size; > > /* ACPI Memory hotplug IO base address */ > -- > 2.50.0 > > With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|