From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web10.7537.1627553719115989570 for ; Thu, 29 Jul 2021 03:15:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=biu/BFBm; spf=pass (domain: kernel.org, ip: 198.145.29.99, mailfrom: ardb@kernel.org) Received: by mail.kernel.org (Postfix) with ESMTPSA id 80AD360F23 for ; Thu, 29 Jul 2021 10:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627553718; bh=6jzk11CURsnZsTNvxC3Pw6qyIyDo1rUHqvgpwHu7rF8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=biu/BFBmsKGmRyBvVEyHAp8wVK9b6fELoKGsMSZQVFWLSmWfLDeC2NI7OH5ohW+lQ /+NNWhDxIayplerjEOHQ1L5fbXBN72AbbKXjdWU4Z9DmbIlrIxz4O5RddTv85qYWFk 0Y0IXUOhCsXDbllD4rP4tH8IalMKC+o1b9z6zQtU8E99E8+7tPqLCF3gW7iTtKI4d3 P1aMAT5SMKb7bUSJ9OajANwDnoBljih38YyVnmWd3P5XaK3Uayf7BhWuAkGdcwAqzG y7ytgSu4DbK0XapG2ILcnfwOJ9p7z9MdbtA7UGBBMpTlOXm3GOsmlftDliXEoODYpC oqBURCfMMsBsg== Received: by mail-ot1-f47.google.com with SMTP id a5-20020a05683012c5b029036edcf8f9a6so5359533otq.3 for ; Thu, 29 Jul 2021 03:15:18 -0700 (PDT) X-Gm-Message-State: AOAM533h+YdWAhwho6f+UHN9p6gkZHDZdVf5Kw4vDH501wrZjZIcPUFU o4NTEzgDx5GeVNT/DVSRmvhILBqQpHGXVrOWWuI= X-Google-Smtp-Source: ABdhPJxPFLeVin+i6+58PnGHJgSVZaXC8Jp7v2mtEDYOck9osBlN3qwnQSR4Q3Sn3Ihkb9h6b/6bHBVYSBJcuWLfHLQ= X-Received: by 2002:a9d:2625:: with SMTP id a34mr2843302otb.77.1627553717393; Thu, 29 Jul 2021 03:15:17 -0700 (PDT) MIME-Version: 1.0 References: <20210723090417.1460-1-Sunny.Wang@arm.com> In-Reply-To: From: "Ard Biesheuvel" Date: Thu, 29 Jul 2021 12:15:06 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] EmbeddedPkg/VirtualRealTimeClockLib : Fix SetTime issues To: Pete Batard Cc: Sunny Wang , edk2-devel-groups-io , Samer El-Haj-Mahmoud , Sami Mujawar , Jeremy Linton , Ard Biesheuvel , Leif Lindholm Content-Type: text/plain; charset="UTF-8" On Fri, 23 Jul 2021 at 18:43, Pete Batard wrote: > > Hi Sunny, > > Good catch for both these issues. Thanks for fixing them. > > With this: > > On 2021.07.23 10:04, Sunny Wang wrote: > > 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/VirtualRealTimeClockLib.c b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.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, Status = %r\n", > > - mDaylightVariableName, > > + mEpochVariableName, > > Status > > )); > > return Status; > > > > Reviewed-by: Pete Batard > Tested-by: Pete Batard Merged, thanks,