From nobody Sun Apr 28 02:37:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69314+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69314+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608550629; cv=none; d=zohomail.com; s=zohoarc; b=fhszglR+eh0asK1tEWmHlF9KZ+UOTrnHa3oPMFiVY2Bq0Bqye4hkse8hcJR3EnAHKaEKhmBtEDwfuRc5rFisD9EpfNaaRmMGmW9zpd+2Xqxrh1+537mRJJi0Ksdjp8CPC5YFvtJk7bK9XEQpBhNj9yYKe9zHakYEyNONDGSJfHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608550629; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=KhwJfam7Z1AZonJnugxSZ3aTE2oEN6onNTo50+RreKw=; b=aqZZk+iV8EX+hynmgS3frwOiqqKPrrkkWAIvqFpiWHFSN4qnZ+OGd82anCXocQ/scgQxn4TEBpOSDGyufB9mpNhKCuGbscF2ntKdziRff3dcZmEXGBL/ej2ttNoUiQTLCGbklAtt+Kq3EYyLP+L0guamaq+2aNHbe+Ks3yACJvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69314+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608550629229155.65549013278746; Mon, 21 Dec 2020 03:37:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id lF0vYY1788612xzjM6oBde3a; Mon, 21 Dec 2020 03:37:08 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.37831.1608550625486686621 for ; Mon, 21 Dec 2020 03:37:05 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-xJO1P2c-MfipKDMLmtVnhw-1; Mon, 21 Dec 2020 06:37:02 -0500 X-MC-Unique: xJO1P2c-MfipKDMLmtVnhw-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8DC11005E46; Mon, 21 Dec 2020 11:37:01 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-71.ams2.redhat.com [10.36.114.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CB971007604; Mon, 21 Dec 2020 11:37:00 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Leif Lindholm , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH 1/2] ArmPlatformPkg/PL031RealTimeClockLib: cast EfiTimeToEpoch() val. to UINT32 Date: Mon, 21 Dec 2020 12:36:56 +0100 Message-Id: <20201221113657.6779-2-lersek@redhat.com> In-Reply-To: <20201221113657.6779-1-lersek@redhat.com> References: <20201221113657.6779-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: j2uLQULsjflIf6fpTbgTs2vEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608550628; bh=KhwJfam7Z1AZonJnugxSZ3aTE2oEN6onNTo50+RreKw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=KF6ANj+m5yGujm3Zh8jVLfV0uZDyZ0Mr7+DryrXIq96VqwZT9OamLQ3DBvENBaZhxPm VPVuv1I4NzLvpi4qHgexa0n34V2OuJT5/R3mCbMC6+57uyqsEpvFAaPQJnEeRpFwVGrV7 2lJ7QTeWCPkHfsh2dJzIitFG6tLGWk6uNQQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In preparation for changing EfiTimeToEpoch()'s return type to UINTN, cast EfiTimeToEpoch()'s retval to UINT32 explicitly, in LibSetTime(). Currently, this is a no-op, and even after widening the retval, it will make no difference, as LibSetTime() explicitly restricts Time->Year under 2106, given that "the PL031 is a 32-bit counter counting seconds". The patch is made for preventing compiler warnings. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeCloc= kLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib= .c index 0df4ceb1cb39..3afef4bf9ad4 100644 --- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c +++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c @@ -180,53 +180,53 @@ EFIAPI LibSetTime ( IN EFI_TIME *Time ) { EFI_STATUS Status; UINT32 EpochSeconds; =20 // Because the PL031 is a 32-bit counter counting seconds, // the maximum time span is just over 136 years. // Time is stored in Unix Epoch format, so it starts in 1970, // Therefore it can not exceed the year 2106. if ((Time->Year < 1970) || (Time->Year >=3D 2106)) { return EFI_UNSUPPORTED; } =20 // Initialize the hardware if not already done if (!mPL031Initialized) { Status =3D InitializePL031 (); if (EFI_ERROR (Status)) { return Status; } } =20 - EpochSeconds =3D EfiTimeToEpoch (Time); + EpochSeconds =3D (UINT32)EfiTimeToEpoch (Time); =20 // Adjust for the correct time zone, i.e. convert to UTC time zone // The timezone setting also reflects the DST setting of the clock if (Time->TimeZone !=3D EFI_UNSPECIFIED_TIMEZONE) { EpochSeconds -=3D Time->TimeZone * SEC_PER_MIN; } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) =3D=3D EFI_TIME_IN_DA= YLIGHT) { // Convert to un-adjusted time, i.e. fall back one hour EpochSeconds -=3D SEC_PER_HOUR; } =20 // Set the PL031 MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds); =20 return EFI_SUCCESS; } =20 =20 /** Returns the current wakeup alarm clock setting. =20 @param Enabled Indicates if the alarm is currently enable= d or disabled. @param Pending Indicates if the alarm signal is pending a= nd requires acknowledgement. @param Time The current alarm setting. =20 @retval EFI_SUCCESS The alarm settings were returned. @retval EFI_INVALID_PARAMETER Any parameter is NULL. @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due= to a hardware error. =20 **/ --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#69314): https://edk2.groups.io/g/devel/message/69314 Mute This Topic: https://groups.io/mt/79123602/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun Apr 28 02:37:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69315+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69315+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608550629; cv=none; d=zohomail.com; s=zohoarc; b=j5cJ647nMsU4QegVzw6YMqDVLJBVdT63tw7qJ7PBz1mVtS/Ht7Dk9G0+gl08ExGfJa10hLJFUHnEJLk/7q/KhV6jawlXyMXYPw9VSc1CWiLUDuAPcbDX7CtSRRBOuKZSwXLpGZ1vFf1RYgXxtN3juLuurseNqZZjh8rwqL+veCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608550629; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=2UYcqrdV6pFC4KS6wFaOnrzhJPMnit4G+X/YOysmShc=; b=gu3a/VzecQPANpagblk7MoI2vmnwNQ4tmif5TWlzovgaN4axuNdBT5+vN0oG46408sSc8obce5vws2wPdUizKFJHphXa6z5eFePJEi8KrnoFxQvK4tgqehdSNE95teyZwqmqgcMyLNU8trt+RKA2RqZ8/tte+LIAE9xs4datVhQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69315+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608550629729579.7707525477167; Mon, 21 Dec 2020 03:37:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ScgOYY1788612x7VI1Ul7wio; Mon, 21 Dec 2020 03:37:09 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web10.38336.1608550626905223141 for ; Mon, 21 Dec 2020 03:37:07 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-zBu8YoG1NCaaHQBOryKBQQ-1; Mon, 21 Dec 2020 06:37:04 -0500 X-MC-Unique: zBu8YoG1NCaaHQBOryKBQQ-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25A38800D55; Mon, 21 Dec 2020 11:37:03 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-71.ams2.redhat.com [10.36.114.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 093991001901; Mon, 21 Dec 2020 11:37:01 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Leif Lindholm , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH 2/2] EmbeddedPkg/TimeBaseLib: remove useless truncation to 32-bit Date: Mon, 21 Dec 2020 12:36:57 +0100 Message-Id: <20201221113657.6779-3-lersek@redhat.com> In-Reply-To: <20201221113657.6779-1-lersek@redhat.com> References: <20201221113657.6779-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: KD2jf5qE7CHerd5qerb7GZc5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608550629; bh=2UYcqrdV6pFC4KS6wFaOnrzhJPMnit4G+X/YOysmShc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=IByOM+IsLbbp1TpllZCwl+hFWbz/d/vdJEDEUMB/fgyhgH/vJ2xT5WpnV0p6dJMsbZZ 5vH6w/vCIQo6t0XU8f7WgQzU3+LOlMW43jrv1INpEt7PiDHC6B0S2uWuoPApWs1HteirX 1jFfjHoFNgCebLTyFeZqCTTnISPOFicCEKs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" EfiTimeToEpoch() calls EfiGetEpochDays() internally, which (reasonably) returns a UINTN. But then EfiTimeToEpoch() truncates the EfiGetEpochDays() retval to UINT32 for no good reason, effectively restricting Time->Year under 2106. This truncation was pointed out with a valid warning (=3D build error) by VS2019. Allow EfiTimeToEpoch() to return / propagate a UINTN value. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- Notes: This patch may only be committed after the edk2-platforms patch "Silicon/Marvell/RealTimeClockLib: make EpochSeconds, WakeupSeconds UINTN". EmbeddedPkg/Include/Library/TimeBaseLib.h | 2 +- EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EmbeddedPkg/Include/Library/TimeBaseLib.h b/EmbeddedPkg/Includ= e/Library/TimeBaseLib.h index 3c2d3660c66c..90853c3f4b93 100644 --- a/EmbeddedPkg/Include/Library/TimeBaseLib.h +++ b/EmbeddedPkg/Include/Library/TimeBaseLib.h @@ -83,7 +83,7 @@ EpochToEfiTime ( /** Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00= :00 UTC) **/ -UINT32 +UINTN EFIAPI EfiTimeToEpoch ( IN EFI_TIME *Time diff --git a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c b/EmbeddedPkg/Li= brary/TimeBaseLib/TimeBaseLib.c index 136ce8a51e86..78fc7b6cd2e5 100644 --- a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c +++ b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c @@ -97,24 +97,24 @@ EfiGetEpochDays ( return EpochDays; } /** Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00= :00 UTC) **/ -UINT32 +UINTN EFIAPI EfiTimeToEpoch ( IN EFI_TIME *Time ) { - UINT32 EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY - UINT32 EpochSeconds; + UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY + UINTN EpochSeconds; =20 EpochDays =3D EfiGetEpochDays (Time); =20 EpochSeconds =3D (EpochDays * SEC_PER_DAY) + ((UINTN)Time->Hour * SEC_PE= R_HOUR) + (Time->Minute * SEC_PER_MIN) + Time->Second; =20 return EpochSeconds; } =20 /** returns Day of the week [0-6] 0=3DSunday **/ --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#69315): https://edk2.groups.io/g/devel/message/69315 Mute This Topic: https://groups.io/mt/79123604/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-