Introducing guest driven VM launch update mechanism (BYOF interface)
v2 cover Introducing guest driven VM launch update mechanism (BYOF interface)
This is the resurrection of the work that was previously discussed here:
https://lists.endsoftwarepatents.org/archive/html/qemu-devel/2025-03/msg05872.html
This relates to the 'bring your own firmware' work that we are driving at Red Hat, now with IGVM support.
The patchset includes a spec doc that has more details.
This patchset implements the hypervisor interface using fw-cfg. Using this interface, the guest can pass its own IGVM file to the hypervisor. Upon reset, the hypervisor re-initializes the guest using the IGVM file the guest provided. This is useful in order to have deterministic and trustworthy launch measurements, mostly for the cloud confidential guest deployments.
This patchset has added functional and unit tests that exercize the hypervisor interface. It has been tested for both confidential guests and non-confidential guests. Gerd has also independently tested the patchset.
Changelog:
v2:
- API definitions moved to a separate userland header file.
- A new ctrl flag is added that will restore original host provided IGVM. Tests for the same are added as well.
- doc updates that describe how the interface works with the new ctrl flag set.
- A memory corruption issue is fixed.
- total size of test IGVM files reduced to 270 KB.
- other review comments addressed.
- tags added.
Ani Sinha (6):
hw/misc/vmlaunchupdate: add api header hw/misc/vmlaunchupdate: Introduce hypervisor fw-cfg interface support docs/spec: Add a specification document for vm-launch-update device tests/qtest: Add small igvm files for testing purpose
Add functional and unit tests for the vm-launch-update device Update MAINTAINERS
Gerd Hoffmann (3):
igvm: store IgvmCfg pointer in QIgvm
igvm: track memory regions
igvm: cleanup memory regions
MAINTAINERS | 13 + backends/igvm-cfg.c | 3 + backends/igvm.c | 99 +++-- docs/specs/index.rst | 1 + docs/specs/vmlaunchupdate.rst | 172 ++++++++ hw/misc/meson.build | 3 + hw/misc/trace-events | 6 + hw/misc/vmlaunchupdate.c | 307 +++++++++++++ include/hw/misc/vmlaunchupdate.h | 38 ++ .../standard-headers/misc/vmlaunchupdate.h | 73 ++++ include/system/igvm-internal.h | 8 +- include/system/igvm.h | 1 + tests/data/igvm/README | 24 ++ tests/data/igvm/hello.igvm | Bin 0 -> 137112 bytes tests/data/igvm/qemuinit.igvm | Bin 0 -> 137112 bytes tests/functional/aarch64/meson.build | 1 + .../aarch64/test_vm_launch_update_aarch.py | 33 ++ tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vm_launch_update.py | 48 +++ tests/qtest/launchupdate-test.c | 408 ++++++++++++++++++ tests/qtest/meson.build | 2 + 21 files changed, 1208 insertions(+), 33 deletions(-) create mode 100644 docs/specs/vmlaunchupdate.rst create mode 100644 hw/misc/vmlaunchupdate.c create mode 100644 include/hw/misc/vmlaunchupdate.h create mode 100644 include/standard-headers/misc/vmlaunchupdate.h create mode 100644 tests/data/igvm/README create mode 100644 tests/data/igvm/hello.igvm create mode 100644 tests/data/igvm/qemuinit.igvm create mode 100755 tests/functional/aarch64/test_vm_launch_update_aarch.py create mode 100755 tests/functional/x86_64/test_vm_launch_update.py create mode 100644 tests/qtest/launchupdate-test.c
Signature · 1 line
2.42.0
PATCH v2 1/9 igvm: store IgvmCfg pointer in QIgvm
From: Gerd Hoffmann <[email protected]>
Store a pointer to IgvmCfg instead of only IgvmFile in QIgvm. Allows to store additional state in the (persistent) IgvmCfg struct.
--- backends/igvm.c | 57 ++++++++++++++++++++-------------- include/system/igvm-internal.h | 2 +- 2 files changed, 34 insertions(+), 25 deletions(-)
backends/igvm.c +33 -24
@@ -178,7 +178,8 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type,if (handlers[handler].type != type) {continue ; } - header_handle =igvm_get_header (ctx->file, handlers[handler].section, + header_handle =igvm_get_header (ctx->cfg->file, + handlers[handler].section, ctx->current_header_index);if (header_handle <0 ) { error_setg(
@@ -187,7 +188,7 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type, (int)header_handle);return -1 ; } - header_data =igvm_get_buffer (ctx->file, header_handle); + header_data =igvm_get_buffer (ctx->cfg->file, header_handle);if (header_data !=NULL ) { header_data +=sizeof (IGVM_VHS_VARIABLE_HEADER ); result = handlers[handler].handler (ctx, header_data, errp);
@@ -198,7 +199,7 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type, header_handle, type); result =-1 ; } -igvm_free_buffer (ctx->file, header_handle); +igvm_free_buffer (ctx->cfg->file, header_handle);return result; }
@@ -344,7 +345,8 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,for (page_index =0 ; page_index < page_count; page_index++) { data_handle =igvm_get_header_data ( - ctx->file,IGVM_HEADER_SECTION_DIRECTIVE , page_index + start_index); + ctx->cfg->file,IGVM_HEADER_SECTION_DIRECTIVE , + page_index + start_index);if (data_handle ==IGVMAPI_NO_DATA ) {/* No data indicates a zero page */ memset (®ion[page_index * page_size],0 , page_size);
@@ -357,7 +359,7 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index,return -1 ; }else { zero = false; - data_size =igvm_get_buffer_size (ctx->file, data_handle); + data_size =igvm_get_buffer_size (ctx->cfg->file, data_handle);if (data_size < page_size) {memset (®ion[page_index * page_size],0 , page_size); }else if (data_size > page_size) {
@@ -367,14 +369,14 @@ static int qigvm_process_mem_region(QIgvm *ctx, unsigned start_index, page_index + start_index);return -1 ; } - data =igvm_get_buffer (ctx->file, data_handle); + data =igvm_get_buffer (ctx->cfg->file, data_handle);if (data ==NULL ) {error_setg (errp,"IGVM: No buffer for handle %d" , data_handle); -igvm_free_buffer (ctx->file, data_handle); +igvm_free_buffer (ctx->cfg->file, data_handle);return -1 ; }memcpy (®ion[page_index * page_size], data, data_size); -igvm_free_buffer (ctx->file, data_handle); +igvm_free_buffer (ctx->cfg->file, data_handle); } }
@@ -411,7 +413,8 @@ static int qigvm_process_mem_page(QIgvm *ctx, ctx->region_start = page_data->gpa; ctx->region_start_index = ctx->current_header_index; }else { - if (!qigvm_page_attrs_equal(ctx->file, ctx->current_header_index, + if (!qigvm_page_attrs_equal(ctx->cfg->file, + ctx->current_header_index, page_data, &ctx->region_prev_page_data) || ((ctx->region_prev_page_data.gpa +
@@ -474,7 +477,8 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,return 0 ; } - data_handle =igvm_get_header_data (ctx->file,IGVM_HEADER_SECTION_DIRECTIVE , + data_handle =igvm_get_header_data (ctx->cfg->file, +IGVM_HEADER_SECTION_DIRECTIVE , ctx->current_header_index);if (data_handle <0 ) { error_setg(errp, "Invalid VP context in IGVM file. Error code: %X",
@@ -482,7 +486,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,return -1 ; } - data = (uint8_t *)igvm_get_buffer (ctx->file, data_handle); + data = (uint8_t *)igvm_get_buffer (ctx->cfg->file, data_handle);if (data ==NULL ) {error_setg (errp,"IGVM: No buffer for handle %d" , data_handle); result =-1 ;
@@ -491,7 +495,8 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data,if (ctx->machine_state->cgs) { result = ctx->cgsc->set_guest_state ( - vp_context->gpa, data,igvm_get_buffer_size (ctx->file, data_handle), + vp_context->gpa, data, +igvm_get_buffer_size (ctx->cfg->file, data_handle),CGS_PAGE_TYPE_VMSA , vp_context->vp_index, errp); }else if (target_arch () ==SYS_EMU_TARGET_X86_64 ) { result =qigvm_x86_set_vp_context (data, vp_context->vp_index, errp);
@@ -504,7 +509,7 @@ static int qigvm_directive_vp_context(QIgvm *ctx, const uint8_t *header_data, } exit: -igvm_free_buffer (ctx->file, data_handle); +igvm_free_buffer (ctx->cfg->file, data_handle);if (result <0 ) {return result; }
@@ -863,7 +868,8 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)uint32_t compatibility_mask_sev_snp =0 ;uint32_t compatibility_mask =0 ; - header_count =igvm_header_count (ctx->file,IGVM_HEADER_SECTION_PLATFORM ); + header_count =igvm_header_count (ctx->cfg->file, +IGVM_HEADER_SECTION_PLATFORM );if (header_count <0 ) { error_setg(errp, "Invalid platform header count in IGVM file. Error code: %X",
@@ -874,11 +880,11 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)for (header_index =0 ; header_index < (unsigned )header_count; header_index++) {IgvmVariableHeaderType typ =igvm_get_header_type ( - ctx->file,IGVM_HEADER_SECTION_PLATFORM , header_index); + ctx->cfg->file,IGVM_HEADER_SECTION_PLATFORM , header_index); typ =igvm_vht_type (typ);if (typ ==IGVM_VHT_SUPPORTED_PLATFORM ) { header_handle =igvm_get_header ( - ctx->file,IGVM_HEADER_SECTION_PLATFORM , header_index); + ctx->cfg->file,IGVM_HEADER_SECTION_PLATFORM , header_index);if (header_handle <0 ) {error_setg (errp, "Invalid platform header in IGVM file. "
@@ -887,11 +893,11 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)return -1 ; } platform = - (IGVM_VHS_SUPPORTED_PLATFORM *)(igvm_get_buffer (ctx->file, + (IGVM_VHS_SUPPORTED_PLATFORM *)(igvm_get_buffer (ctx->cfg->file, header_handle));if (platform ==NULL ) {error_setg (errp,"IGVM: No buffer for handle %d" , header_handle); -igvm_free_buffer (ctx->file, header_handle); +igvm_free_buffer (ctx->cfg->file, header_handle);return -1 ; }
@@ -922,7 +928,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp) }else if (platform->platform_type ==IGVM_PLATFORM_TYPE_NATIVE ) { compatibility_mask = platform->compatibility_mask; } -igvm_free_buffer (ctx->file, header_handle); +igvm_free_buffer (ctx->cfg->file, header_handle); } }/* Choose the strongest supported isolation technology */
@@ -999,7 +1005,7 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,error_setg (errp,"No IGVM file loaded." );return -1 ; } - ctx.file = cfg->file; + ctx.cfg = cfg;trace_igvm_process_file (cfg->file, onlyVpContext); ctx.machine_state = machine_state;
@@ -1021,7 +1027,8 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state, goto cleanup; } - header_count =igvm_header_count (ctx.file,IGVM_HEADER_SECTION_DIRECTIVE ); + header_count =igvm_header_count (ctx.cfg->file, +IGVM_HEADER_SECTION_DIRECTIVE );if (header_count <=0 ) { error_setg( errp, "Invalid directive header count in IGVM file. Error code: %X",
@@ -1035,7 +1042,8 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state, ctx.current_header_index < (unsigned )header_count; ctx.current_header_index++) {IgvmVariableHeaderType raw_type =igvm_get_header_type ( - ctx.file,IGVM_HEADER_SECTION_DIRECTIVE , ctx.current_header_index); + ctx.cfg->file,IGVM_HEADER_SECTION_DIRECTIVE , + ctx.current_header_index);if (!onlyVpContext ||igvm_vht_type (raw_type) ==IGVM_VHT_VP_CONTEXT ) {if (qigvm_handler (&ctx, raw_type, errp) <0 ) { goto cleanup_parameters;
@@ -1053,7 +1061,7 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state, } header_count = -igvm_header_count (ctx.file,IGVM_HEADER_SECTION_INITIALIZATION ); +igvm_header_count (ctx.cfg->file,IGVM_HEADER_SECTION_INITIALIZATION );if (header_count <0 ) { error_setg( errp,
@@ -1066,7 +1074,8 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state, ctx.current_header_index < (unsigned )header_count; ctx.current_header_index++) {IgvmVariableHeaderType type = -igvm_get_header_type (ctx.file,IGVM_HEADER_SECTION_INITIALIZATION , +igvm_get_header_type (ctx.cfg->file, +IGVM_HEADER_SECTION_INITIALIZATION , ctx.current_header_index);if (qigvm_handler (&ctx, type, errp) <0 ) { goto cleanup_parameters;
include/system/igvm-internal.h +1 -1
@@ -43,7 +43,7 @@ typedef struct QIgvmParameterData {* file. */ struct QIgvm { -IgvmHandle file; +IgvmCfg *cfg;MachineState *machine_state;ConfidentialGuestSupportClass *cgsc;uint32_t compatibility_mask;
Signature · 1 line
2.42.0
PATCH v2 2/9 igvm: track memory regions
In reply to Ani SinhaFrom: Gerd Hoffmann <[email protected]>
Memory regions added by the current IGVM needs to be tracked so that they can be freed when a new IGVM is loaded.
--- backends/igvm-cfg.c | 1 + backends/igvm.c | 20 ++++++++++++-------- include/system/igvm-internal.h | 6 ++++++ 3 files changed, 19 insertions(+), 8 deletions(-)
backends/igvm-cfg.c +1 -0
@@ -65,6 +65,7 @@ static void igvm_complete(UserCreatable *uc, Error **errp)IgvmCfg *igvm =IGVM_CFG (uc); igvm->file =qigvm_file_init (igvm->filename, errp); +QTAILQ_INIT (&igvm->memory_regions); } OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
backends/igvm.c +12 -8
@@ -220,7 +220,7 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t addr, uint64_t size, int region_identifier, Error **errp) {ERRP_GUARD (); -MemoryRegion *igvm_pages =NULL ; +IgvmMemoryRegion *imr =NULL ;Int128 gpa_region_size;MemoryRegionSection mrs =memory_region_find (get_system_memory (), addr, size);
@@ -254,23 +254,27 @@ 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 ); + imr =g_new0 (IgvmMemoryRegion,1 ); + imr->mr =g_new0 (MemoryRegion,1 );if (ctx->machine_state->cgs && ctx->machine_state->cgs->require_guest_memfd) { -if (!memory_region_init_ram_guest_memfd (igvm_pages,NULL , +if (!memory_region_init_ram_guest_memfd (imr->mr,NULL , region_name, size, errp)) { -g_free (igvm_pages); +g_free (imr->mr); +g_free (imr);return NULL ; } }else { -if (!memory_region_init_ram (igvm_pages,NULL , region_name, size, +if (!memory_region_init_ram (imr->mr,NULL , region_name, size, errp)) { -g_free (igvm_pages); +g_free (imr->mr); +g_free (imr);return NULL ; } } -memory_region_add_subregion (get_system_memory (), addr, igvm_pages); -return memory_region_get_ram_ptr (igvm_pages); +memory_region_add_subregion (get_system_memory (), addr, imr->mr); +QTAILQ_INSERT_TAIL (&ctx->cfg->memory_regions, imr, next); +return memory_region_get_ram_ptr (imr->mr); } }
include/system/igvm-internal.h +6 -0
@@ -18,6 +18,11 @@#include "system/confidential-guest-support.h" #include <igvm/igvm.h> +typedef struct IgvmMemoryRegion { +QTAILQ_ENTRY (IgvmMemoryRegion) next; +MemoryRegion *mr; +}IgvmMemoryRegion ; +struct IgvmCfg {Object parent_obj;
@@ -29,6 +34,7 @@ struct IgvmCfg {char *filename;IgvmHandle file;ResettableState reset_state; + QTAILQ_HEAD(, IgvmMemoryRegion) memory_regions; }; typedef struct QIgvmParameterData {
Signature · 1 line
2.42.0
PATCH v2 3/9 igvm: cleanup memory regions
In reply to Ani SinhaFrom: Gerd Hoffmann <[email protected]>
This change cleans up existing memory regions that were created by the current IGVM. The cleanup would be necessary when a new IGVM is loaded. This cleanup function is called in a subsequent patch.
--- backends/igvm-cfg.c | 2 ++ backends/igvm.c | 22 ++++++++++++++++++++++ include/system/igvm.h | 1 + 3 files changed, 25 insertions(+)
backends/igvm-cfg.c +2 -0
@@ -52,6 +52,8 @@ static void igvm_reset_hold(Object *obj, ResetType type)trace_igvm_reset_hold (type); +/* cleanup existing memory regions first */ +qigvm_cleanup_memory (igvm);qigvm_process_file (igvm, ms, false, &error_fatal); }
backends/igvm.c +22 -0
@@ -14,6 +14,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/target-info-qapi.h" +#include "migration/vmstate.h" #include "system/igvm.h" #include "system/igvm-cfg.h" #include "system/igvm-internal.h"
@@ -1109,3 +1110,24 @@ cleanup_parameters: cleanup:return retval; } + +/* +* cleanup any memory regions created by qigvm_prepare_memory() +*/ +void qigvm_cleanup_memory (IgvmCfg *cfg) +{ +IgvmMemoryRegion *imr, *tmp; + + QTAILQ_FOREACH_SAFE(imr, &cfg->memory_regions, next, tmp) + { +memory_region_del_subregion (get_system_memory (), imr->mr); +vmstate_unregister_ram (imr->mr,NULL ); +QTAILQ_REMOVE (&cfg->memory_regions, imr, next); +/* +* imr->mr will be freed when all references to the memory +* region are dropped. Freeing it here will cause memory +* corruption. +*/ +g_free (imr); + } +}
include/system/igvm.h +1 -0
@@ -20,6 +20,7 @@ typedef struct QIgvm QIgvm;int qigvm_process_file (IgvmCfg *igvm,MachineState *machine_state,bool onlyVpContext,Error **errp); +void qigvm_cleanup_memory (IgvmCfg *igvm);/* x86 native */ int qigvm_x86_get_mem_map_entry(int index,
Signature · 1 line
2.42.0
PATCH v2 4/9 hw/misc/vmlaunchupdate: add api header
In reply to Ani SinhaAdd a separate header file for guest usable api definitions.
--- .../standard-headers/misc/vmlaunchupdate.h | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 include/standard-headers/misc/vmlaunchupdate.h
include/standard-headers/misc/vmlaunchupdate.h new file +73 -0
@@ -0,0 +1,73 @@ +/* +* Guest driven VM launch state update device via IGVM. +* The definitions in this header defines the API for the hypervisor interface. +* For details and specification, please look at docs/specs/vmlaunchupdate.rst. +* +* Copyright (C) 2026 Red Hat, Inc. +* +* Authors: Ani Sinha <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +*/ +#ifndef VMLAUNCHUPDATE_API_H +#define VMLAUNCHUPDATE_API_H + +/* fw-cfg file definition */ +#define FILE_VMLAUNCHUPDATE "etc/vmlaunchupdate" + +/* version */ +#define VM_LAUNCHUPDATE_VERSION 0x01 + +/* format bits, used by both 'capabilities' and 'control' */ + +/* igvm */ +#define VM_LAUNCHUPDATE_FORMAT_IGVM (1ULL << 32) + +/* 'control' field bits */ + +/* disable vmlaunchupdate interface */ +#define VM_LAUNCHUPDATE_CTL_DISABLE (1 << 0) +/* revert to the original host provided igvm */ +#define VM_LAUNCHUPDATE_CTL_HOST_IGVM (1 << 1) + +/* status code */ +enum VMLaunchUpdateStatus { +VM_LAUNCHUPDATE_SUCCESS , +VM_LAUNCHUPDATE_LOAD_FAIL , +VM_LAUNCHUPDATE_NOT_IGVM_INIT , +}; + +typedef struct { +/* api version */ +uint16_t version; + +/* +* The guest can read this in order to determine if loading new IGVM +* succeeded. +*/ +uint16_t status; + +/* VMM capabilities, read-only. */ +uint64_t capabilities; +/* control bits, see VMFWUPDATE_CTL_* */ +uint64_t control; + +/* +* address and size of the IGVM image. Will be cleared when +* the write completes successfully and IGVM file is correctly parsed. +*/ +uint64_t fw_image_addr; +uint64_t fw_image_size; + +/* +* address + size of opaque blob. The guest can use this to pass on +* information, for example which memory region the linux kernel has been +* loaded to. writable, will be kept intact on firmware update. +*/ +uint64_t opaque_addr; +uint64_t opaque_size; + +}VMLaunchUpdate ; + +#endif
Signature · 1 line
2.42.0
Re: [PATCH v2 4/9] hw/misc/vmlaunchupdate: add api header
Hi,
include/standard-headers/misc/vmlaunchupdate.h line 32
Quoted 4 lines
include/standard-headers/misc/vmlaunchupdate.h new file +4
-0+/* disable vmlaunchupdate interface */ +#define VM_LAUNCHUPDATE_CTL_DISABLE (1 << 0) +/* revert to the original host provided igvm */ +#define VM_LAUNCHUPDATE_CTL_HOST_IGVM (1 << 1)
Hmm, I think these bits need a more verbose comment, especially the combination of the two ...
HOST_IGVM=0 DISABLE=0
Supplied IGVM file replaces the firmware permanently. Updating the firmware again is possible.
HOST_IGVM=0 DISABLE=1
Supplied IGVM file replaces the firmware permanently. Updating the firmware again is not possible.
HOST_IGVM=1 DISABLE=0
Supplied IGVM file replaces the firmware for one reset. Resetting again will switch back to the original firmware. Updating the firmware again is possible.
HOST_IGVM=1 DISABLE=1
Supplied IGVM file replaces the firmware for one reset. Resetting again will switch back to the original firmware. Updating the firmware again is NOT possible.
Question: How long will the 'disable' flag be active? Specifically will switching back to the original firmware also clear the 'disable' flag? Which I think makes sense.
Another question: What happens when using HOST_IGVM=0 first and later on HOST_IGVM=1?
include/standard-headers/misc/vmlaunchupdate.h line 49
Quoted 9 lines
include/standard-headers/misc/vmlaunchupdate.h new file +9
-0+typedef struct { + /* api version */ + uint16_t version; + + /* + * The guest can read this in order to determine if loading new IGVM + * succeeded. + */ + uint16_t status;
uint32_t _padding;
include/standard-headers/misc/vmlaunchupdate.h line 54
Quoted 5 lines
include/standard-headers/misc/vmlaunchupdate.h new file +5
-0+ +/* VMM capabilities, read-only. */ +uint64_t capabilities; +/* control bits, see VMFWUPDATE_CTL_* */ +uint64_t control;
take care,
Gerd
PS: you should cc alex for v3
PATCH v2 5/9 hw/misc/vmlaunchupdate: Introduce hypervisor fw-cfg interface support
In reply to Ani SinhaVM launch update is a mechanism where the virtual machines can use IGVM file bundle to boot into a trusted execution environment without having to depend on a untrusted party to provide the IGVM bundle or firmware image. This is particularly useful for confidential virtual machines that are deployed in the cloud where the tenant and the cloud provider are two different entities. In this scenario, virtual machines can bring their own trusted IGVM file containing a trusted firmware image
bundled as a part of their filesystem and then use this hypervisor interface to update to a trusted and deterministic boot state.
This also allows the guests to have a consistent measurements on the firmware image.
Currently, this mechanism only works if the VM was started with IGVM in the first place.
This change introduces support for the fw-cfg based hypervisor interface and the corresponding device. The interface is made generic enough so that guests are free to use their own ABI to pass required information between initial and trusted execution contexts (where they are running their own trusted boot state) without the hypervisor getting involved in between.
Currently, this device is only supported for x86 machines. Presence of IGVM host libraries is also required for parsing IGVM files. Hence, the device cannot be initialized for other machine types or hosts where IGVM support is not present. Trying to initialize it for arm for example will lead to failure:
$ ./qemu-system-arm -device vm-launch-update -machine virt qemu-system-arm: -device vmfwupdate: This machine does not support vm-launch-update device
Functional and qtests will be added in a subsequent patch.
--- hw/misc/meson.build | 3 + hw/misc/trace-events | 6 + hw/misc/vmlaunchupdate.c | 307 +++++++++++++++++++++++++++++++ include/hw/misc/vmlaunchupdate.h | 38 ++++ 4 files changed, 354 insertions(+) create mode 100644 hw/misc/vmlaunchupdate.c create mode 100644 include/hw/misc/vmlaunchupdate.h
hw/misc/meson.build +3 -0
@@ -163,6 +163,9 @@ specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c')) specific_ss.add(when: 'CONFIG_RISCV_MIPS_CMGCR', if_true: files('riscv_cmgcr.c')) specific_ss.add(when: 'CONFIG_RISCV_MIPS_CPC', if_true: files('riscv_cpc.c')) +if igvm.found() + specific_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmlaunchupdate.c')) +endif system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))
hw/misc/trace-events +6 -0
@@ -442,3 +442,9 @@ iommu_testdev_dma_read(uint64_t gva, uint32_t len) "gva=0x%" PRIx64 " len=%u" iommu_testdev_dma_verify(uint32_t expected, uint32_t actual) "expected=0x%x actual=0x%x" iommu_testdev_dma_result(uint32_t result) "DMA completed result=0x%x" iommu_testdev_dma_armed(bool armed) "armed=%d" + +# vmlaunchupdate.c +launch_update_write(void) "" +vmlaunch_reset_enter(void) "" +vm_launchupdate_finalize(void) "" +restore_host_x86_igvm(void) ""
hw/misc/vmlaunchupdate.c new file +307 -0
307 lines not on this page · raw message
include/hw/misc/vmlaunchupdate.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Guest driven VM launch state update device via IGVM. +* For details and specification, please look at docs/specs/vmlaunchupdate.rst. +* +* Copyright (C) 2026 Red Hat, Inc. +* +* Authors: Ani Sinha <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +*/ +#ifndef VMLAUNCHUPDATE_H +#define VMLAUNCHUPDATE_H + +#include "hw/core/qdev.h" +#include "qom/object.h" +#include "qemu/units.h" +#include "system/igvm-cfg.h" +#include "standard-headers/misc/vmlaunchupdate.h" + +#define TYPE_VMLAUNCHUPDATE "vm-launch-update" + +typedef struct VMLaunchUpdateState { +DeviceState parent_obj; +VMLaunchUpdate launch_update; +bool disabled; +bool host_igvm_on_reset; +ResettableState reset_state; +}VMLaunchUpdateState ; + + +typedef struct VMLaunchUpdateStateClass { +ObjectClass parent_class; +}VMLaunchUpdateStateClass ; + +OBJECT_DECLARE_SIMPLE_TYPE (VMLaunchUpdateState,VMLAUNCHUPDATE ); + +#endif
Signature · 1 line
2.42.0
Re: [PATCH v2 5/9] hw/misc/vmlaunchupdate: Introduce hypervisor fw-cfg interface support
Quoted 27 lines · Ani Sinha
VM launch update is a mechanism where the virtual machines can use IGVM file bundle to boot into a trusted execution environment without having to depend on a untrusted party to provide the IGVM bundle or firmware image. This is particularly useful for confidential virtual machines that are deployed in the cloud where the tenant and the cloud provider are two different entities. In this scenario, virtual machines can bring their own trusted IGVM file containing a trusted firmware image
bundled as a part of their filesystem and then use this hypervisor interface to update to a trusted and deterministic boot state.
This also allows the guests to have a consistent measurements on the firmware image.Currently, this mechanism only works if the VM was started with IGVM in the first place.
This change introduces support for the fw-cfg based hypervisor interface and the corresponding device. The interface is made generic enough so that guests are free to use their own ABI to pass required information between initial and trusted execution contexts (where they are running their own trusted boot state) without the hypervisor getting involved in between.
Currently, this device is only supported for x86 machines. Presence of IGVM host libraries is also required for parsing IGVM files. Hence, the device cannot be initialized for other machine types or hosts where IGVM support is not present. Trying to initialize it for arm for example will lead to failure:
Quoted 7 lines
$ ./qemu-system-arm -device vm-launch-update -machine virt qemu-system-arm: -device vmfwupdate: This machine does not support vm-launch-update deviceFunctional and qtests will be added in a subsequent patch.
CC Alex Graf <[email protected]>CC Gerd Hoffman <[email protected]>
PATCH v2 6/9 docs/spec: Add a specification document for vm-launch-update device
In reply to Ani SinhaThis change adds a specification document and expanation for the vm-launch-update device.
--- docs/specs/index.rst | 1 + docs/specs/vmlaunchupdate.rst | 172 ++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 docs/specs/vmlaunchupdate.rst
docs/specs/index.rst +1 -0
@@ -34,6 +34,7 @@ guest hardware that is specific to QEMU. virt-ctlr vmcoreinfo vmgenid + vmlaunchupdate rapl-msr rocker riscv-iommu
docs/specs/vmlaunchupdate.rst new file +172 -0
172 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH v2 7/9 tests/qtest: Add small igvm files for testing purpose
In reply to Ani SinhaNeeded by launchupdate-test.c. README file is added with explanation on how to build these IGVM files.
--- tests/data/igvm/README | 24 ++++++++++++++++++++++++ tests/data/igvm/hello.igvm | Bin 0 -> 153624 bytes tests/data/igvm/qemuinit.igvm | Bin 0 -> 137112 bytes 3 files changed, 24 insertions(+) create mode 100644 tests/data/igvm/README create mode 100644 tests/data/igvm/hello.igvm create mode 100644 tests/data/igvm/qemuinit.igvm
tests/data/igvm/README new file +24 -0
@@ -0,0 +1,24 @@ +Small IGVM file bundles required for tesing vm-launch-update device +=================================================================== + +This directory contains IGVM files required for launchupdate-test.c. +These IGVM bundles can be built from the following repository: +https://gitlab.com/anisinha/virt-firmware-rs + +Just type "make" in the top of the repository. The built IGVM files +can be found in the target/x86_64-unknown-none/debug directory. + +$ ls -l ./target/x86_64-unknown-none/debug/*.igvm +-rw-r--r--. 1 anisinha anisinha 153624 Jun 8 10:05 ./target/x86_64-unknown-none/debug/hello.igvm +-rw-r--r--. 1 anisinha anisinha 157848 Jun 8 10:05 ./target/x86_64-unknown-none/debug/igvmtest.igvm +-rw-r--r--. 1 anisinha anisinha 987384 Jun 8 10:05 ./target/x86_64-unknown-none/debug/mefisto.igvm +-rw-r--r--. 1 anisinha anisinha 368312 Jun 8 10:05 ./target/x86_64-unknown-none/debug/qemuinit.igvm +-rw-r--r--. 1 anisinha anisinha 223944 Jun 8 10:05 ./target/x86_64-unknown-none/debug/snptest.igvm + + +Following files are used by the tests/qtest/launchupdate-test.c: + +hello.igvm +qemuinit.igvm + +
tests/data/igvm/hello.igvm new file binary +0 -0
tests/data/igvm/qemuinit.igvm new file binary +0 -0
Signature · 1 line
2.42.0
Re: [PATCH v2 7/9] tests/qtest: Add small igvm files for testing purpose
tests/data/igvm/README line 9
Quoted 12 lines · Ani Sinha
Needed by
launchupdate-test.c. README file is added with explanation on how to build these IGVM files.tests/data/igvm/README new file +8
-0+Small IGVM file bundles required for tesing vm-launch-update device +=================================================================== + +This directory contains IGVM files required for launchupdate-test.c. +These IGVM bundles can be built from the following repository: +https://gitlab.com/anisinha/virt-firmware-rs +Just type "make" in the top of the repository. The built IGVM files +can be found in the target/x86_64-unknown-none/debug directory.
There is also a smaller hello version written in C instead of rust in the bios-32 directory. I've updated that recently in my repo to provide three versions so it is possible to pick the behavior you want (reset, poweroff, hlt loop).
Binaries are available from https://kraxel.gitlab.io/virt-firmware-rs/
HTH & take care,
Gerd
PATCH v2 8/9 Add functional and unit tests for the vm-launch-update device
In reply to Ani SinhaThis patchset adds functional and unit tests that exercize various functions and behaviors of vm-launch-update device. It uses the IGVM files that were introduced in the previous patch for exercizing the hypervisor interface.
--- tests/data/igvm/hello.igvm | Bin 153624 -> 137112 bytes tests/functional/aarch64/meson.build | 1 + .../aarch64/test_vm_launch_update_aarch.py | 33 ++ tests/functional/x86_64/meson.build | 1 + .../x86_64/test_vm_launch_update.py | 48 +++ tests/qtest/launchupdate-test.c | 408 ++++++++++++++++++ tests/qtest/meson.build | 2 + 7 files changed, 493 insertions(+) create mode 100755 tests/functional/aarch64/test_vm_launch_update_aarch.py create mode 100755 tests/functional/x86_64/test_vm_launch_update.py create mode 100644 tests/qtest/launchupdate-test.c
tests/data/igvm/hello.igvm binary +0 -0
tests/functional/aarch64/meson.build +1 -0
@@ -23,6 +23,7 @@ test_aarch64_timeouts = { tests_aarch64_system_quick = [ 'migration', 'vmstate', + 'vm_launch_update_aarch', ] tests_aarch64_system_thorough = [
tests/functional/aarch64/test_vm_launch_update_aarch.py new file +33 -0
@@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# +# Check for vm-launch-update device. +# +# Copyright (c) 2026 Red Hat, Inc. +# +# Author: +# Ani Sinha <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from qemu_test import QemuSystemTest + +class VmLaunchUpdateDeviceCheck(QemuSystemTest): + + def aarch64_fail_test(self): + """ + Currently the device is only supported for pc platforms. + """ + self.vm.add_args('-machine', 'virt', '-device', + 'vm-launch-update,id=fwupd1') + self.vm.set_qmp_monitor(enabled=False) + self.vm.launch() + self.vm.wait() + self.assertEqual(self.vm.exitcode(), 1, "QEMU exit code should be 1") + self.assertRegex(self.vm.get_log(), + r'This machine does not support vm-launch-update device') + + def test_vm_launch_update(self): + self.aarch64_fail_test() + +if __name__ == '__main__': + QemuSystemTest.main()
tests/functional/x86_64/meson.build +1 -0
@@ -18,6 +18,7 @@ tests_x86_64_system_quick = [ 'pc_cpu_hotplug_props', 'virtio_version', 'vmstate', + 'vm_launch_update', ] # The address-sanitizer makes mlock() a no-op because it
tests/functional/x86_64/test_vm_launch_update.py new file +48 -0
48 lines not on this page · raw message
tests/qtest/launchupdate-test.c new file +408 -0
408 lines not on this page · raw message
tests/qtest/meson.build +2 -0
@@ -61,6 +61,8 @@ qtests_i386 = \ (config_all_devices.has_key('CONFIG_Q35') ? ['e820-test'] : []) + \ (config_all_devices.has_key('CONFIG_FW_CFG_DMA') ? ['vmcoreinfo-test'] : []) + \ (config_all_devices.has_key('CONFIG_Q35') ? ['dump-test'] : []) + \ + (igvm.found() and + config_all_devices.has_key('CONFIG_FW_CFG_DMA') ? ['launchupdate-test'] : []) + \ (config_all_devices.has_key('CONFIG_I440FX') ? ['i440fx-test'] : []) + \ (config_all_devices.has_key('CONFIG_I440FX') ? ['ide-test'] : []) + \ (config_all_devices.has_key('CONFIG_I440FX') ? ['numa-test'] : []) + \
Signature · 1 line
2.42.0
Re: [PATCH v2 8/9] Add functional and unit tests for the vm-launch-update device
Quoted 10 lines · Ani Sinha
This patchset adds functional and unit tests that exercize various functions and behaviors of vm-launch-update device. It uses the IGVM files that were introduced in the previous patch for exercizing the hypervisor interface.
CC Alex Graf <[email protected]>CC Gerd Hoffman <[email protected]>Signed-off-by Ani Sinha <[email protected]>--- tests/data/igvm/hello.igvm | Bin 153624 -> 137112 bytes
Intentional? Should have been in the previous patch I guess?
take care,
Gerd
PATCH v2 9/9 Update MAINTAINERS
In reply to Ani SinhaAdd maintainers for vm-launch-update device and associated documentation and test code.
--- MAINTAINERS | 13 +++++++++++++ 1 file changed, 13 insertions(+)
MAINTAINERS +13 -0
@@ -2826,6 +2826,19 @@ F: include/hw/acpi/vmgenid.h F: docs/specs/vmgenid.rst F: tests/qtest/vmgenid-test.c +VM Launch Update +M: Ani Sinha <[email protected]> +M: Gerd Hoffman <[email protected]> +S: Maintained +F: hw/misc/vmlaunchupdate.c +F: include/hw/misc/vmlaunchupdate.h +F: include/standard-headers/misc/vmlaunchupdate.h +F: docs/specs/vmlaunchupdate.rst +F: tests/functional/aarch64/test_vm_launch_update_aarch.py +F: tests/functional/x86_64/test_vm_launch_update.py +F: tests/qtest/launchupdate-test.c +F: tests/data/igvm/* + LED M: Philippe Mathieu-Daudé <[email protected]> S: Maintained
Signature · 1 line
2.42.0