Skip to contentSkip to conversation

Firmware 20260704 patches

GIT PULL Applied Gerd Hoffmann 2 participants 5 messages Jul 4 – Jul 5 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

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(-)
Signature · 1 line
2.55.0
#1 lore raw

[PULL 1/3] igvm: Report error on missing parameter area in directive handlers

From: Luigi Leonardi <[email protected]>

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.

Message-ID: <[email protected]>

---
 include/system/igvm-internal.h |  3 ++-
 backends/igvm.c                | 26 ++++++++++++++++----------
 target/i386/igvm.c             |  5 +++--
 3 files changed, 21 insertions(+), 13 deletions(-)
include/system/igvm-internal.h +2 -1
index 7f131c4d0392..7eb3792ed8c5 100644
@@ -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
backends/igvm.c +16 -10
index 3f4b97a5d417..a5a2a4eccc19 100644
@@ -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 =
target/i386/igvm.c +3 -2
index f41b498b8924..ad9bf87761fb 100644
@@ -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);
Signature · 1 line
2.55.0
#2 lore raw

[PULL 2/3] igvm: use idiomatic meson conditional for IGVM build files

In reply to Gerd Hoffmann

From: Luigi Leonardi <[email protected]>

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

Message-ID: <[email protected]>

---
 backends/meson.build | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
backends/meson.build +2 -5
index 60021f45d124..aabfaea5fd8d 100644
@@ -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'))
 
Signature · 1 line
2.55.0
#3 lore raw

[PULL 3/3] igvm: add device tree parameter support

In reply to Gerd Hoffmann

From: Luigi Leonardi <[email protected]>

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

Message-ID: <[email protected]>

---
 backends/igvm.c      | 54 ++++++++++++++++++++++++++++++++++++++++++++
 backends/meson.build |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)
backends/igvm.c +54 -0
index a5a2a4eccc19..80e87fe6029a 100644
@@ -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)
 {
backends/meson.build +1 -1
index aabfaea5fd8d..8792c58c361f 100644
@@ -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'))
 
Signature · 1 line
2.55.0