Skip to contentSkip to conversation

Firmware 20260203 patches

GIT PULL Applied Gerd Hoffmann 2 participants 19 messages Feb 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit b377abc220fc53e9cab2aac3c73fc20be6d85eea:

Merge tag 'hw-misc-20260202' of https://github.com/philmd/qemu into staging (2026-02-03 07:52:04 +1000)

are available in the Git repository at:

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

for you to fetch changes up to dea1f68a5cd338b338e34f2df5ecb2e35a9d8681:

igvm: Fill MADT IGVM parameter field on x86_64 (2026-02-03 08:32:33 +0100)

----------------------------------------------------------------
firmware updates for 11.0
- igvm: rework reset handling.
- igvm: add MADT parameter support.
- uefi: variable store fixes.

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

Gerd Hoffmann (7):
hw/uefi: skip time check for append-write updates. hw/uefi: fix size negotiation
igvm: reorganize headers
igvm: make igvm-cfg object resettable
igvm: move file load to complete callback
igvm: add trace points for igvm file loading and processing
igvm: move igvm file processing to reset callbacks

Jim MacArthur (1):
docs/system/igvm.rst: Update external links

Oliver Steffen (9):
hw/acpi: Make acpi_checksum() public
hw/acpi: Make BIOS linker optional
hw/acpi: Add standalone function to build MADT
igvm: Move structs to internal header
igvm: Add common function for finding parameter entries
igvm: Refactor qigvm_parameter_insert
igvm: Pass machine state to IGVM file processing
igvm: Only build stubs if igvm is enabled
igvm: Fill MADT IGVM parameter field on x86_64

 hw/i386/acpi-build.h           |   2 +
 include/hw/acpi/acpi.h         |   3 +
 include/qemu/typedefs.h        |   1 +
 include/system/igvm-cfg.h      |  15 +-
 include/system/igvm-internal.h |  82 ++++++++++
 include/system/igvm.h          |   7 +-
 backends/igvm-cfg.c            |  64 +++++++-
 backends/igvm.c                | 266 ++++++++++++++++-----------------
 hw/acpi/aml-build.c            |  12 +-
 hw/acpi/core.c                 |   5 +-
 hw/i386/acpi-build.c           |   9 ++
 hw/i386/pc_piix.c              |  10 --
 hw/i386/pc_q35.c               |  10 --
 hw/uefi/var-service-vars.c     |   5 +-
 stubs/igvm.c                   |   6 +
 target/i386/igvm.c             |  32 ++++
 target/i386/sev.c              |   3 +-
 backends/trace-events          |   7 +
 docs/system/igvm.rst           |   6 +-
 stubs/meson.build              |   4 +-
 20 files changed, 361 insertions(+), 188 deletions(-)
 create mode 100644 include/system/igvm-internal.h
Signature · 1 line
2.52.0
#1 lore raw

[PULL 01/17] docs/system/igvm.rst: Update external links

From: Jim MacArthur <[email protected]>

* Fixes link to AMD64 Architecture Programmer's Manual and bumps version to 3.43.
* Updates link to buildigvm to new home on GitLab.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3247

Message-ID: <[email protected]>

---
 docs/system/igvm.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
docs/system/igvm.rst +3 -3
index 79508d958802..9db8ae43d21d 100644
@@ -166,8 +166,8 @@ References
 ----------
 
 [1] AMD64 Architecture Programmer's Manual, Volume 2: System Programming
-  Rev 3.41
-  https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf
+  Rev 3.43
+  https://docs.amd.com/v/u/en-US/24593_3.43
 
 [2] ``buildigvm`` - A tool to build example IGVM files containing OVMF firmware
-  https://github.com/roy-hopkins/buildigvm
\ No newline at end of file
+  https://gitlab.com/qemu-project/buildigvm
Signature · 1 line
2.52.0
#2 lore raw

[PULL 02/17] hw/uefi: skip time check for append-write updates.

In reply to Gerd Hoffmann

Only execute the time time check if the EFI_VARIABLE_APPEND_WRITE bit is clear. For append-write updates the timestamp verification is not needed.

See uefi spec, section "8.2.6 Using the EFI_VARIABLE_AUTHENTICATION_2 descriptor"

Fixes db1ecfb473ac ("hw/uefi: add var-service-vars.c")

Message-ID: <[email protected]>

---
 hw/uefi/var-service-vars.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/uefi/var-service-vars.c +2 -1
index 8533533ea5c8..52845e9723d3 100644
@@ -475,7 +475,8 @@ static size_t uefi_vars_mm_set_variable(uefi_vars_state *uv, mm_header *mhdr,
                 goto rollback;
             }
             if (old_var && new_var) {
-                if (uefi_time_compare(&old_var->time, &new_var->time) > 0) {
+                if ((va->attributes & EFI_VARIABLE_APPEND_WRITE) == 0 &&
+                    uefi_time_compare(&old_var->time, &new_var->time) > 0) {
                     trace_uefi_vars_security_violation("time check failed");
                     mvar->status = EFI_SECURITY_VIOLATION;
                     goto rollback;
Signature · 1 line
2.52.0
#3 lore raw

[PULL 03/17] hw/uefi: fix size negotiation

In reply to Gerd Hoffmann

Payload size is the variable request size, not the total buffer size. Take that into account and subtract header sizes.

Fixes db1ecfb473ac ("hw/uefi: add var-service-vars.c")

Message-ID: <[email protected]>

---
 hw/uefi/var-service-vars.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/uefi/var-service-vars.c +1 -1
index 52845e9723d3..94f40ef23684 100644
@@ -593,7 +593,7 @@ uefi_vars_mm_get_payload_size(uefi_vars_state *uv, mm_header *mhdr,
         return uefi_vars_mm_error(mhdr, mvar, EFI_BAD_BUFFER_SIZE);
     }
 
-    ps->payload_size = uv->buf_size;
+    ps->payload_size = uv->buf_size - sizeof(*mhdr) - sizeof(*mvar);
     mvar->status = EFI_SUCCESS;
     return length;
 }
Signature · 1 line
2.52.0
#4 lore raw

[PULL 05/17] igvm: make igvm-cfg object resettable

In reply to Gerd Hoffmann

Add TYPE_RESETTABLE_INTERFACE to interfaces. Register callbacks for the reset phases. Add trace points for logging and debugging. No functional change, that will come in followup patches.

Message-ID: <[email protected]>

---
 include/system/igvm-internal.h |  2 ++
 backends/igvm-cfg.c            | 35 +++++++++++++++++++++++++++++++++-
 backends/trace-events          |  5 +++++
 3 files changed, 41 insertions(+), 1 deletion(-)
include/system/igvm-internal.h +2 -0
index 475a29bbf3d7..ac9e5683cc63 100644
@@ -11,6 +11,7 @@
 
 #include "qemu/typedefs.h"
 #include "qom/object.h"
+#include "hw/core/resettable.h"
 
 struct IgvmCfg {
     ObjectClass parent_class;
@@ -21,6 +22,7 @@ struct IgvmCfg {
      *           format.
      */
     char *filename;
+    ResettableState reset_state;
 };
 
 #endif
backends/igvm-cfg.c +34 -1
index 001c4dc93346..e0df3eaa8efd 100644
@@ -17,6 +17,8 @@
 #include "system/reset.h"
 #include "qom/object_interfaces.h"
 
+#include "trace.h"
+
 static char *get_igvm(Object *obj, Error **errp)
 {
     IgvmCfg *igvm = IGVM_CFG(obj);
@@ -30,24 +32,55 @@ static void set_igvm(Object *obj, const char *value, Error **errp)
     igvm->filename = g_strdup(value);
 }
 
+static ResettableState *igvm_reset_state(Object *obj)
+{
+    IgvmCfg *igvm = IGVM_CFG(obj);
+    return &igvm->reset_state;
+}
+
+static void igvm_reset_enter(Object *obj, ResetType type)
+{
+    trace_igvm_reset_enter(type);
+}
+
+static void igvm_reset_hold(Object *obj, ResetType type)
+{
+    trace_igvm_reset_hold(type);
+}
+
+static void igvm_reset_exit(Object *obj, ResetType type)
+{
+    trace_igvm_reset_exit(type);
+}
+
 OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
-                                   { TYPE_USER_CREATABLE }, { NULL })
+                                   { TYPE_USER_CREATABLE },
+                                   { TYPE_RESETTABLE_INTERFACE },
+                                   { NULL })
 
 static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
 {
     IgvmCfgClass *igvmc = IGVM_CFG_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
 
     object_class_property_add_str(oc, "file", get_igvm, set_igvm);
     object_class_property_set_description(oc, "file",
                                           "Set the IGVM filename to use");
 
     igvmc->process = qigvm_process_file;
+
+    rc->get_state = igvm_reset_state;
+    rc->phases.enter = igvm_reset_enter;
+    rc->phases.hold = igvm_reset_hold;
+    rc->phases.exit = igvm_reset_exit;
 }
 
 static void igvm_cfg_init(Object *obj)
 {
+    qemu_register_resettable(obj);
 }
 
 static void igvm_cfg_finalize(Object *obj)
 {
+    qemu_unregister_resettable(obj);
 }
backends/trace-events +5 -0
index 14a7ecf5aaf4..87e0c636ec02 100644
@@ -23,3 +23,8 @@ iommufd_backend_get_dirty_bitmap(int iommufd, uint32_t hwpt_id, uint64_t iova, u
 iommufd_backend_invalidate_cache(int iommufd, uint32_t id, uint32_t data_type, uint32_t entry_len, uint32_t entry_num, uint32_t done_num, uint64_t data_ptr, int ret) " iommufd=%d id=%u data_type=%u entry_len=%u entry_num=%u done_num=%u data_ptr=0x%"PRIx64" (%d)"
 iommufd_backend_alloc_viommu(int iommufd, uint32_t dev_id, uint32_t type, uint32_t hwpt_id, uint32_t viommu_id, int ret) " iommufd=%d type=%u dev_id=%u hwpt_id=%u viommu_id=%u (%d)"
 iommufd_backend_alloc_vdev(int iommufd, uint32_t dev_id, uint32_t viommu_id, uint64_t virt_id, uint32_t vdev_id, int ret) " iommufd=%d dev_id=%u viommu_id=%u virt_id=0x%"PRIx64" vdev_id=%u (%d)"
+
+# igvm-cfg.c
+igvm_reset_enter(int type) "type=%u"
+igvm_reset_hold(int type) "type=%u"
+igvm_reset_exit(int type) "type=%u"
Signature · 1 line
2.52.0
#5 lore raw

[PULL 04/17] igvm: reorganize headers

In reply to Gerd Hoffmann

Add a new igvm-internal.h header file. Structs and declarations which depend on the igvm library header go into that file.

Also declare IgvmCfg in typedefs.h, so the type can be used without including igvm header files.

Message-ID: <[email protected]>

---
 include/qemu/typedefs.h        |  1 +
 include/system/igvm-cfg.h      | 12 +-----------
 include/system/igvm-internal.h | 26 ++++++++++++++++++++++++++
 include/system/igvm.h          |  2 +-
 backends/igvm-cfg.c            |  4 +++-
 backends/igvm.c                |  2 ++
 6 files changed, 34 insertions(+), 13 deletions(-)
 create mode 100644 include/system/igvm-internal.h
include/qemu/typedefs.h +1 -0
index 4a94af9665a5..416a8c9acead 100644
@@ -55,6 +55,7 @@ typedef struct FWCfgState FWCfgState;
 typedef struct HostMemoryBackend HostMemoryBackend;
 typedef struct I2CBus I2CBus;
 typedef struct I2SCodec I2SCodec;
+typedef struct IgvmCfg IgvmCfg;
 typedef struct IOMMUMemoryRegion IOMMUMemoryRegion;
 typedef struct ISABus ISABus;
 typedef struct ISADevice ISADevice;
include/system/igvm-cfg.h +1 -11
index 944f23a814dd..6c07f3084082 100644
@@ -12,19 +12,9 @@
 #ifndef QEMU_IGVM_CFG_H
 #define QEMU_IGVM_CFG_H
 
+#include "qemu/typedefs.h"
 #include "qom/object.h"
 
-typedef struct IgvmCfg {
-    ObjectClass parent_class;
-
-    /*
-     * filename: Filename that specifies a file that contains the configuration
-     *           of the guest in Independent Guest Virtual Machine (IGVM)
-     *           format.
-     */
-    char *filename;
-} IgvmCfg;
-
 typedef struct IgvmCfgClass {
     ObjectClass parent_class;
 
include/system/igvm-internal.h new file +26 -0
new file mode 100644
index 000000000000..475a29bbf3d7
@@ -0,0 +1,26 @@
+/*
+ * QEMU IGVM private data structures
+ *
+ * Everything which depends on igvm library headers goes here.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_IGVM_INTERNAL_H
+#define QEMU_IGVM_INTERNAL_H
+
+#include "qemu/typedefs.h"
+#include "qom/object.h"
+
+struct IgvmCfg {
+    ObjectClass parent_class;
+
+    /*
+     * filename: Filename that specifies a file that contains the configuration
+     *           of the guest in Independent Guest Virtual Machine (IGVM)
+     *           format.
+     */
+    char *filename;
+};
+
+#endif
include/system/igvm.h +1 -1
index 48ce20604259..8355e54e95fc 100644
@@ -12,8 +12,8 @@
 #ifndef BACKENDS_IGVM_H
 #define BACKENDS_IGVM_H
 
+#include "qemu/typedefs.h"
 #include "system/confidential-guest-support.h"
-#include "system/igvm-cfg.h"
 #include "qapi/error.h"
 
 int qigvm_process_file(IgvmCfg *igvm, ConfidentialGuestSupport *cgs,
backends/igvm-cfg.c +3 -1
index d00acf351249..001c4dc93346 100644
@@ -11,8 +11,10 @@
 
 #include "qemu/osdep.h"
 
-#include "system/igvm-cfg.h"
 #include "system/igvm.h"
+#include "system/igvm-cfg.h"
+#include "system/igvm-internal.h"
+#include "system/reset.h"
 #include "qom/object_interfaces.h"
 
 static char *get_igvm(Object *obj, Error **errp)
backends/igvm.c +2 -0
index 905bd8d98994..fbb8300b6d01 100644
@@ -14,6 +14,8 @@
 #include "qapi/error.h"
 #include "qemu/target-info-qapi.h"
 #include "system/igvm.h"
+#include "system/igvm-cfg.h"
+#include "system/igvm-internal.h"
 #include "system/memory.h"
 #include "system/address-spaces.h"
 #include "hw/core/cpu.h"
Signature · 1 line
2.52.0
#6 lore raw

[PULL 07/17] igvm: add trace points for igvm file loading and processing

In reply to Gerd Hoffmann

Message-ID: <[email protected]>

---
 backends/igvm.c       | 5 +++++
 backends/trace-events | 2 ++
 2 files changed, 7 insertions(+)
backends/igvm.c +5 -0
index a01e01a12a60..4cf7b572347c 100644
@@ -20,6 +20,8 @@
 #include "system/address-spaces.h"
 #include "hw/core/cpu.h"
 
+#include "trace.h"
+
 #include <igvm/igvm.h>
 #include <igvm/igvm_defs.h>
 
@@ -886,6 +888,8 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp)
         error_setg(errp, "Unable to parse IGVM file %s: %d", filename, igvm);
         return -1;
     }
+
+    trace_igvm_file_loaded(filename, igvm);
     return igvm;
 }
 
@@ -903,6 +907,7 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
         return -1;
     }
     ctx.file = cfg->file;
+    trace_igvm_process_file(cfg->file, onlyVpContext);
 
     /*
      * The ConfidentialGuestSupport object is optional and allows a confidential
backends/trace-events +2 -0
index 87e0c636ec02..8dc64a20d3d9 100644
@@ -28,3 +28,5 @@ iommufd_backend_alloc_vdev(int iommufd, uint32_t dev_id, uint32_t viommu_id, uin
 igvm_reset_enter(int type) "type=%u"
 igvm_reset_hold(int type) "type=%u"
 igvm_reset_exit(int type) "type=%u"
+igvm_file_loaded(const char *fn, int32_t handle) "fn=%s, handle=0x%x"
+igvm_process_file(int32_t handle, bool context_only) "handle=0x%x context-only=%d"
Signature · 1 line
2.52.0
#7 lore raw

[PULL 08/17] igvm: move igvm file processing to reset callbacks

In reply to Gerd Hoffmann

Move igvm file processing from machine init to reset callbacks. With that the igvm file is properly re-loaded on reset. Also the loading happens later in the init process now. This will simplify future support for some IGVM parameters which depend on initialization steps which happen after machine init.

Message-ID: <[email protected]>

---
 backends/igvm-cfg.c |  7 +++++++
 hw/i386/pc_piix.c   | 10 ----------
 hw/i386/pc_q35.c    | 10 ----------
 3 files changed, 7 insertions(+), 20 deletions(-)
backends/igvm-cfg.c +7 -0
index 4014062e0f22..f236b523df3b 100644
@@ -16,6 +16,8 @@
 #include "system/igvm-internal.h"
 #include "system/reset.h"
 #include "qom/object_interfaces.h"
+#include "hw/core/qdev.h"
+#include "hw/core/boards.h"
 
 #include "trace.h"
 
@@ -45,7 +47,12 @@ static void igvm_reset_enter(Object *obj, ResetType type)
 
 static void igvm_reset_hold(Object *obj, ResetType type)
 {
+    MachineState *ms = MACHINE(qdev_get_machine());
+    IgvmCfg *igvm = IGVM_CFG(obj);
+
     trace_igvm_reset_hold(type);
+
+    qigvm_process_file(igvm, ms->cgs, false, &error_fatal);
 }
 
 static void igvm_reset_exit(Object *obj, ResetType type)
hw/i386/pc_piix.c +0 -10
index fea158fc4bfe..878db5721b78 100644
@@ -320,16 +320,6 @@ static void pc_init1(MachineState *machine, const char *pci_type)
                                x86_nvdimm_acpi_dsmio,
                                x86ms->fw_cfg, OBJECT(pcms));
     }
-
-#if defined(CONFIG_IGVM)
-    /* Apply guest state from IGVM if supplied */
-    if (x86ms->igvm) {
-        if (IGVM_CFG_GET_CLASS(x86ms->igvm)
-                ->process(x86ms->igvm, machine->cgs, false, &error_fatal) < 0) {
-            g_assert_not_reached();
-        }
-    }
-#endif
 }
 
 typedef enum PCSouthBridgeOption {
hw/i386/pc_q35.c +0 -10
index 4d6046e47b0d..6e5a23d718f1 100644
@@ -328,16 +328,6 @@ static void pc_q35_init(MachineState *machine)
                                x86_nvdimm_acpi_dsmio,
                                x86ms->fw_cfg, OBJECT(pcms));
     }
-
-#if defined(CONFIG_IGVM)
-    /* Apply guest state from IGVM if supplied */
-    if (x86ms->igvm) {
-        if (IGVM_CFG_GET_CLASS(x86ms->igvm)
-                ->process(x86ms->igvm, machine->cgs, false, &error_fatal) < 0) {
-            g_assert_not_reached();
-        }
-    }
-#endif
 }
 
 #define DEFINE_Q35_MACHINE(major, minor) \
Signature · 1 line
2.52.0
#8 lore raw

[PULL 09/17] hw/acpi: Make acpi_checksum() public

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Make the ACPI table checksum calculation function (in core.c) public so it can be reused in other parts of the ACPI code.

Message-ID: <[email protected]>

---
 include/hw/acpi/acpi.h | 3 +++
 hw/acpi/core.c         | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
include/hw/acpi/acpi.h +3 -0
index 4b8ee094c419..b036116dfb87 100644
@@ -203,4 +203,7 @@ struct AcpiSlicOem {
 };
 int acpi_get_slic_oem(AcpiSlicOem *oem);
 
+/* core.c */
+int acpi_checksum(const uint8_t *data, int len);
+
 #endif /* QEMU_HW_ACPI_H */
hw/acpi/core.c +4 -1
index d9979b0da949..6b65e587f2a5 100644
@@ -83,7 +83,10 @@ bool acpi_builtin(void)
     return true;
 }
 
-static int acpi_checksum(const uint8_t *data, int len)
+/* Calculate the ACPI checksum value so that if used in the corresponding
+ * header field, the ACPI checksum verification will be successful.
+ */
+int acpi_checksum(const uint8_t *data, int len)
 {
     int sum, i;
     sum = 0;
Signature · 1 line
2.52.0
#9 lore raw

[PULL 06/17] igvm: move file load to complete callback

In reply to Gerd Hoffmann

Add UserCreatableClass->complete callback function for igvm-cfg object.

Move file loading and parsing of the igvm file from the process function to the new complete() callback function. Keep the igvm file loaded after processing, release it in finalize() instead, so we parse it only once.

Message-ID: <[email protected]>

---
 include/system/igvm-internal.h |  5 +++++
 backends/igvm-cfg.c            | 18 ++++++++++++++++++
 backends/igvm.c                |  9 ++++-----
 3 files changed, 27 insertions(+), 5 deletions(-)
include/system/igvm-internal.h +5 -0
index ac9e5683cc63..171cec8d0f6c 100644
@@ -13,6 +13,8 @@
 #include "qom/object.h"
 #include "hw/core/resettable.h"
 
+#include <igvm/igvm.h>
+
 struct IgvmCfg {
     ObjectClass parent_class;
 
@@ -22,7 +24,10 @@ struct IgvmCfg {
      *           format.
      */
     char *filename;
+    IgvmHandle file;
     ResettableState reset_state;
 };
 
+IgvmHandle qigvm_file_init(char *filename, Error **errp);
+
 #endif
backends/igvm-cfg.c +18 -0
index e0df3eaa8efd..4014062e0f22 100644
@@ -53,6 +53,13 @@ static void igvm_reset_exit(Object *obj, ResetType type)
     trace_igvm_reset_exit(type);
 }
 
+static void igvm_complete(UserCreatable *uc, Error **errp)
+{
+    IgvmCfg *igvm = IGVM_CFG(uc);
+
+    igvm->file = qigvm_file_init(igvm->filename, errp);
+}
+
 OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
                                    { TYPE_USER_CREATABLE },
                                    { TYPE_RESETTABLE_INTERFACE },
@@ -62,6 +69,7 @@ static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
 {
     IgvmCfgClass *igvmc = IGVM_CFG_CLASS(oc);
     ResettableClass *rc = RESETTABLE_CLASS(oc);
+    UserCreatableClass *uc = USER_CREATABLE_CLASS(oc);
 
     object_class_property_add_str(oc, "file", get_igvm, set_igvm);
     object_class_property_set_description(oc, "file",
@@ -73,14 +81,24 @@ static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
     rc->phases.enter = igvm_reset_enter;
     rc->phases.hold = igvm_reset_hold;
     rc->phases.exit = igvm_reset_exit;
+
+    uc->complete = igvm_complete;
 }
 
 static void igvm_cfg_init(Object *obj)
 {
+    IgvmCfg *igvm = IGVM_CFG(obj);
+
+    igvm->file = -1;
     qemu_register_resettable(obj);
 }
 
 static void igvm_cfg_finalize(Object *obj)
 {
+    IgvmCfg *igvm = IGVM_CFG(obj);
+
     qemu_unregister_resettable(obj);
+    if (igvm->file >= 0) {
+        igvm_free(igvm->file);
+    }
 }
backends/igvm.c +4 -5
index fbb8300b6d01..a01e01a12a60 100644
@@ -869,7 +869,7 @@ static int qigvm_handle_policy(QIgvm *ctx, Error **errp)
     return 0;
 }
 
-static IgvmHandle qigvm_file_init(char *filename, Error **errp)
+IgvmHandle qigvm_file_init(char *filename, Error **errp)
 {
     IgvmHandle igvm;
     g_autofree uint8_t *buf = NULL;
@@ -898,10 +898,11 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
     QIgvm ctx;
 
     memset(&ctx, 0, sizeof(ctx));
-    ctx.file = qigvm_file_init(cfg->filename, errp);
-    if (ctx.file < 0) {
+    if (cfg->file < 0) {
+        error_setg(errp, "No IGVM file loaded.");
         return -1;
     }
+    ctx.file = cfg->file;
 
     /*
      * The ConfidentialGuestSupport object is optional and allows a confidential
@@ -992,7 +993,5 @@ cleanup_parameters:
     g_free(ctx.id_auth);
 
 cleanup:
-    igvm_free(ctx.file);
-
     return retval;
 }
Signature · 1 line
2.52.0
#10 lore raw

[PULL 10/17] hw/acpi: Make BIOS linker optional

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Make the BIOS linker optional in acpi_table_end() and calculate the ACPI table checksum directly if no linker is provided.

This makes it possible to call for example acpi_build_madt() from outside the ACPI table builder context.

Message-ID: <[email protected]>

---
 hw/acpi/aml-build.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
hw/acpi/aml-build.c +10 -2
index dad4cfcc7d80..ea1c415b211b 100644
@@ -22,6 +22,7 @@
 #include "qemu/osdep.h"
 #include <glib/gprintf.h>
 #include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi.h"
 #include "qemu/bswap.h"
 #include "qemu/bitops.h"
 #include "system/numa.h"
@@ -1741,6 +1742,7 @@ void acpi_table_end(BIOSLinker *linker, AcpiTable *desc)
     uint32_t table_len = desc->array->len - desc->table_offset;
     uint32_t table_len_le = cpu_to_le32(table_len);
     gchar *len_ptr = &desc->array->data[desc->table_offset + 4];
+    uint8_t *table;
 
     /* patch "Length" field that has been reserved by acpi_table_begin()
      * to the actual length, i.e. accumulated table length from
@@ -1748,8 +1750,14 @@ void acpi_table_end(BIOSLinker *linker, AcpiTable *desc)
      */
     memcpy(len_ptr, &table_len_le, sizeof table_len_le);
 
-    bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
-        desc->table_offset, table_len, desc->table_offset + checksum_offset);
+    if (linker != NULL) {
+        bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
+                                        desc->table_offset, table_len,
+                                        desc->table_offset + checksum_offset);
+    } else {
+        table = (uint8_t *) &desc->array->data[desc->table_offset];
+        table[checksum_offset] = acpi_checksum(table, table_len);
+    }
 }
 
 void *acpi_data_push(GArray *table_data, unsigned size)
Signature · 1 line
2.52.0
#11 lore raw

[PULL 11/17] hw/acpi: Add standalone function to build MADT

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Add a function called acpi_build_madt_standalone() that builds a MADT without the rest of the ACPI table structure.

Message-ID: <[email protected]>

---
 hw/i386/acpi-build.h | 2 ++
 hw/i386/acpi-build.c | 9 +++++++++
 2 files changed, 11 insertions(+)
hw/i386/acpi-build.h +2 -0
index 8ba3c33e4831..00e19bbe5edf 100644
@@ -8,4 +8,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 void acpi_setup(void);
 Object *acpi_get_i386_pci_host(void);
 
+GArray *acpi_build_madt_standalone(MachineState *machine);
+
 #endif
hw/i386/acpi-build.c +9 -0
index 9446a9f862ca..19c62362e31d 100644
@@ -2249,3 +2249,12 @@ void acpi_setup(void)
      */
     acpi_build_tables_cleanup(&tables, false);
 }
+
+GArray *acpi_build_madt_standalone(MachineState *machine)
+{
+  X86MachineState *x86ms = X86_MACHINE(machine);
+  GArray *table = g_array_new(false, true, 1);
+  acpi_build_madt(table, NULL, x86ms, x86ms->oem_id,
+                  x86ms->oem_table_id);
+  return table;
+}
Signature · 1 line
2.52.0
#12 lore raw

[PULL 12/17] igvm: Move structs to internal header

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Move QIgvm and QIgvmParameter struct definitions from the source file into an IGVM internal header file to allow implementing architecture specific IGVM code in other places, for example target/i386/igvm.c.

Message-ID: <[email protected]>

---
 include/system/igvm-internal.h | 40 ++++++++++++++++++++++++++++++++++
 backends/igvm.c                | 37 -------------------------------
 2 files changed, 40 insertions(+), 37 deletions(-)
include/system/igvm-internal.h +40 -0
index 171cec8d0f6c..9c8e887d6f60 100644
@@ -9,10 +9,12 @@
 #ifndef QEMU_IGVM_INTERNAL_H
 #define QEMU_IGVM_INTERNAL_H
 
+#include "qemu/queue.h"
 #include "qemu/typedefs.h"
 #include "qom/object.h"
 #include "hw/core/resettable.h"
 
+#include "system/confidential-guest-support.h"
 #include <igvm/igvm.h>
 
 struct IgvmCfg {
@@ -28,6 +30,44 @@ struct IgvmCfg {
     ResettableState reset_state;
 };
 
+typedef struct QIgvmParameterData {
+    QTAILQ_ENTRY(QIgvmParameterData) next;
+    uint8_t *data;
+    uint32_t size;
+    uint32_t index;
+} QIgvmParameterData;
+
+/*
+ * QIgvm contains the information required during processing of a single IGVM
+ * file.
+ */
+typedef struct QIgvm {
+    IgvmHandle file;
+    ConfidentialGuestSupport *cgs;
+    ConfidentialGuestSupportClass *cgsc;
+    uint32_t compatibility_mask;
+    unsigned current_header_index;
+    QTAILQ_HEAD(, QIgvmParameterData) parameter_data;
+    IgvmPlatformType platform_type;
+
+    /*
+     * SEV-SNP platforms can contain an ID block and authentication
+     * that should be verified by the guest.
+     */
+    struct sev_id_block *id_block;
+    struct sev_id_authentication *id_auth;
+
+    /* Define the guest policy for SEV guests */
+    uint64_t sev_policy;
+
+    /* These variables keep track of contiguous page regions */
+    IGVM_VHS_PAGE_DATA region_prev_page_data;
+    uint64_t region_start;
+    unsigned region_start_index;
+    unsigned region_last_index;
+    unsigned region_page_count;
+} QIgvm;
+
 IgvmHandle qigvm_file_init(char *filename, Error **errp);
 
 #endif
backends/igvm.c +0 -37
index 4cf7b572347c..3a3832dc2dde 100644
@@ -25,12 +25,6 @@
 #include <igvm/igvm.h>
 #include <igvm/igvm_defs.h>
 
-typedef struct QIgvmParameterData {
-    QTAILQ_ENTRY(QIgvmParameterData) next;
-    uint8_t *data;
-    uint32_t size;
-    uint32_t index;
-} QIgvmParameterData;
 
 /*
  * Some directives are specific to particular confidential computing platforms.
@@ -66,37 +60,6 @@ struct QEMU_PACKED sev_id_authentication {
 
 #define IGVM_SEV_ID_BLOCK_VERSION 1
 
-/*
- * QIgvm contains the information required during processing
- * of a single IGVM file.
- */
-typedef struct QIgvm {
-    IgvmHandle file;
-    ConfidentialGuestSupport *cgs;
-    ConfidentialGuestSupportClass *cgsc;
-    uint32_t compatibility_mask;
-    unsigned current_header_index;
-    QTAILQ_HEAD(, QIgvmParameterData) parameter_data;
-    IgvmPlatformType platform_type;
-
-    /*
-     * SEV-SNP platforms can contain an ID block and authentication
-     * that should be verified by the guest.
-     */
-    struct sev_id_block *id_block;
-    struct sev_id_authentication *id_auth;
-
-    /* Define the guest policy for SEV guests */
-    uint64_t sev_policy;
-
-    /* These variables keep track of contiguous page regions */
-    IGVM_VHS_PAGE_DATA region_prev_page_data;
-    uint64_t region_start;
-    unsigned region_start_index;
-    unsigned region_last_index;
-    unsigned region_page_count;
-} QIgvm;
-
 static int qigvm_directive_page_data(QIgvm *ctx, const uint8_t *header_data,
                                      Error **errp);
 static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
Signature · 1 line
2.52.0
#13 lore raw

[PULL 13/17] igvm: Add common function for finding parameter entries

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Move repeating code for finding the parameter entries in the IGVM backend out of the parameter handlers into a common function.

A warning message is emitted in case a no parameter entry can be found for a given index.

Message-ID: <[email protected]>

---
 include/system/igvm-internal.h |   3 +
 backends/igvm.c                | 139 ++++++++++++++++++---------------
 2 files changed, 78 insertions(+), 64 deletions(-)
include/system/igvm-internal.h +3 -0
index 9c8e887d6f60..019f95e86615 100644
@@ -70,4 +70,7 @@ typedef struct QIgvm {
 
 IgvmHandle qigvm_file_init(char *filename, Error **errp);
 
+QIgvmParameterData*
+qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
+
 #endif
backends/igvm.c +75 -64

178 lines not on this page · raw message

Signature · 1 line
2.52.0
#14 lore raw

[PULL 14/17] igvm: Refactor qigvm_parameter_insert

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Use qigvm_find_param_entry() also in qigvm_parameter_insert(). This changes behavior: Processing now stops after the first parameter entry found. That is OK, because we expect only one matching entry anyway.

Message-ID: <[email protected]>

---
 backends/igvm.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)
backends/igvm.c +24 -24
index ea3f9d6b008f..ffd1c325b661 100644
@@ -476,31 +476,31 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx,
         return 0;
     }
 
-    QTAILQ_FOREACH(param_entry, &ctx->parameter_data, next)
-    {
-        if (param_entry->index == param->parameter_area_index) {
-            region = qigvm_prepare_memory(ctx, param->gpa, param_entry->size,
-                                          ctx->current_header_index, errp);
-            if (!region) {
-                return -1;
-            }
-            memcpy(region, param_entry->data, param_entry->size);
-            g_free(param_entry->data);
-            param_entry->data = NULL;
+    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    if (param_entry == NULL) {
+        return 0;
+    }
 
-            /*
-             * If a confidential guest support object is provided then use it to
-             * set the guest state.
-             */
-            if (ctx->cgs) {
-                result = ctx->cgsc->set_guest_state(param->gpa, region,
-                                                    param_entry->size,
-                                                    CGS_PAGE_TYPE_UNMEASURED, 0,
-                                                    errp);
-                if (result < 0) {
-                    return -1;
-                }
-            }
+    region = qigvm_prepare_memory(ctx, param->gpa, param_entry->size,
+                                    ctx->current_header_index, errp);
+    if (!region) {
+        return -1;
+    }
+    memcpy(region, param_entry->data, param_entry->size);
+    g_free(param_entry->data);
+    param_entry->data = NULL;
+
+    /*
+     * If a confidential guest support object is provided then use it to
+     * set the guest state.
+     */
+    if (ctx->cgs) {
+        result = ctx->cgsc->set_guest_state(param->gpa, region,
+                                            param_entry->size,
+                                            CGS_PAGE_TYPE_UNMEASURED, 0,
+                                            errp);
+        if (result < 0) {
+            return -1;
         }
     }
     return 0;
Signature · 1 line
2.52.0
#15 lore raw

[PULL 15/17] igvm: Pass machine state to IGVM file processing

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Pass the full MachineState to the IGVM backend during file processing, instead of just the ConfidentialGuestSupport struct (which is a member of the MachineState).
This replaces the cgs parameter of qigvm_process_file() with the machine state to make it available in the IGVM processing context.

We will use it later to generate MADT data there to pass to the guest as IGVM parameter.

Message-ID: <[email protected]>

---
 include/system/igvm-cfg.h      |  3 ++-
 include/system/igvm-internal.h |  3 ++-
 include/system/igvm.h          |  5 +++--
 backends/igvm-cfg.c            |  2 +-
 backends/igvm.c                | 28 ++++++++++++++++------------
 target/i386/sev.c              |  3 +--
 6 files changed, 25 insertions(+), 19 deletions(-)
include/system/igvm-cfg.h +2 -1
index 6c07f3084082..e06d611f7446 100644
@@ -12,6 +12,7 @@
 #ifndef QEMU_IGVM_CFG_H
 #define QEMU_IGVM_CFG_H
 
+#include "hw/core/boards.h"
 #include "qemu/typedefs.h"
 #include "qom/object.h"
 
@@ -27,7 +28,7 @@ typedef struct IgvmCfgClass {
      *
      * Returns 0 for ok and -1 on error.
      */
-    int (*process)(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
+    int (*process)(IgvmCfg *cfg, MachineState *machine_state,
                    bool onlyVpContext, Error **errp);
 
 } IgvmCfgClass;
include/system/igvm-internal.h +2 -1
index 019f95e86615..1d36519ab082 100644
@@ -12,6 +12,7 @@
 #include "qemu/queue.h"
 #include "qemu/typedefs.h"
 #include "qom/object.h"
+#include "hw/core/boards.h"
 #include "hw/core/resettable.h"
 
 #include "system/confidential-guest-support.h"
@@ -43,7 +44,7 @@ typedef struct QIgvmParameterData {
  */
 typedef struct QIgvm {
     IgvmHandle file;
-    ConfidentialGuestSupport *cgs;
+    MachineState *machine_state;
     ConfidentialGuestSupportClass *cgsc;
     uint32_t compatibility_mask;
     unsigned current_header_index;
include/system/igvm.h +3 -2
index 8355e54e95fc..5573a6111ae7 100644
@@ -12,12 +12,13 @@
 #ifndef BACKENDS_IGVM_H
 #define BACKENDS_IGVM_H
 
+#include "hw/core/boards.h"
 #include "qemu/typedefs.h"
 #include "system/confidential-guest-support.h"
 #include "qapi/error.h"
 
-int qigvm_process_file(IgvmCfg *igvm, ConfidentialGuestSupport *cgs,
-                      bool onlyVpContext, Error **errp);
+int qigvm_process_file(IgvmCfg *igvm, MachineState *machine_state,
+                       bool onlyVpContext, Error **errp);
 
 /* x86 native */
 int qigvm_x86_get_mem_map_entry(int index,
backends/igvm-cfg.c +1 -1
index f236b523df3b..64589ca34f24 100644
@@ -52,7 +52,7 @@ static void igvm_reset_hold(Object *obj, ResetType type)
 
     trace_igvm_reset_hold(type);
 
-    qigvm_process_file(igvm, ms->cgs, false, &error_fatal);
+    qigvm_process_file(igvm, ms, false, &error_fatal);
 }
 
 static void igvm_reset_exit(Object *obj, ResetType type)
backends/igvm.c +16 -12
index ffd1c325b661..3e7c0ea41d14 100644
@@ -202,7 +202,8 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size,
         g_autofree char *region_name =
             g_strdup_printf("igvm.%X", region_identifier);
         igvm_pages = g_new0(MemoryRegion, 1);
-        if (ctx->cgs && ctx->cgs->require_guest_memfd) {
+        if (ctx->machine_state->cgs &&
+            ctx->machine_state->cgs->require_guest_memfd) {
             if (!memory_region_init_ram_guest_memfd(igvm_pages, NULL,
                                                     region_name, size, errp)) {
                 return NULL;
@@ -322,7 +323,7 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,
      * If a confidential guest support object is provided then use it to set the
      * guest state.
      */
-    if (ctx->cgs) {
+    if (ctx->machine_state->cgs) {
         cgs_page_type =
             qigvm_type_to_cgs_type(page_type, flags->unmeasured, zero);
         if (cgs_page_type < 0) {
@@ -424,7 +425,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,
 
     data = (uint8_t *)igvm_get_buffer(ctx->file, data_handle);
 
-    if (ctx->cgs) {
+    if (ctx->machine_state->cgs) {
         result = ctx->cgsc->set_guest_state(
             vp_context->gpa, data, igvm_get_buffer_size(ctx->file, data_handle),
             CGS_PAGE_TYPE_VMSA, vp_context->vp_index, errp);
@@ -494,7 +495,7 @@ static int qigvm_directive_parameter_insert(QIgvm *ctx,
      * If a confidential guest support object is provided then use it to
      * set the guest state.
      */
-    if (ctx->cgs) {
+    if (ctx->machine_state->cgs) {
         result = ctx->cgsc->set_guest_state(param->gpa, region,
                                             param_entry->size,
                                             CGS_PAGE_TYPE_UNMEASURED, 0,
@@ -535,7 +536,7 @@ static int qigvm_directive_memory_map(QIgvm *ctx, const uint8_t *header_data,
     ConfidentialGuestMemoryMapEntry cgmm_entry;
     int retval = 0;
 
-    if (ctx->cgs && ctx->cgsc->get_mem_map_entry) {
+    if (ctx->machine_state->cgs && ctx->cgsc->get_mem_map_entry) {
         get_mem_map_entry = ctx->cgsc->get_mem_map_entry;
 
     } else if (target_arch() == SYS_EMU_TARGET_X86_64) {
@@ -661,7 +662,7 @@ static int qigvm_directive_required_memory(QIgvm *ctx,
     if (!region) {
         return -1;
     }
-    if (ctx->cgs) {
+    if (ctx->machine_state->cgs) {
         result =
             ctx->cgsc->set_guest_state(mem->gpa, region, mem->number_of_bytes,
                                        CGS_PAGE_TYPE_REQUIRED_MEMORY, 0, errp);
@@ -779,14 +780,14 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
                                                 sizeof(
                                                     IGVM_VHS_VARIABLE_HEADER));
             if ((platform->platform_type == IGVM_PLATFORM_TYPE_SEV_ES) &&
-                ctx->cgs) {
+                ctx->machine_state->cgs) {
                 if (ctx->cgsc->check_support(
                         CGS_PLATFORM_SEV_ES, platform->platform_version,
                         platform->highest_vtl, platform->shared_gpa_boundary)) {
                     compatibility_mask_sev_es = platform->compatibility_mask;
                 }
             } else if ((platform->platform_type == IGVM_PLATFORM_TYPE_SEV) &&
-                       ctx->cgs) {
+                       ctx->machine_state->cgs) {
                 if (ctx->cgsc->check_support(
                         CGS_PLATFORM_SEV, platform->platform_version,
                         platform->highest_vtl, platform->shared_gpa_boundary)) {
@@ -794,7 +795,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
                 }
             } else if ((platform->platform_type ==
                         IGVM_PLATFORM_TYPE_SEV_SNP) &&
-                       ctx->cgs) {
+                       ctx->machine_state->cgs) {
                 if (ctx->cgsc->check_support(
                         CGS_PLATFORM_SEV_SNP, platform->platform_version,
                         platform->highest_vtl, platform->shared_gpa_boundary)) {
@@ -867,7 +868,7 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp)
     return igvm;
 }
 
-int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
+int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
                        bool onlyVpContext, Error **errp)
 {
     int32_t header_count;
@@ -883,13 +884,16 @@ int qigvm_process_file(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
     ctx.file = cfg->file;
     trace_igvm_process_file(cfg->file, onlyVpContext);
 
+    ctx.machine_state = machine_state;
+
     /*
      * The ConfidentialGuestSupport object is optional and allows a confidential
      * guest platform to perform extra processing, such as page measurement, on
      * IGVM directives.
      */
-    ctx.cgs = cgs;
-    ctx.cgsc = cgs ? CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs) : NULL;
+    ctx.cgsc = machine_state->cgs ?
+                   CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(machine_state->cgs) :
+                   NULL;
 
     /*
      * Check that the IGVM file provides configuration for the current
target/i386/sev.c +1 -2
index fef9f441c61e..acdcb9c4e681 100644
@@ -1892,8 +1892,7 @@ static int sev_common_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
          */
         if (x86machine->igvm) {
             if (IGVM_CFG_GET_CLASS(x86machine->igvm)
-                    ->process(x86machine->igvm, machine->cgs, true, errp) ==
-                -1) {
+                    ->process(x86machine->igvm, machine, true, errp) == -1) {
                 return -1;
             }
             /*
Signature · 1 line
2.52.0
#16 lore raw

[PULL 16/17] igvm: Only build stubs if igvm is enabled

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Change meson script to only include the IGVM stubs file if the IGVM feature is enabled. It is used to handle architecture specific differences within the IGVM backend, not to provide stubs of the backend itself.

Message-ID: <[email protected]>

---
 stubs/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
stubs/meson.build +3 -1
index 2b5fd8a88af5..8a07059500db 100644
@@ -71,7 +71,9 @@ if have_system
   stub_ss.add(files('dump.c'))
   stub_ss.add(files('cmos.c'))
   stub_ss.add(files('fw_cfg.c'))
-  stub_ss.add(files('igvm.c'))
+  if igvm.found()
+    stub_ss.add(files('igvm.c'))
+  endif
   stub_ss.add(files('target-get-monitor-def.c'))
   stub_ss.add(files('target-monitor-defs.c'))
   stub_ss.add(files('win32-kbd-hook.c'))
Signature · 1 line
2.52.0
#17 lore raw

[PULL 17/17] igvm: Fill MADT IGVM parameter field on x86_64

In reply to Gerd Hoffmann

From: Oliver Steffen <[email protected]>

Use the new acpi_build_madt_standalone() function to fill the MADT parameter field.

The IGVM parameter can be consumed by Coconut SVSM [1], instead of relying on the fw_cfg interface, which has caused problems before due to unexpected access [2,3]. Using IGVM parameters is the default way for Coconut SVSM across hypervisors; switching over would allow removing specialized code paths for QEMU in Coconut.

Coconut SVSM needs to know the SMP configuration, but does not look at any other ACPI data, nor does it interact with the PCI bus settings. Since the MADT is static and not linked with other ACPI tables, it can be supplied stand-alone like this.

Generating the MADT twice (during ACPI table building and IGVM processing) seems acceptable, since there is no infrastructure to obtain the MADT out of the ACPI table memory area.

In any case OVMF, which runs after SVSM has already been initialized, will continue reading all ACPI tables via fw_cfg and provide fixed up ACPI data to the OS as before without any changes.

The IGVM parameter handler is implemented for the i386 machine target and stubbed for all others.

[1] https://github.com/coconut-svsm/svsm/pull/858
[2] https://gitlab.com/qemu-project/qemu/-/issues/2882
[3] https://github.com/coconut-svsm/svsm/issues/646

Message-ID: <[email protected]>

---
 include/system/igvm-internal.h |  5 +++++
 backends/igvm.c                |  2 ++
 stubs/igvm.c                   |  6 ++++++
 target/i386/igvm.c             | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+)
include/system/igvm-internal.h +5 -0
index 1d36519ab082..38004bd908e7 100644
@@ -74,4 +74,9 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp);
 QIgvmParameterData*
 qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
 
+/*
+ *  IGVM parameter handlers
+ */
+int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp);
+
 #endif
backends/igvm.c +2 -0
index 3e7c0ea41d14..b01a19ba46a1 100644
@@ -128,6 +128,8 @@ static struct QIGVMHandler handlers[] = {
       qigvm_directive_snp_id_block },
     { IGVM_VHT_GUEST_POLICY, IGVM_HEADER_SECTION_INITIALIZATION,
       qigvm_initialization_guest_policy },
+    { IGVM_VHT_MADT, IGVM_HEADER_SECTION_DIRECTIVE,
+      qigvm_directive_madt },
 };
 
 static int qigvm_handler(QIgvm *ctx, uint32_t type, Error **errp)
stubs/igvm.c +6 -0
index 17cd1e903e35..47d5130d9d74 100644
@@ -12,6 +12,7 @@
 #include "qemu/osdep.h"
 
 #include "system/igvm.h"
+#include "system/igvm-internal.h"
 
 int qigvm_x86_get_mem_map_entry(int index,
                                 ConfidentialGuestMemoryMapEntry *entry,
@@ -24,3 +25,8 @@ int qigvm_x86_set_vp_context(void *data, int index, Error **errp)
 {
     return -1;
 }
+
+int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
+{
+    return -1;
+}
target/i386/igvm.c +32 -0
index 457c253b030c..f41b498b8924 100644
@@ -13,7 +13,9 @@
 
 #include "cpu.h"
 #include "hw/i386/e820_memory_layout.h"
+#include "hw/i386/acpi-build.h"
 #include "system/igvm.h"
+#include "system/igvm-internal.h"
 
 struct IgvmNativeVpContextX64 {
     uint64_t rax;
@@ -178,3 +180,33 @@ void qigvm_x86_bsp_reset(CPUX86State *env)
 
     qigvm_x86_load_context(bsp_context, env);
 }
+
+/*
+ * Process MADT IGVM parameter
+ */
+int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
+{
+    const IGVM_VHS_PARAMETER *param = (const IGVM_VHS_PARAMETER *)header_data;
+    QIgvmParameterData *param_entry;
+    int result = 0;
+
+    /* Find the parameter area that should hold the MADT data */
+    param_entry = qigvm_find_param_entry(ctx, param->parameter_area_index);
+    if (param_entry == NULL) {
+        return 0;
+    }
+
+    GArray *madt = acpi_build_madt_standalone(ctx->machine_state);
+
+    if (madt->len <= param_entry->size) {
+        memcpy(param_entry->data, madt->data, madt->len);
+    } else {
+        error_setg(
+            errp,
+            "IGVM: MADT size exceeds parameter area defined in IGVM file");
+        result = -1;
+    }
+
+    g_array_free(madt, true);
+    return result;
+}
Signature · 1 line
2.52.0
#18 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

The following changes since commit b377abc220fc53e9cab2aac3c73fc20be6d85eea:

   Merge tag 'hw-misc-20260202' ofhttps://github.com/philmd/qemu into staging (2026-02-03 07:52:04 +1000)

are available in the Git repository at:

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

for you to fetch changes up to dea1f68a5cd338b338e34f2df5ecb2e35a9d8681:

Quoted 7 lines

igvm: Fill MADT IGVM parameter field on x86_64 (2026-02-03 08:32:33 +0100)

----------------------------------------------------------------
firmware updates for 11.0
- igvm: rework reset handling.
- igvm: add MADT parameter support.
- uefi: variable store fixes.

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.0 as appropriate.

r~