From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.5874.1627030891008764245 for ; Fri, 23 Jul 2021 02:01:31 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: sunny.wang@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 716B7113E; Fri, 23 Jul 2021 02:01:29 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7430A3F73D; Fri, 23 Jul 2021 02:01:27 -0700 (PDT) From: "Sunny Wang" To: devel@edk2.groups.io Cc: Sunny Wang , Samer El-Haj-Mahmoud , Sami Mujawar , Jeremy Linton , Ard Biesheuvel , Pete Batard , Leif Lindholm , Sunny Wang Subject: [edk2-platform][PATCH v1 1/1] EmbeddedPkg/VirtualRealTimeClockLib : Fix SetTime issues Date: Fri, 23 Jul 2021 17:01:01 +0800 Message-Id: <20210723090101.1382-1-Sunny.Wang@arm.com> X-Mailer: git-send-email 2.31.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable This patch fixes two issues below: 1. SCT SetTime_Func failures. - https://github.com/pftf/RPi4/issues/164 2. Using shell time and date commands to set time can't work. The problem is that gRT->SetTime always returns EFI_INVALID_PARAMETER error status. The root cause is that LibSetTime() sets RtcEpochSeconds variable with inconsistent attributes. One is without EFI_VARIABLE_NON_VOLATILE, the other one is with EFI_VARIABLE_NON_VOLATILE. That caused that the variable driver returns EFI_INVALID_PARAMETER. Per UEFI spec, if a preexisting variable is rewritten with different attributes, SetVariable() shall not modify the variable and shall return EFI_INVALID_PARAMETER. Therefore, the solution is to add EFI_VARIABLE_NON_VOLATILE attribute to the first EfiSetVariable() call to make two calls consistent. By the way, this patch also fix a minor issue with a debug message. Cc: Samer El-Haj-Mahmoud Cc: Sami Mujawar Cc: Jeremy Linton Cc: Ard Biesheuvel Cc: Pete Batard Cc: Leif Lindholm Signed-off-by: Sunny Wang --- .../VirtualRealTimeClockLib/VirtualRealTimeClockLib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeC= lockLib.c b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeCl= ockLib.c index de6fbb40e6..c10c91bc75 100644 --- a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib= .c +++ b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib= .c @@ -4,7 +4,7 @@ * * Coypright (c) 2019, Pete Batard * Copyright (c) 2018, Andrei Warkentin - * Copyright (c) 2011-2014, ARM Ltd. All rights reserved. + * Copyright (c) 2011-2021, ARM Ltd. All rights reserved. * Copyright (c) 2008-2010, Apple Inc. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved. * @@ -96,7 +96,7 @@ LibGetTime ( EfiSetVariable ( (CHAR16 *)mEpochVariableName, &gEfiCallerIdGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_= VARIABLE_RUNTIME_ACCESS, sizeof (EpochSeconds), &EpochSeconds ); @@ -324,7 +324,7 @@ LibSetTime ( DEBUG (( DEBUG_ERROR, "LibSetTime: Failed to save %s variable to non-volatile storage, S= tatus =3D %r\n", - mDaylightVariableName, + mEpochVariableName, Status )); return Status; --=20 2.31.0.windows.1