Skip to contentSkip to conversation

hw/uefi: three small bug fixes.

PATCH In review Gerd Hoffmann 2 participants 7 messages Aug 11, 2025

lore
Share & tools
lore
#0 lore raw

cover hw/uefi: three small bug fixes.

Gerd Hoffmann (3):
hw/uefi: return success for notifications
hw/uefi: check access for first variable
hw/uefi: open json file in binary mode

 hw/uefi/var-service-json.c | 2 +-
 hw/uefi/var-service-vars.c | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/3 hw/uefi: return success for notifications

Set status to SUCCESS for ready-to-boot and exit-boot-services notification calls.

---
 hw/uefi/var-service-vars.c | 2 ++
 1 file changed, 2 insertions(+)
hw/uefi/var-service-vars.c +2 -0
index 37d05b71cf70..cbeccdbd2664 100644
@@ -702,12 +702,14 @@ uint32_t uefi_vars_mm_vars_proto(uefi_vars_state *uv)
     case SMM_VARIABLE_FUNCTION_READY_TO_BOOT:
         trace_uefi_event("ready-to-boot");
         uv->ready_to_boot = true;
+        mvar->status = EFI_SUCCESS;
         length = 0;
         break;
 
     case SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE:
         trace_uefi_event("exit-boot-service");
         uv->exit_boot_service = true;
+        mvar->status = EFI_SUCCESS;
         length = 0;
         break;
 
Signature · 1 line
2.50.1
#3 lore raw

PATCH 2/3 hw/uefi: check access for first variable

In reply to Gerd Hoffmann

When listing variables (via get-next-variable-name) only the names of variables which can be accessed will be returned. That check was missing for the first variable though. Add it.

---
 hw/uefi/var-service-vars.c | 3 +++
 1 file changed, 3 insertions(+)
hw/uefi/var-service-vars.c +3 -0
index cbeccdbd2664..8533533ea5c8 100644
@@ -357,6 +357,9 @@ uefi_vars_mm_get_next_variable(uefi_vars_state *uv, mm_header *mhdr,
     if (uefi_strlen(name, nv->name_size) == 0) {
         /* empty string -> first */
         var = QTAILQ_FIRST(&uv->variables);
+        while (var && !check_access(uv, var)) {
+            var = QTAILQ_NEXT(var, next);
+        }
         if (!var) {
             return uefi_vars_mm_error(mhdr, mvar, EFI_NOT_FOUND);
         }
Signature · 1 line
2.50.1
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] hw/uefi: check access for first variable

Quoted 8 lines · Gerd Hoffmann

When listing variables (via get-next-variable-name) only the names of variables which can be accessed will be returned. That check was missing for the first variable though. Add it.

---
  hw/uefi/var-service-vars.c | 3 +++
  1 file changed, 3 insertions(+)
#5 lore raw

PATCH 3/3 hw/uefi: open json file in binary mode

In reply to Gerd Hoffmann

Fixes file length discrepancies due to line ending conversions on windows hosts.

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

---
 hw/uefi/var-service-json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/uefi/var-service-json.c +1 -1
index ad3462cd1557..f5f155683334 100644
@@ -172,7 +172,7 @@ static GString *uefi_vars_to_json(uefi_vars_state *uv)
 void uefi_vars_json_init(uefi_vars_state *uv, Error **errp)
 {
     if (uv->jsonfile) {
-        uv->jsonfd = qemu_create(uv->jsonfile, O_RDWR, 0666, errp);
+        uv->jsonfd = qemu_create(uv->jsonfile, O_RDWR | O_BINARY, 0666, errp);
     }
 }
 
Signature · 1 line
2.50.1