]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/VirtualRealTimeClockLib: Fix SetTime issues
authorSunny Wang <Sunny.Wang@arm.com>
Fri, 23 Jul 2021 09:01:01 +0000 (17:01 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 29 Jul 2021 10:13:32 +0000 (10:13 +0000)
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.

Signed-off-by: Sunny Wang <sunny.wang@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c

index de6fbb40e61be5861a78fb0274e4fac85eac0b81..c10c91bc758c6e5c47bae51093e392a5380c827c 100644 (file)
@@ -4,7 +4,7 @@
  *\r
  *  Coypright (c) 2019, Pete Batard <pete@akeo.ie>\r
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>\r
- *  Copyright (c) 2011-2014, ARM Ltd. All rights reserved.\r
+ *  Copyright (c) 2011-2021, ARM Ltd. All rights reserved.\r
  *  Copyright (c) 2008-2010, Apple Inc. All rights reserved.\r
  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
  *\r
@@ -96,7 +96,7 @@ LibGetTime (
     EfiSetVariable (\r
       (CHAR16 *)mEpochVariableName,\r
       &gEfiCallerIdGuid,\r
-      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
       sizeof (EpochSeconds),\r
       &EpochSeconds\r
       );\r
@@ -324,7 +324,7 @@ LibSetTime (
     DEBUG ((\r
       DEBUG_ERROR,\r
       "LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",\r
-      mDaylightVariableName,\r
+      mEpochVariableName,\r
       Status\r
       ));\r
     return Status;\r