All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] Firmware 20260704 patches
@ 2026-07-04  4:53 Gerd Hoffmann
  2026-07-04  4:53 ` [PULL 1/3] igvm: Report error on missing parameter area in directive handlers Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-07-04  4:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Ani Sinha, Stefano Garzarella, Zhao Liu,
	Gerd Hoffmann

The following changes since commit b83371668192a705b878e909c5ae9c1233cbd5fb:

  Merge tag 'pbouvier/pr/plugins-20260618' of https://gitlab.com/p-b-o/qemu into staging (2026-06-19 15:00:01 -0400)

are available in the Git repository at:

  https://gitlab.com/kraxel/qemu.git tags/firmware-20260704-pull-request

for you to fetch changes up to 1c4bd8f13c769598eeee91d69a463fdb099a2c31:

  igvm: add device tree parameter support (2026-07-02 11:14:19 +0200)

----------------------------------------------------------------
igvm: add device tree support

----------------------------------------------------------------

Luigi Leonardi (3):
  igvm: Report error on missing parameter area in directive handlers
  igvm: use idiomatic meson conditional for IGVM build files
  igvm: add device tree parameter support

 include/system/igvm-internal.h |  3 +-
 backends/igvm.c                | 80 +++++++++++++++++++++++++++++-----
 target/i386/igvm.c             |  5 ++-
 backends/meson.build           |  7 +--
 4 files changed, 77 insertions(+), 18 deletions(-)

-- 
2.55.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PULL 1/3] igvm: Report error on missing parameter area in directive handlers
  2026-07-04  4:53 [PULL 0/3] Firmware 20260704 patches Gerd Hoffmann
@ 2026-07-04  4:53 ` Gerd Hoffmann
  2026-07-04  4:53 ` [PULL 2/3] igvm: use idiomatic meson conditional for IGVM build files Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-07-04  4:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Ani Sinha, Stefano Garzarella, Zhao Liu,
	Gerd Hoffmann, Luigi Leonardi

From: Luigi Leonardi <leonardi@redhat.com>

Parameter areas are how an IGVM file tells QEMU to allocate buffers
for runtime information the guest needs — VP count, memory map,
MADT and so on. Usage directives reference a parameter area by index
to tell QEMU where to write each piece of data. If the index doesn't
match any declared parameter area, the data has nowhere to go and
should be treated as an error.

The directive handlers that look up a parameter area all return 0
(success) when `qigvm_find_param_entry()` can't find it. Therefore,
the load succeeds but the guest never gets the expected parameters.

Note that the IGVM library already validates parameter area indices
when the file is loaded, so this path should only be reachable with
a malformed file that bypassed library validation. This is defensive
programming against that case.

Report the error with error_setg() and return -1 instead.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-ID: <20260626-microvm_device_tree-v6-1-9cd13cf057e2@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/system/igvm-internal.h |  3 ++-
 backends/igvm.c                | 26 ++++++++++++++++----------
 target/i386/igvm.c             |  5 +++--
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h
index 7f131c4d0392..7eb3792ed8c5 100644
--- a/include/system/igvm-internal.h
+++ b/include/system/igvm-internal.h
@@ -72,6 +72,7 @@ struct QIgvm {
 IgvmHandle qigvm_file_init(char *filename, Error **errp);
 
 QIgvmParameterData*
-qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
+qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index,
+                       Error **errp);
 
 #endif
diff --git a/backends/igvm.c b/backends/igvm.c
index 3f4b97a5d417..a5a2a4eccc19 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -81,7 +81,8 @@ struct QEMU_PACKED sev_id_authentication {
 #define IGVM_SEV_ID_BLOCK_VERSION 1
 
 QIgvmParameterData*
-qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index)
+qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index,
+                       Error **errp)
 {
     QIgvmParameterData *param_entry;
     QTAILQ_FOREACH(param_entry, &igvm->parameter_data, next)
@@ -90,7 +91,8 @@ qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index)
             return param_entry;
         }
     }
-    warn_report("IGVM: No parameter area for index %u", parameter_area_index);
+    error_setg(errp, "IGVM: parameter area index %u not found",
+                   parameter_area_index);
     return NULL;
 }
 
@@ -528,9 +530,10 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx,
         return 0;
     }
 
-    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    param_entry = qigvm_find_param_entry(ctx,
+                                         param->parameter_area_index, errp);
     if (param_entry == NULL) {
-        return 0;
+        return -1;
     }
 
     region = qigvm_prepare_memory(ctx, param->gpa, param_entry->size,
@@ -601,9 +604,10 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const uint8_t *header_data,
     }
 
     /* Find the parameter area that should hold the memory map */
-    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    param_entry = qigvm_find_param_entry(ctx,
+                                         param->parameter_area_index, errp);
     if (param_entry == NULL) {
-        return 0;
+        return -1;
     }
 
     max_entry_count = param_entry->size / sizeof(IGVM_VHS_MEMORY_MAP_ENTRY);
@@ -660,9 +664,10 @@ static int qigvm_directive_vp_count(QIgvm *ctx, const uint8_t *header_data,
     uint32_t *vp_count;
     CPUState *cpu;
 
-    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    param_entry = qigvm_find_param_entry(ctx,
+                                         param->parameter_area_index, errp);
     if (param_entry == NULL) {
-        return 0;
+        return -1;
     }
 
     vp_count = (uint32_t *)(param_entry->data + param->byte_offset);
@@ -683,9 +688,10 @@ static int qigvm_directive_environment_info(QIgvm *ctx,
     QIgvmParameterData *param_entry;
     IgvmEnvironmentInfo *environmental_state;
 
-    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    param_entry = qigvm_find_param_entry(ctx,
+                                         param->parameter_area_index, errp);
     if (param_entry == NULL) {
-        return 0;
+        return -1;
     }
 
     environmental_state =
diff --git a/target/i386/igvm.c b/target/i386/igvm.c
index f41b498b8924..ad9bf87761fb 100644
--- a/target/i386/igvm.c
+++ b/target/i386/igvm.c
@@ -191,9 +191,10 @@ int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
     int result = 0;
 
     /* Find the parameter area that should hold the MADT data */
-    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    param_entry = qigvm_find_param_entry(ctx,
+                                         param->parameter_area_index, errp);
     if (param_entry == NULL) {
-        return 0;
+        return -1;
     }
 
     GArray *madt = acpi_build_madt_standalone(ctx->machine_state);
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 2/3] igvm: use idiomatic meson conditional for IGVM build files
  2026-07-04  4:53 [PULL 0/3] Firmware 20260704 patches Gerd Hoffmann
  2026-07-04  4:53 ` [PULL 1/3] igvm: Report error on missing parameter area in directive handlers Gerd Hoffmann
@ 2026-07-04  4:53 ` Gerd Hoffmann
  2026-07-04  4:53 ` [PULL 3/3] igvm: add device tree parameter support Gerd Hoffmann
  2026-07-05 17:57 ` [PULL 0/3] Firmware 20260704 patches Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-07-04  4:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Ani Sinha, Stefano Garzarella, Zhao Liu,
	Gerd Hoffmann, Luigi Leonardi

From: Luigi Leonardi <leonardi@redhat.com>

Replace the explicit igvm.found() check with system_ss.add(when:,
if_true:), matching the pattern used by all other optional backends.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-ID: <20260626-microvm_device_tree-v6-2-9cd13cf057e2@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/meson.build | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/backends/meson.build b/backends/meson.build
index 60021f45d124..aabfaea5fd8d 100644
--- a/backends/meson.build
+++ b/backends/meson.build
@@ -34,11 +34,8 @@ if have_vhost_user_crypto
 endif
 system_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
 system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
-if igvm.found()
-  system_ss.add(igvm)
-  system_ss.add(files('igvm-cfg.c'), igvm)
-  system_ss.add(files('igvm.c'), igvm)
-endif
+
+system_ss.add(when: igvm, if_true: [files('igvm-cfg.c', 'igvm.c')])
 
 system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c'))
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 3/3] igvm: add device tree parameter support
  2026-07-04  4:53 [PULL 0/3] Firmware 20260704 patches Gerd Hoffmann
  2026-07-04  4:53 ` [PULL 1/3] igvm: Report error on missing parameter area in directive handlers Gerd Hoffmann
  2026-07-04  4:53 ` [PULL 2/3] igvm: use idiomatic meson conditional for IGVM build files Gerd Hoffmann
@ 2026-07-04  4:53 ` Gerd Hoffmann
  2026-07-05 17:57 ` [PULL 0/3] Firmware 20260704 patches Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-07-04  4:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Ani Sinha, Stefano Garzarella, Zhao Liu,
	Gerd Hoffmann, Luigi Leonardi

From: Luigi Leonardi <leonardi@redhat.com>

Coconut SVSM, with the upcoming device tree support [1], will use
the IGVM device tree parameter to discover virtio-mmio and ISA serial
devices instead of relying on the fw_cfg interface, which is
QEMU-specific.

The device tree is packed before copying into the IGVM parameter area
to reduce its size, since IGVM files can define tighter memory
constraints for parameter areas. Packing is done in the generic IGVM
backend rather than in per-architecture device tree setup code, so
that each architecture does not need to handle it individually.

[1] https://github.com/coconut-svsm/svsm/pull/1006

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-ID: <20260626-microvm_device_tree-v6-3-9cd13cf057e2@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/igvm.c      | 54 ++++++++++++++++++++++++++++++++++++++++++++
 backends/meson.build |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/backends/igvm.c b/backends/igvm.c
index a5a2a4eccc19..80e87fe6029a 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -26,6 +26,10 @@
 #include <igvm/igvm.h>
 #include <igvm/igvm_defs.h>
 
+#ifdef CONFIG_FDT
+#include <libfdt.h>
+#endif
+
 #ifndef IGVM_VHT_OPTIONAL_BIT
 #define IGVM_VHT_OPTIONAL_BIT (1U << 31)
 #endif
@@ -121,6 +125,10 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, const uint8_t *header_data,
 static int qigvm_initialization_guest_policy(QIgvm *ctx,
                                        const uint8_t *header_data,
                                        Error **errp);
+#ifdef CONFIG_FDT
+static int qigvm_directive_device_tree(QIgvm *ctx, const uint8_t *header_data,
+                                       Error **errp);
+#endif
 
 struct QIGVMHandler {
     IgvmVariableHeaderType type;
@@ -151,6 +159,10 @@ static struct QIGVMHandler handlers[] = {
       qigvm_initialization_guest_policy },
     { IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE,
       qigvm_directive_madt },
+#ifdef CONFIG_FDT
+    { IGVM_VHT_DEVICE_TREE, IGVM_HEADER_SECTION_DIRECTIVE,
+      qigvm_directive_device_tree },
+#endif
 };
 
 static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type,
@@ -786,6 +798,48 @@ static int qigvm_directive_snp_id_block(QIgvm *ctx, const uint8_t *header_data,
     return 0;
 }
 
+#ifdef CONFIG_FDT
+static int qigvm_directive_device_tree(QIgvm *ctx, const uint8_t *header_data,
+                                       Error **errp)
+{
+    const IGVM_VHS_PARAMETER *param = (const IGVM_VHS_PARAMETER *)header_data;
+    g_autofree void *fdt_packed = NULL;
+    QIgvmParameterData *param_entry;
+    uint32_t fdt_size;
+
+    param_entry = qigvm_find_param_entry(ctx,
+                                         param->parameter_area_index, errp);
+    if (param_entry == NULL) {
+        return -1;
+    }
+
+    if (ctx->machine_state->fdt == NULL) {
+        error_setg(errp, "IGVM: device tree not available");
+        return -1;
+    }
+
+    fdt_size = fdt_totalsize(ctx->machine_state->fdt);
+    fdt_packed = g_memdup2(ctx->machine_state->fdt, fdt_size);
+
+    if (fdt_pack(fdt_packed)) {
+        error_setg(errp, "IGVM: failed to pack device tree");
+        return -1;
+    }
+
+    fdt_size = fdt_totalsize(fdt_packed);
+    if (fdt_size > param_entry->size) {
+        error_setg(errp,
+                   "IGVM: device tree size exceeds parameter area"
+                   " defined in IGVM file");
+        return -1;
+    }
+
+    memcpy(param_entry->data, fdt_packed, fdt_size);
+
+    return 0;
+}
+#endif
+
 static int qigvm_initialization_guest_policy(QIgvm *ctx,
                                        const uint8_t *header_data, Error **errp)
 {
diff --git a/backends/meson.build b/backends/meson.build
index aabfaea5fd8d..8792c58c361f 100644
--- a/backends/meson.build
+++ b/backends/meson.build
@@ -35,7 +35,7 @@ endif
 system_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
 system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
 
-system_ss.add(when: igvm, if_true: [files('igvm-cfg.c', 'igvm.c')])
+system_ss.add(when: igvm, if_true: [files('igvm-cfg.c', 'igvm.c'), fdt])
 
 system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c'))
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PULL 0/3] Firmware 20260704 patches
  2026-07-04  4:53 [PULL 0/3] Firmware 20260704 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2026-07-04  4:53 ` [PULL 3/3] igvm: add device tree parameter support Gerd Hoffmann
@ 2026-07-05 17:57 ` Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2026-07-05 17:57 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: qemu-devel, Paolo Bonzini, Ani Sinha, Stefano Garzarella,
	Zhao Liu, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-05 17:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-04  4:53 [PULL 0/3] Firmware 20260704 patches Gerd Hoffmann
2026-07-04  4:53 ` [PULL 1/3] igvm: Report error on missing parameter area in directive handlers Gerd Hoffmann
2026-07-04  4:53 ` [PULL 2/3] igvm: use idiomatic meson conditional for IGVM build files Gerd Hoffmann
2026-07-04  4:53 ` [PULL 3/3] igvm: add device tree parameter support Gerd Hoffmann
2026-07-05 17:57 ` [PULL 0/3] Firmware 20260704 patches Stefan Hajnoczi

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.