[PATCH v2 2/2] efi_loader: clear OsIndications

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Jun 30 17:31:16 CEST 2021


After each reboot we must clear flag
EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED in variable
OsIndications.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
v2:
	update OsIndications after handling all capsules
---
 lib/efi_loader/efi_setup.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 3c5cf9a435..ca865c5a99 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -5,9 +5,12 @@
  *  Copyright (c) 2016-2018 Alexander Graf et al.
  */

+#define LOG_CATEGORY LOGC_EFI
+
 #include <common.h>
 #include <efi_loader.h>
 #include <efi_variable.h>
+#include <log.h>

 #define OBJ_LIST_NOT_INITIALIZED 1

@@ -171,6 +174,32 @@ static efi_status_t efi_init_os_indications(void)
 				    &os_indications_supported, false);
 }

+static efi_status_t efi_clear_os_indications(void)
+{
+	efi_uintn_t size;
+	u64 os_indications;
+	efi_status_t ret;
+
+	/* Clear EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED */
+	size = sizeof(os_indications);
+	ret = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid,
+				   NULL, &size, &os_indications, NULL);
+	if (ret != EFI_SUCCESS)
+		os_indications = 0;
+	else
+		os_indications &=
+			~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED;
+	ret = efi_set_variable_int(L"OsIndications", &efi_global_variable_guid,
+				   EFI_VARIABLE_NON_VOLATILE |
+				   EFI_VARIABLE_BOOTSERVICE_ACCESS |
+				   EFI_VARIABLE_RUNTIME_ACCESS,
+				   sizeof(os_indications), &os_indications,
+				   false);
+	if (ret != EFI_SUCCESS)
+		log_err("Setting %ls failed\n", L"OsIndications");
+	return EFI_SUCCESS;
+}
+
 /**
  * efi_init_obj_list() - Initialize and populate EFI object list
  *
@@ -291,6 +320,10 @@ efi_status_t efi_init_obj_list(void)
 	if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK) &&
 	    !IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
 		ret = efi_launch_capsules();
+	if (ret != EFI_SUCCESS)
+		goto out;
+
+	ret = efi_clear_os_indications();
 out:
 	efi_obj_list_initialized = ret;
 	return ret;
--
2.30.2



More information about the U-Boot mailing list