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. The patchset is also available in this branch https://gitlab.com/anisinha/qemu/-/commits/hyperface-phoenix-v5 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. Here is the functional test runs for aarch64 and x86_64 $ export QEMU_TEST_QEMU_BINARY=qemu-system-aarch64 $ ./build/run tests/functional/aarch64/test_vm_launch_update_aarch.py TAP version 13 ok 1 test_vm_launch_update_aarch.VmLaunchUpdateDeviceCheck.test_vm_launch_update 1..1 $ export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64 $ ./build/run tests/functional/x86_64/test_vm_launch_update.py TAP version 13 ok 1 test_vm_launch_update.VmLaunchUpdateDeviceCheck.test_vm_launch_update 1..1 For CoCo case, here is the run for the qtest unit test: $ COCO=1 LAUNCHUPDATE_TRACE=1 LAUNCHUPDATE_DEBUG=1 QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/launchupdate-test TAP version 14 # random seed: R02Sabb1bb55ca41d480b2f8963cc61697ee 1..4 # Start of vm-launch-update tests # starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-2747907.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-2747907.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -device vm-launch-update -accel qtest ok 1 /vm-launch-update/cap # starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-2747907.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-2747907.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -device vm-launch-update -accel qtest ok 2 /vm-launch-update/disabled # starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-2747907.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-2747907.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -device vm-launch-update -accel qtest qemu-system-x86_64: info: guest was not initially started with IGVM, not changing launch state. ok 3 /vm-launch-update/errorcheck serial console file is /tmp/launchupdate-qtest-serial-sJROYT3 # starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-2747907.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-2747907.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -machine q35,igvm-cfg=igvm0,confidential-guest-support=lsec0 -m 1G -accel kvm -device vm-launch-update --trace memory_region_finalize --trace qigvm_cleanup_memory -D /tmp/qemu-debug.log -chardev file,id=serial0,path=/tmp/launchupdate-qtest-serial-sJROYT3 -serial chardev:serial0 -object igvm-cfg,id=igvm0,file=tests/data/igvm/snptest-nohello.igvm -object '{"qom-type":"sev-snp-guest","id":"lsec0","cbitpos":51,"reduced-phys-bits":1,"policy":196608}' -accel qtest target endianness: little guest paddr: 100000 igvm size: 199176 writing igvm file into the guest memory tell hypervisor where igvm is loaded in guest memory qemu-system-x86_64: info: vmlaunchupdate: new IGVM context set. resetting the virtual machine now qemu-system-x86_64: info: virtual machine state has been rebuilt with new guest file handle. qemu-system-x86_64: info: virtual machine state has been rebuilt with new guest file handle. hello world found on console resetting again in order to restore host provided IGVM qemu-system-x86_64: info: virtual machine state has been rebuilt with new guest file handle. qemu-system-x86_64: info: restoring original host IGVM: tests/data/igvm/snptest-nohello.igvm qemu-system-x86_64: info: vmlaunchupdate: host IGVM context set. qemu-system-x86_64: info: virtual machine state has been rebuilt with new guest file handle. ok 4 /vm-launch-update/load_igvm # slow test /vm-launch-update/load_igvm executed in 7.97 secs # End of vm-launch-update tests Changelog: v5: - add functional tests only if igvm libraries are present as without it, the support for the device is absent in QEMU. - add some more checks for the unit test for the required dependencies (device, kvm, q35 etc). - minor spec doc update. - rebased, - tags added. - QEMU CI passed https://gitlab.com/anisinha/qemu/-/pipelines/2756839922 v4: - Alex's suggestions addressed. - Fixed memory region memory leak issue pointed by Alex. - Updated test/data/igvm/README to mention how to download IGVM bundles for CoCo case. - Updated qtest to add some tracepoints. - Added a couple of new patches that add new tracepoints for tracing mr decalocation. - Tested on CoCo and non-CoCo. - Rebased and tags added. v3: - Gerd's suggestions incorporated. - Rebased. - tags added. 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. CC: Alex Graf <[email protected]> CC: Gerd Hoffman <[email protected]> CC: [email protected] Ani Sinha (8): system/memory: add a tracepoint for memory_region_finalize backends/igvm: add a tracepoint for qigvm_cleanup_memory 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 | 97 ++-- backends/trace-events | 1 + docs/specs/index.rst | 1 + docs/specs/vmlaunchupdate.rst | 199 ++++++++ hw/misc/meson.build | 3 + hw/misc/trace-events | 6 + hw/misc/vmlaunchupdate.c | 333 +++++++++++++ include/hw/misc/vmlaunchupdate.h | 38 ++ .../standard-headers/misc/vmlaunchupdate.h | 102 ++++ include/system/igvm-internal.h | 8 +- include/system/igvm.h | 1 + system/memory.c | 1 + system/trace-events | 1 + tests/data/igvm/README | 45 ++ tests/data/igvm/hello.igvm | Bin 0 -> 137112 bytes tests/data/igvm/qemuinit.igvm | Bin 0 -> 137112 bytes tests/functional/aarch64/meson.build | 4 + .../aarch64/test_vm_launch_update_aarch.py | 33 ++ tests/functional/x86_64/meson.build | 4 + .../x86_64/test_vm_launch_update.py | 48 ++ tests/qtest/launchupdate-test.c | 450 ++++++++++++++++++ tests/qtest/meson.build | 2 + 24 files changed, 1360 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 -- 2.42.0
