From 88a61f5aecb4e2ed66a35ae989c4998b931e5f61 Mon Sep 17 00:00:00 2001 From: Krystian Hebel Date: Mon, 30 Sep 2024 21:32:35 +0200 Subject: [PATCH] DasharoModulePkg/DasharoVariablesLib: add runtime attribute to FUM This is required for initializing capsule update process from Linux's capsule_loader. It also fixes the possibility for putting the device in infinite FUM loop by creating the variable with runtime access. SetVariable() in WarnIfFirmwareUpdateMode() used to remove the variable failed because of mismatched attributes. According to UEFI specification, > If a preexisting variable is rewritten with no access attributes > specified, the variable will be deleted. This is exactly what is needed. The other way to delete a variable is to specify matching attributes and set the size of a variable as 0. Signed-off-by: Krystian Hebel --- .../Library/DasharoVariablesLib/DasharoVariablesLib.c | 2 +- .../Library/PlatformBootManagerLib/PlatformBootManager.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DasharoModulePkg/Library/DasharoVariablesLib/DasharoVariablesLib.c b/DasharoModulePkg/Library/DasharoVariablesLib/DasharoVariablesLib.c index 2b7c320f7d..679eb72f72 100644 --- a/DasharoModulePkg/Library/DasharoVariablesLib/DasharoVariablesLib.c +++ b/DasharoModulePkg/Library/DasharoVariablesLib/DasharoVariablesLib.c @@ -513,7 +513,7 @@ DasharoEnableFUM ( Status = gRT->SetVariable ( DASHARO_VAR_FIRMWARE_UPDATE_MODE, &gDasharoSystemFeaturesGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, sizeof (Enable), &Enable ); diff --git a/DasharoPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/DasharoPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index 0e0914c5ce..926a8bf57d 100644 --- a/DasharoPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/DasharoPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -1134,7 +1134,7 @@ WarnIfFirmwareUpdateMode ( Status = gRT->SetVariable ( DASHARO_VAR_FIRMWARE_UPDATE_MODE, &gDasharoSystemFeaturesGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, + 0, 0, NULL );