Uefi 20250321 patches
The following changes since commit 1dae461a913f9da88df05de6e2020d3134356f2e:
Update version for v10.0.0-rc0 release (2025-03-18 10:18:14 -0400)
are available in the Git repository at:
https://gitlab.com/kraxel/qemu.git tags/uefi-20250321-pull-request
for you to fetch changes up to 5e5d18d2ccd674778715f828df80fdddac73bdea:
docs/firmware: add feature flag for host uefi variable store (2025-03-21 12:01:12 +0100)
----------------------------------------------------------------
hw/uefi-vars: bug fixes
hw/uefi-vars: support riscv and loongarch
docs: update firmware.json spec
----------------------------------------------------------------
Gerd Hoffmann (6):
hw/uefi: flush variable store to disk in post load hw/uefi: fix error handling in uefi_vars_json_save hw/uefi: fix error handling in uefi_vars_json_load hw/uefi-vars-sysbus: allow for riscv virt hw/uefi-vars-sysbus: allow for loongarch virt docs/firmware: add feature flag for host uefi variable store
hw/loongarch/virt.c | 2 ++ hw/riscv/virt.c | 2 ++ hw/uefi/var-service-core.c | 1 + hw/uefi/var-service-json.c | 24 +++++++++++++++++++----- docs/interop/firmware.json | 12 +++++++++++- hw/uefi/Kconfig | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-)
Signature · 1 line
2.49.0
[PULL 4/6] hw/uefi-vars-sysbus: allow for riscv virt
Allow the device being added to riscv virt VMs.
Message-ID: <[email protected]>
--- hw/riscv/virt.c | 2 ++ hw/uefi/Kconfig | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
hw/riscv/virt.c +2 -0
@@ -57,6 +57,7 @@#include "hw/acpi/aml-build.h" #include "qapi/qapi-visit-common.h" #include "hw/virtio/virtio-iommu.h" +#include "hw/uefi/var-service-api.h" /* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */ static bool virt_use_kvm_aia_aplic_imsic (RISCVVirtAIAType aia_type)
@@ -1935,6 +1936,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) hc->plug = virt_machine_device_plug_cb;machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_UEFI_VARS_SYSBUS );#ifdef CONFIG_TPM machine_class_allow_dynamic_sysbus_dev (mc,TYPE_TPM_TIS_SYSBUS );#endif
hw/uefi/Kconfig +1 -1
@@ -1,3 +1,3 @@ config UEFI_VARS bool - default y if X86_64 || AARCH64 + default y if X86_64 || AARCH64 || RISCV64
Signature · 1 line
2.49.0
[PULL 6/6] docs/firmware: add feature flag for host uefi variable store
In reply to Gerd HoffmannMessage-ID: <[email protected]>
--- docs/interop/firmware.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
docs/interop/firmware.json +11 -1
@@ -214,13 +214,23 @@ # PL011 UART. @verbose-static is mutually exclusive # with @verbose-dynamic. # +# @host-uefi-vars: The firmware expects the host to provide an uefi +# variable store. qemu supports that via +# "uefi-vars-sysbus" (aarch64, riscv64, loongarch64) +# or "uefi-vars-x64" (x86_64) devices. The firmware +# will not use flash for nvram. When loading the +# firmware into flash the 'stateless' setup should be +# used. It is recommened to load the firmware into +# memory though. +# # Since: 3.0 ## { 'enum' : 'FirmwareFeature', 'data' : [ 'acpi-s3', 'acpi-s4', 'amd-sev', 'amd-sev-es', 'amd-sev-snp', 'intel-tdx', - 'enrolled-keys', 'requires-smm', 'secure-boot', + 'enrolled-keys', 'requires-smm', + 'secure-boot', 'host-uefi-vars', 'verbose-dynamic', 'verbose-static' ] } ##
Signature · 1 line
2.49.0
[PULL 3/6] hw/uefi: fix error handling in uefi_vars_json_load
In reply to Gerd HoffmannCatch lseek errors. Return on read errors.
Message-ID: <[email protected]>
--- hw/uefi/var-service-json.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/uefi/var-service-json.c +8 -1
@@ -214,7 +214,7 @@ void uefi_vars_json_load(uefi_vars_state *uv, Error **errp)QObject *qobj;Visitor *v;char *str; -size_t len; +ssize_t len;int rc;if (uv->jsonfd ==-1 ) {
@@ -222,7 +222,12 @@ void uefi_vars_json_load(uefi_vars_state *uv, Error **errp) } len =lseek (uv->jsonfd,0 ,SEEK_END ); +if (len <0 ) { +warn_report ("%s: lseek error" , __func__); +return ; + }if (len ==0 ) { +/* empty file */ return ; }
@@ -231,6 +236,8 @@ void uefi_vars_json_load(uefi_vars_state *uv, Error **errp) rc =read (uv->jsonfd, str, len);if (rc != len) {warn_report ("%s: read error" , __func__); +g_free (str); +return ; } str[len] =0 ;
Signature · 1 line
2.49.0
[PULL 5/6] hw/uefi-vars-sysbus: allow for loongarch virt
In reply to Gerd HoffmannAllow the device being added to loongarch virt VMs.
Message-ID: <[email protected]>
--- hw/loongarch/virt.c | 2 ++ hw/uefi/Kconfig | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
hw/loongarch/virt.c +2 -0
@@ -38,6 +38,7 @@#include "hw/mem/nvdimm.h" #include "hw/platform-bus.h" #include "hw/display/ramfb.h" +#include "hw/uefi/var-service-api.h" #include "hw/mem/pc-dimm.h" #include "system/tpm.h" #include "system/block-backend.h"
@@ -1207,6 +1208,7 @@ static void virt_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"v-eiointc" ,"Enable Virt Extend I/O Interrupt Controller." );machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_UEFI_VARS_SYSBUS );#ifdef CONFIG_TPM machine_class_allow_dynamic_sysbus_dev (mc,TYPE_TPM_TIS_SYSBUS );#endif
hw/uefi/Kconfig +1 -1
@@ -1,3 +1,3 @@ config UEFI_VARS bool - default y if X86_64 || AARCH64 || RISCV64 + default y if X86_64 || AARCH64 || RISCV64 || LOONGARCH64
Signature · 1 line
2.49.0
[PULL 1/6] hw/uefi: flush variable store to disk in post load
In reply to Gerd HoffmannMake live migration more robust. Commit 4c0cfc72b31a ("pflash_cfi01:
write flash contents to bdrv on incoming migration") elaborates in detail on the motivation.
Message-ID: <[email protected]>
--- hw/uefi/var-service-core.c | 1 + 1 file changed, 1 insertion(+)
hw/uefi/var-service-core.c +1 -0
@@ -29,6 +29,7 @@ static int uefi_vars_post_load(void *opaque, int version_id)uefi_vars_state *uv = opaque;uefi_vars_update_storage (uv); +uefi_vars_json_save (uv); uv->buffer =g_malloc (uv->buf_size);return 0 ; }
Signature · 1 line
2.49.0
[PULL 2/6] hw/uefi: fix error handling in uefi_vars_json_save
In reply to Gerd HoffmannCatch lseek errors. Return on errors.
Use autoptr for the GString to simplify cleanup.
Message-ID: <[email protected]>
--- hw/uefi/var-service-json.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
hw/uefi/var-service-json.c +11 -4
@@ -178,7 +178,7 @@ void uefi_vars_json_init(uefi_vars_state *uv, Error **errp)void uefi_vars_json_save (uefi_vars_state *uv) { -GString *gstr; +g_autoptr (GString) gstr =NULL ;int rc;if (uv->jsonfd ==-1 ) {
@@ -187,18 +187,25 @@ void uefi_vars_json_save(uefi_vars_state *uv) gstr =uefi_vars_to_json (uv); -lseek (uv->jsonfd,0 ,SEEK_SET ); + rc =lseek (uv->jsonfd,0 ,SEEK_SET ); +if (rc <0 ) { +warn_report ("%s: lseek error" , __func__); +return ; + } + rc =ftruncate (uv->jsonfd,0 );if (rc !=0 ) {warn_report ("%s: ftruncate error" , __func__); +return ; } + rc =write (uv->jsonfd, gstr->str, gstr->len);if (rc != gstr->len) {warn_report ("%s: write error" , __func__); +return ; } +fsync (uv->jsonfd); - -g_string_free (gstr, true); }void uefi_vars_json_load (uefi_vars_state *uv,Error **errp)
Signature · 1 line
2.49.0
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.0 for any user-visible changes.