[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.22 1/5] x86/time: use RTC century byte when available





On 5/12/26 4:58 PM, Jan Beulich wrote:
Without this the present logic will misbehave from 2070 onwards.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Generally it looks like 4.22 won't be used in 2070 or higher (I am curious do we have similar use cases now that very old Xen version is used nowadays?) but the patch looks pretty straightforward:
 Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>

Thanks.

~ Oleksii


--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1257,6 +1257,7 @@ struct rtc_time {
  static bool __get_cmos_time(struct rtc_time *rtc)
  {
      s_time_t start, t1, t2;
+    unsigned int century = 0;
      unsigned long flags;
spin_lock_irqsave(&rtc_lock, flags);
@@ -1280,6 +1281,8 @@ static bool __get_cmos_time(struct rtc_t
      rtc->day  = CMOS_READ(RTC_DAY_OF_MONTH);
      rtc->mon  = CMOS_READ(RTC_MONTH);
      rtc->year = CMOS_READ(RTC_YEAR);
+    if ( acpi_gbl_FADT.century && acpi_gbl_FADT.century < 0x80 )
+        century = CMOS_READ(acpi_gbl_FADT.century);
if ( RTC_ALWAYS_BCD || !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) )
      {
@@ -1293,7 +1296,12 @@ static bool __get_cmos_time(struct rtc_t
spin_unlock_irqrestore(&rtc_lock, flags); - if ( (rtc->year += 1900) < 1970 )
+    if ( century )
+    {
+        BCD_TO_BIN(century);
+        rtc->year += century * 100;
+    }
+    else if ( (rtc->year += 1900) < 1970 )
          rtc->year += 100;
return t1 <= SECONDS(1) && t2 < MILLISECS(3);





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.