From nobody Mon Nov 25 13:36:51 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+69312+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+69312+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608549887; cv=none; d=zohomail.com; s=zohoarc; b=RcCkyYDTb1PnWkOGtp1LMgg7qy3YUYjHkW6k7xMMjT2C8kkzz9pqOV56GNmuFTOIezXXEa1ETzN/fukhQciRI2e6oPdkVhnkMu7O+q4riUFHrH35rzKx1h7kPO6Lv9hCDoBW3N8TJH4ihUUxsB4qUlLjvyi0KN8ygMBTA02/GQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608549887; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=rP8slIgaEijVEbarsco74IbqS4WLgFxb+f2/iIrQkeo=; b=gp2qor8YEXT8KIt6SzdeQ+ExnFKbhv3QkVpMjCPZGE+A3GXMe5W9JAaiEVSVxa4tLqxOwGTEhthzoidwu8YJJ3J2sxIB+DHqOe1+kGZTk9i3ZQCuqOwRVKTxJSy5A9hH628bEgJJQraeBl0RA0T+qPiBvbmSM2MAgogq34Q2tvo= 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+69312+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 1608549887450967.160589413125; Mon, 21 Dec 2020 03:24:47 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tlgDYY1788612xWYz5VVBYvZ; Mon, 21 Dec 2020 03:24:47 -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.38233.1608549880368171305 for ; Mon, 21 Dec 2020 03:24:41 -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-462-bhuH8_f1PXCO8lQxwpSm7Q-1; Mon, 21 Dec 2020 06:24:37 -0500 X-MC-Unique: bhuH8_f1PXCO8lQxwpSm7Q-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A679910054FF; Mon, 21 Dec 2020 11:24:36 +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 4BAFE60C0F; Mon, 21 Dec 2020 11:24:35 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Leif Lindholm , Marcin Wojtas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [edk2-platforms PATCH] Silicon/Marvell/RealTimeClockLib: make EpochSeconds, WakeupSeconds UINTN Date: Mon, 21 Dec 2020 12:24:33 +0100 Message-Id: <20201221112433.5525-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: pLRnbwsgdcxf4yaPR5x3KB87x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608549887; bh=rP8slIgaEijVEbarsco74IbqS4WLgFxb+f2/iIrQkeo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=mo7e751iXIo1l0DCiSTFX+wq1bGgFu+MkUYkHTX7B2O0BHkZBSHT2KlwLMqH50U9bii fFoERnZ99hCloYKnvU7O/NQgZQRTJCdcIlVCf9yqio3hjrK78W7Hq7M6WHyokixdJRXCA 1BxS7Gkqe1XZ1P3HG2Mr+4G1nMVJl64D2NQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" We're going to change EfiTimeToEpoch() in edk2's TimeBaseLib to propagate its internal UINTN calculation to the caller without an internal UINT32 truncation. Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib drives 32-bit-only hardware, so catch any number of seconds since the epoch, from EfiTimeToEpoch(), that doesn't fit in 32 bits. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Marcin Wojtas Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- Notes: Build-tested only, with =20 build \ -a AARCH64 \ -b NOOPT \ -p Platform/SolidRun/Armada80x0McBin/Armada80x0McBin.dsc \ -t GCC5 \ -m EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 1= 4 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCl= ockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCloc= kLib.c index 1974e0144cd8..a811fd368eca 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c @@ -100,33 +100,36 @@ EFIAPI LibSetTime ( IN EFI_TIME *Time ) { EFI_STATUS Status =3D EFI_SUCCESS; - UINT32 EpochSeconds; + UINTN EpochSeconds; =20 // Check the input parameters are within the range specified by UEFI if (!IsTimeValid (Time)) { return EFI_INVALID_PARAMETER; } =20 // Convert time to raw seconds EpochSeconds =3D EfiTimeToEpoch (Time); + if (EpochSeconds > MAX_UINT32) { + return EFI_INVALID_PARAMETER; + } =20 // Issue delayed write to time register - RtcDelayedWrite (RTC_TIME_REG, EpochSeconds); + RtcDelayedWrite (RTC_TIME_REG, (UINT32)EpochSeconds); =20 return Status; } =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 **/ @@ -172,32 +175,35 @@ EFIAPI LibSetWakeupTime ( IN BOOLEAN Enabled, OUT EFI_TIME *Time ) { - UINT32 WakeupSeconds; + UINTN WakeupSeconds; =20 // Convert time to raw seconds WakeupSeconds =3D EfiTimeToEpoch (Time); + if (WakeupSeconds > MAX_UINT32) { + return EFI_INVALID_PARAMETER; + } =20 // Issue delayed write to alarm register - RtcDelayedWrite (RTC_ALARM_2_REG, WakeupSeconds); + RtcDelayedWrite (RTC_ALARM_2_REG, (UINT32)WakeupSeconds); =20 if (Enabled) { MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN); } else { MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, 0); } =20 return EFI_SUCCESS; } =20 /** This is the declaration of an EFI image entry point. This can be the ent= ry point to an application written to this specification, an EFI boot service driver, or an EFI run= time driver. =20 @param ImageHandle Handle that identifies the loaded image. @param SystemTable System Table for this image. =20 @retval EFI_SUCCESS The operation completed successfully. =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 (#69312): https://edk2.groups.io/g/devel/message/69312 Mute This Topic: https://groups.io/mt/79123470/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-