* [PULL 0/6] Uefi 20250321 patches
@ 2025-03-21 12:35 Gerd Hoffmann
2025-03-21 12:35 ` [PULL 1/6] hw/uefi: flush variable store to disk in post load Gerd Hoffmann
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:35 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
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(-)
--
2.49.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PULL 1/6] hw/uefi: flush variable store to disk in post load
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
@ 2025-03-21 12:35 ` Gerd Hoffmann
2025-03-21 12:36 ` [PULL 2/6] hw/uefi: fix error handling in uefi_vars_json_save Gerd Hoffmann
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:35 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé, Peter Krempa
Make live migration more robust. Commit 4c0cfc72b31a ("pflash_cfi01:
write flash contents to bdrv on incoming migration") elaborates in
detail on the motivation.
Cc: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250319141159.1461621-2-kraxel@redhat.com>
---
hw/uefi/var-service-core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/uefi/var-service-core.c b/hw/uefi/var-service-core.c
index 8ed8378ab991..4836a0cb8116 100644
--- a/hw/uefi/var-service-core.c
+++ b/hw/uefi/var-service-core.c
@@ -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;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PULL 2/6] hw/uefi: fix error handling in uefi_vars_json_save
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
2025-03-21 12:35 ` [PULL 1/6] hw/uefi: flush variable store to disk in post load Gerd Hoffmann
@ 2025-03-21 12:36 ` Gerd Hoffmann
2025-03-21 12:36 ` [PULL 3/6] hw/uefi: fix error handling in uefi_vars_json_load Gerd Hoffmann
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
Catch lseek errors. Return on errors.
Use autoptr for the GString to simplify cleanup.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250319141159.1461621-3-kraxel@redhat.com>
---
hw/uefi/var-service-json.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/hw/uefi/var-service-json.c b/hw/uefi/var-service-json.c
index 761082c11fc1..f1c20a6b8c1e 100644
--- a/hw/uefi/var-service-json.c
+++ b/hw/uefi/var-service-json.c
@@ -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)
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PULL 3/6] hw/uefi: fix error handling in uefi_vars_json_load
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
2025-03-21 12:35 ` [PULL 1/6] hw/uefi: flush variable store to disk in post load Gerd Hoffmann
2025-03-21 12:36 ` [PULL 2/6] hw/uefi: fix error handling in uefi_vars_json_save Gerd Hoffmann
@ 2025-03-21 12:36 ` Gerd Hoffmann
2025-03-21 12:36 ` [PULL 4/6] hw/uefi-vars-sysbus: allow for riscv virt Gerd Hoffmann
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
Catch lseek errors. Return on read errors.
Fixes: CID 1593154
Fixes: CID 1593157
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250319141159.1461621-4-kraxel@redhat.com>
---
hw/uefi/var-service-json.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/hw/uefi/var-service-json.c b/hw/uefi/var-service-json.c
index f1c20a6b8c1e..ad3462cd1557 100644
--- a/hw/uefi/var-service-json.c
+++ b/hw/uefi/var-service-json.c
@@ -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;
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PULL 4/6] hw/uefi-vars-sysbus: allow for riscv virt
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
` (2 preceding siblings ...)
2025-03-21 12:36 ` [PULL 3/6] hw/uefi: fix error handling in uefi_vars_json_load Gerd Hoffmann
@ 2025-03-21 12:36 ` Gerd Hoffmann
2025-03-21 12:36 ` [PULL 5/6] hw/uefi-vars-sysbus: allow for loongarch virt Gerd Hoffmann
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
Allow the device being added to riscv virt VMs.
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250319141159.1461621-5-kraxel@redhat.com>
---
hw/riscv/virt.c | 2 ++
hw/uefi/Kconfig | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index dae46f4733cd..e517002fdfc7 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -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
diff --git a/hw/uefi/Kconfig b/hw/uefi/Kconfig
index ca6c2bc46a96..f139008b632b 100644
--- a/hw/uefi/Kconfig
+++ b/hw/uefi/Kconfig
@@ -1,3 +1,3 @@
config UEFI_VARS
bool
- default y if X86_64 || AARCH64
+ default y if X86_64 || AARCH64 || RISCV64
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PULL 5/6] hw/uefi-vars-sysbus: allow for loongarch virt
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
` (3 preceding siblings ...)
2025-03-21 12:36 ` [PULL 4/6] hw/uefi-vars-sysbus: allow for riscv virt Gerd Hoffmann
@ 2025-03-21 12:36 ` Gerd Hoffmann
2025-03-21 12:36 ` [PULL 6/6] docs/firmware: add feature flag for host uefi variable store Gerd Hoffmann
2025-03-23 22:29 ` [PULL 0/6] Uefi 20250321 patches Stefan Hajnoczi
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
Allow the device being added to loongarch virt VMs.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250319141159.1461621-6-kraxel@redhat.com>
---
hw/loongarch/virt.c | 2 ++
hw/uefi/Kconfig | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index a5840ff96857..b6f5f6a3b546 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -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
diff --git a/hw/uefi/Kconfig b/hw/uefi/Kconfig
index f139008b632b..046d55320e16 100644
--- a/hw/uefi/Kconfig
+++ b/hw/uefi/Kconfig
@@ -1,3 +1,3 @@
config UEFI_VARS
bool
- default y if X86_64 || AARCH64 || RISCV64
+ default y if X86_64 || AARCH64 || RISCV64 || LOONGARCH64
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PULL 6/6] docs/firmware: add feature flag for host uefi variable store
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
` (4 preceding siblings ...)
2025-03-21 12:36 ` [PULL 5/6] hw/uefi-vars-sysbus: allow for loongarch virt Gerd Hoffmann
@ 2025-03-21 12:36 ` Gerd Hoffmann
2025-03-23 22:29 ` [PULL 0/6] Uefi 20250321 patches Stefan Hajnoczi
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2025-03-21 12:36 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li, Bibo Mao,
Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20250319141159.1461621-7-kraxel@redhat.com>
---
docs/interop/firmware.json | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json
index 57f55f6c5455..745d21d82232 100644
--- a/docs/interop/firmware.json
+++ b/docs/interop/firmware.json
@@ -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' ] }
##
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PULL 0/6] Uefi 20250321 patches
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
` (5 preceding siblings ...)
2025-03-21 12:36 ` [PULL 6/6] docs/firmware: add feature flag for host uefi variable store Gerd Hoffmann
@ 2025-03-23 22:29 ` Stefan Hajnoczi
6 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2025-03-23 22:29 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: qemu-devel, Daniel Henrique Barboza, Kashyap Chamarthy, Weiwei Li,
Bibo Mao, Jiaxun Yang, Philippe Mathieu-Daudé, Paolo Bonzini,
Palmer Dabbelt, qemu-riscv, Gerd Hoffmann, Alistair Francis,
Liu Zhiwei, Song Gao, Daniel P. Berrangé
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.0 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-24 13:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 12:35 [PULL 0/6] Uefi 20250321 patches Gerd Hoffmann
2025-03-21 12:35 ` [PULL 1/6] hw/uefi: flush variable store to disk in post load Gerd Hoffmann
2025-03-21 12:36 ` [PULL 2/6] hw/uefi: fix error handling in uefi_vars_json_save Gerd Hoffmann
2025-03-21 12:36 ` [PULL 3/6] hw/uefi: fix error handling in uefi_vars_json_load Gerd Hoffmann
2025-03-21 12:36 ` [PULL 4/6] hw/uefi-vars-sysbus: allow for riscv virt Gerd Hoffmann
2025-03-21 12:36 ` [PULL 5/6] hw/uefi-vars-sysbus: allow for loongarch virt Gerd Hoffmann
2025-03-21 12:36 ` [PULL 6/6] docs/firmware: add feature flag for host uefi variable store Gerd Hoffmann
2025-03-23 22:29 ` [PULL 0/6] Uefi 20250321 patches Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).