All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Steffen <osteffen@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Eduardo Habkost <eduardo@habkost.net>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Oliver Steffen <osteffen@redhat.com>
Subject: [RFC 2/2] q35: add virtio-mmio slots
Date: Tue,  1 Jul 2025 14:18:15 +0200	[thread overview]
Message-ID: <20250701121815.523896-3-osteffen@redhat.com> (raw)
In-Reply-To: <20250701121815.523896-1-osteffen@redhat.com>

From: Gerd Hoffmann <kraxel@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.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Oliver Steffen <osteffen@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



  parent reply	other threads:[~2025-07-01 12:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 12:18 [RFC 0/2] Add SVSM virtio-mmio device slots (q35) Oliver Steffen
2025-07-01 12:18 ` [RFC 1/2] hw/uefi: Add hardware-info ID for virtio mmio devices for SVSM Oliver Steffen
2025-08-01 13:29   ` Stefano Garzarella
2025-07-01 12:18 ` Oliver Steffen [this message]
2025-08-01 13:38   ` [RFC 2/2] q35: add virtio-mmio slots Stefano Garzarella
2025-08-01 13:55   ` Daniel P. Berrangé
2025-08-04 13:47     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250701121815.523896-3-osteffen@redhat.com \
    --to=osteffen@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=joerg.roedel@amd.com \
    --cc=kraxel@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sgarzare@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.