[edk2-devel] [edk2-platforms PATCH] Marvell/RealTimeClockLib: Allow only Unix Epoch in LibSetWakeupTime

Marcin Wojtas mw at semihalf.com
Mon Dec 21 16:37:10 UTC 2020


Because the Armada RTC uses a 32-bit counter for 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.

The issue emerged during ACS test case, which does not pass
Unix Epoch-relative time and caused EfiTimeToEpoch to assert.

Signed-off-by: Marcin Wojtas <mw at semihalf.com>
---
 Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c
index a811fd368e..40ab01ed41 100644
--- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c
+++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c
@@ -179,6 +179,16 @@ LibSetWakeupTime (
 {
   UINTN       WakeupSeconds;
 
+  //
+  // Because the Armada RTC uses a 32-bit counter for 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 >= 2106)) {
+    return EFI_UNSUPPORTED;
+  }
+
   // Convert time to raw seconds
   WakeupSeconds = EfiTimeToEpoch (Time);
   if (WakeupSeconds > MAX_UINT32) {
-- 
2.29.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69335): https://edk2.groups.io/g/devel/message/69335
Mute This Topic: https://groups.io/mt/79129320/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list