Discussion:
[edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug
Ruiyu Ni
2015-06-10 04:10:52 UTC
Permalink
The original driver cannot handle the case when system time runs from 1999/12/31 23:59:59
to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this bug.
The patch limits the driver to only support year in 100 range and decide the century value based
on the supporting range: Century either equals to PcdMinimalYear / 100 or equals to PcdMinimalYear / 100 + 1.

The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31 23:59:59,
the next second system time will become 1998/1/1 0:0:0. I think it's a acceptable limitation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Feng Tian <***@intel.com>
Cc: Liming Gao <***@intel.com>
Cc: Michael D Kinney <***@intel.com>
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55 +++++++++-------------
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@

## This PCD specifies the maximal valid year in RTC.
# @Prompt Maximal valid year in RTC.
- gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x0000000E
+ # @Expression gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear < gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
+ gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2097|UINT16|0x0000000E

[PcdsFixedAtBuild, PcdsPatchableInModule]
## Defines the ACPI register set base address.
@@ -168,4 +169,4 @@
gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddressMask |0xFFFE|UINT16|0x00000018

[UserExtensions.TianoCore."ExtraFiles"]
- PcAtChipsetPkgExtra.uni
\ No newline at end of file
+ PcAtChipsetPkgExtra.uni
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
index 23f8d3b..9ec309c 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
@@ -100,7 +100,6 @@ PcRtcInit (
RTC_REGISTER_A RegisterA;
RTC_REGISTER_B RegisterB;
RTC_REGISTER_D RegisterD;
- UINT8 Century;
EFI_TIME Time;
UINTN DataSize;
UINT32 TimerVar;
@@ -163,8 +162,6 @@ PcRtcInit (
Time.Month = RtcRead (RTC_ADDRESS_MONTH);
Time.Year = RtcRead (RTC_ADDRESS_YEAR);

- Century = RtcRead (RTC_ADDRESS_CENTURY);
-
//
// Set RTC configuration after get original time
// The value of bit AIE should be reserved.
@@ -201,7 +198,7 @@ PcRtcInit (
//
// Validate time fields
//
- Status = ConvertRtcTimeToEfiTime (&Time, Century, RegisterB);
+ Status = ConvertRtcTimeToEfiTime (&Time, RegisterB);
if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (&Time);
}
@@ -218,7 +215,7 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = RTC_INIT_YEAR;
+ Time.Year = PcdGet16 (PcdMinimalValidYear);
Time.Nanosecond = 0;
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
Time.Daylight = 0;
@@ -251,7 +248,7 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = RTC_INIT_YEAR;
+ Time.Year = PcdGet16 (PcdMinimalValidYear);
Time.Nanosecond = 0;
Time.TimeZone = Global->SavedTimeZone;
Time.Daylight = Global->Daylight;;
@@ -272,8 +269,8 @@ PcRtcInit (
}
return EFI_DEVICE_ERROR;
}
-
- ConvertEfiTimeToRtcTime (&Time, RegisterB, &Century);
+
+ ConvertEfiTimeToRtcTime (&Time, RegisterB);

//
// Set the Y/M/D info to variable as it has no corresponding hw registers.
@@ -343,7 +340,6 @@ PcRtcGetTime (
{
EFI_STATUS Status;
RTC_REGISTER_B RegisterB;
- UINT8 Century;

//
// Check parameters for null pointer
@@ -383,8 +379,6 @@ PcRtcGetTime (
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
Time->Year = RtcRead (RTC_ADDRESS_YEAR);

- Century = RtcRead (RTC_ADDRESS_CENTURY);
-
//
// Release RTC Lock.
//
@@ -401,7 +395,7 @@ PcRtcGetTime (
//
// Make sure all field values are in correct range
//
- Status = ConvertRtcTimeToEfiTime (Time, Century, RegisterB);
+ Status = ConvertRtcTimeToEfiTime (Time, RegisterB);
if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (Time);
}
@@ -447,7 +441,6 @@ PcRtcSetTime (
EFI_STATUS Status;
EFI_TIME RtcTime;
RTC_REGISTER_B RegisterB;
- UINT8 Century;
UINT32 TimerVar;

if (Time == NULL) {
@@ -506,7 +499,7 @@ PcRtcSetTime (
RegisterB.Bits.Set = 1;
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);

- ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
+ ConvertEfiTimeToRtcTime (&RtcTime, RegisterB);

RtcWrite (RTC_ADDRESS_SECONDS, RtcTime.Second);
RtcWrite (RTC_ADDRESS_MINUTES, RtcTime.Minute);
@@ -514,7 +507,6 @@ PcRtcSetTime (
RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH, RtcTime.Day);
RtcWrite (RTC_ADDRESS_MONTH, RtcTime.Month);
RtcWrite (RTC_ADDRESS_YEAR, (UINT8) RtcTime.Year);
- RtcWrite (RTC_ADDRESS_CENTURY, Century);

//
// Allow updates of the RTC registers
@@ -564,7 +556,6 @@ PcRtcGetWakeupTime (
EFI_STATUS Status;
RTC_REGISTER_B RegisterB;
RTC_REGISTER_C RegisterC;
- UINT8 Century;
EFI_TIME RtcTime;
UINTN DataSize;

@@ -612,8 +603,6 @@ PcRtcGetWakeupTime (
Time->TimeZone = Global->SavedTimeZone;
Time->Daylight = Global->Daylight;

- Century = RtcRead (RTC_ADDRESS_CENTURY);
-
//
// Get the alarm info from variable
//
@@ -644,7 +633,7 @@ PcRtcGetWakeupTime (
//
// Make sure all field values are in correct range
//
- Status = ConvertRtcTimeToEfiTime (Time, Century, RegisterB);
+ Status = ConvertRtcTimeToEfiTime (Time, RegisterB);
if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (Time);
}
@@ -680,7 +669,6 @@ PcRtcSetWakeupTime (
EFI_STATUS Status;
EFI_TIME RtcTime;
RTC_REGISTER_B RegisterB;
- UINT8 Century;
EFI_TIME_CAPABILITIES Capabilities;

ZeroMem (&RtcTime, sizeof (RtcTime));
@@ -736,7 +724,7 @@ PcRtcSetWakeupTime (
RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);

if (Enable) {
- ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
+ ConvertEfiTimeToRtcTime (&RtcTime, RegisterB);
} else {
//
// if the alarm is disable, record the current setting.
@@ -837,7 +825,6 @@ CheckAndConvertBcd8ToDecimal8 (

@param Time On input, the time data read from RTC to convert
On output, the time converted to UEFI format
- @param Century Value of century read from RTC.
@param RegisterB Value of Register B of RTC, indicating data mode
and hour format.

@@ -848,11 +835,11 @@ CheckAndConvertBcd8ToDecimal8 (
EFI_STATUS
ConvertRtcTimeToEfiTime (
IN OUT EFI_TIME *Time,
- IN UINT8 Century,
IN RTC_REGISTER_B RegisterB
)
{
BOOLEAN IsPM;
+ UINT8 Century;

if ((Time->Hour & 0x80) != 0) {
IsPM = TRUE;
@@ -870,14 +857,21 @@ ConvertRtcTimeToEfiTime (
Time->Minute = CheckAndConvertBcd8ToDecimal8 (Time->Minute);
Time->Second = CheckAndConvertBcd8ToDecimal8 (Time->Second);
}
- Century = CheckAndConvertBcd8ToDecimal8 (Century);

if (Time->Year == 0xff || Time->Month == 0xff || Time->Day == 0xff ||
- Time->Hour == 0xff || Time->Minute == 0xff || Time->Second == 0xff ||
- Century == 0xff) {
+ Time->Hour == 0xff || Time->Minute == 0xff || Time->Second == 0xff) {
return EFI_INVALID_PARAMETER;
}

+ //
+ // For minimal/maximum year range [1970, 2069],
+ // Century is 19 if RTC year >= 70,
+ // Century is 20 otherwise.
+ //
+ Century = (UINT8) (PcdGet16 (PcdMinimalValidYear) / 100);
+ if (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) {
+ Century++;
+ }
Time->Year = (UINT16) (Century * 100 + Time->Year);

//
@@ -1053,14 +1047,11 @@ IsLeapYear (
@param Time On input, the time data read from UEFI to convert
On output, the time converted to RTC format
@param RegisterB Value of Register B of RTC, indicating data mode
- @param Century It is set according to EFI_TIME Time.
-
**/
VOID
ConvertEfiTimeToRtcTime (
IN OUT EFI_TIME *Time,
- IN RTC_REGISTER_B RegisterB,
- OUT UINT8 *Century
+ IN RTC_REGISTER_B RegisterB
)
{
BOOLEAN IsPM;
@@ -1081,10 +1072,8 @@ ConvertEfiTimeToRtcTime (
}
}
//
- // Set the Time/Date/Daylight Savings values.
+ // Set the Time/Date values.
//
- *Century = DecimalToBcd8 ((UINT8) (Time->Year / 100));
-
Time->Year = (UINT16) (Time->Year % 100);

if (RegisterB.Bits.Dm == 0) {
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
index 020d715..026c108 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
@@ -1,7 +1,7 @@
/** @file
Header file for real time clock driver.

-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -61,7 +61,6 @@ typedef struct {
#define RTC_ADDRESS_REGISTER_B 11 // R/W
#define RTC_ADDRESS_REGISTER_C 12 // RO
#define RTC_ADDRESS_REGISTER_D 13 // RO
-#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
//
// Date and time initial values.
// They are used if the RTC values are invalid during driver initialization
@@ -71,7 +70,6 @@ typedef struct {
#define RTC_INIT_HOUR 0
#define RTC_INIT_DAY 1
#define RTC_INIT_MONTH 1
-#define RTC_INIT_YEAR 2001

//
// Register initial values
@@ -287,14 +285,11 @@ RtcTimeFieldsValid (
@param Time On input, the time data read from UEFI to convert
On output, the time converted to RTC format
@param RegisterB Value of Register B of RTC, indicating data mode
- @param Century It is set according to EFI_TIME Time.
-
**/
VOID
ConvertEfiTimeToRtcTime (
IN OUT EFI_TIME *Time,
- IN RTC_REGISTER_B RegisterB,
- OUT UINT8 *Century
+ IN RTC_REGISTER_B RegisterB
);


@@ -308,7 +303,6 @@ ConvertEfiTimeToRtcTime (

@param Time On input, the time data read from RTC to convert
On output, the time converted to UEFI format
- @param Century Value of century read from RTC.
@param RegisterB Value of Register B of RTC, indicating data mode
and hour format.

@@ -319,7 +313,6 @@ ConvertEfiTimeToRtcTime (
EFI_STATUS
ConvertRtcTimeToEfiTime (
IN OUT EFI_TIME *Time,
- IN UINT8 Century,
IN RTC_REGISTER_B RegisterB
);
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Tian, Feng
2015-06-11 02:04:11 UTC
Permalink
Reviewed-by: Feng Tian <***@intel.com>

-----Original Message-----
From: Ni, Ruiyu
Sent: Wednesday, June 10, 2015 12:11
To: edk2-***@lists.sourceforge.net
Cc: Ni, Ruiyu; Tian, Feng; Gao, Liming; Kinney, Michael D
Subject: [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug

The original driver cannot handle the case when system time runs from 1999/12/31 23:59:59 to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this bug.
The patch limits the driver to only support year in 100 range and decide the century value based on the supporting range: Century either equals to PcdMinimalYear / 100 or equals to PcdMinimalYear / 100 + 1.

The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31 23:59:59, the next second system time will become 1998/1/1 0:0:0. I think it's a acceptable limitation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Feng Tian <***@intel.com>
Cc: Liming Gao <***@intel.com>
Cc: Michael D Kinney <***@intel.com>
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55 +++++++++------------- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@

## This PCD specifies the maximal valid year in RTC.
# @Prompt Maximal valid year in RTC.
- gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x0000000E
+ # @Expression gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear <
+ gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
+ gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2097|UINT16|0x000000
+ 0E

[PcdsFixedAtBuild, PcdsPatchableInModule]
## Defines the ACPI register set base address.
@@ -168,4 +169,4 @@
gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddressMask |0xFFFE|UINT16|0x00000018

[UserExtensions.TianoCore."ExtraFiles"]
- PcAtChipsetPkgExtra.uni
\ No newline at end of file
+ PcAtChipsetPkgExtra.uni
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
index 23f8d3b..9ec309c 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
@@ -100,7 +100,6 @@ PcRtcInit (
RTC_REGISTER_A RegisterA;
RTC_REGISTER_B RegisterB;
RTC_REGISTER_D RegisterD;
- UINT8 Century;
EFI_TIME Time;
UINTN DataSize;
UINT32 TimerVar;
@@ -163,8 +162,6 @@ PcRtcInit (
Time.Month = RtcRead (RTC_ADDRESS_MONTH);
Time.Year = RtcRead (RTC_ADDRESS_YEAR);

- Century = RtcRead (RTC_ADDRESS_CENTURY);
-
//
// Set RTC configuration after get original time
// The value of bit AIE should be reserved.
@@ -201,7 +198,7 @@ PcRtcInit (
//
// Validate time fields
//
- Status = ConvertRtcTimeToEfiTime (&Time, Century, RegisterB);
+ Status = ConvertRtcTimeToEfiTime (&Time, RegisterB);
if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (&Time);
}
@@ -218,7 +215,7 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = RTC_INIT_YEAR;
+ Time.Year = PcdGet16 (PcdMinimalValidYear);
Time.Nanosecond = 0;
Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
Time.Daylight = 0;
@@ -251,7 +248,7 @@ PcRtcInit (
Time.Hour = RTC_INIT_HOUR;
Time.Day = RTC_INIT_DAY;
Time.Month = RTC_INIT_MONTH;
- Time.Year = RTC_INIT_YEAR;
+ Time.Year = PcdGet16 (PcdMinimalValidYear);
Time.Nanosecond = 0;
Time.TimeZone = Global->SavedTimeZone;
Time.Daylight = Global->Daylight;;
@@ -272,8 +269,8 @@ PcRtcInit (
}
return EFI_DEVICE_ERROR;
}
-
- ConvertEfiTimeToRtcTime (&Time, RegisterB, &Century);
+
+ ConvertEfiTimeToRtcTime (&Time, RegisterB);

//
// Set the Y/M/D info to variable as it has no corresponding hw registers.
@@ -343,7 +340,6 @@ PcRtcGetTime (
{
EFI_STATUS Status;
RTC_REGISTER_B RegisterB;
- UINT8 Century;

//
// Check parameters for null pointer
@@ -383,8 +379,6 @@ PcRtcGetTime (
Time->Month = RtcRead (RTC_ADDRESS_MONTH);
Time->Year = RtcRead (RTC_ADDRESS_YEAR);

- Century = RtcRead (RTC_ADDRESS_CENTURY);
-
//
// Release RTC Lock.
//
@@ -401,7 +395,7 @@ PcRtcGetTime (
//
// Make sure all field values are in correct range
//
- Status = ConvertRtcTimeToEfiTime (Time, Century, RegisterB);
+ Status = ConvertRtcTimeToEfiTime (Time, RegisterB);
if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (Time);
}
@@ -447,7 +441,6 @@ PcRtcSetTime (
EFI_STATUS Status;
EFI_TIME RtcTime;
RTC_REGISTER_B RegisterB;
- UINT8 Century;
UINT32 TimerVar;

if (Time == NULL) {
@@ -506,7 +499,7 @@ PcRtcSetTime (
RegisterB.Bits.Set = 1;
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);

- ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
+ ConvertEfiTimeToRtcTime (&RtcTime, RegisterB);

RtcWrite (RTC_ADDRESS_SECONDS, RtcTime.Second);
RtcWrite (RTC_ADDRESS_MINUTES, RtcTime.Minute); @@ -514,7 +507,6 @@ PcRtcSetTime (
RtcWrite (RTC_ADDRESS_DAY_OF_THE_MONTH, RtcTime.Day);
RtcWrite (RTC_ADDRESS_MONTH, RtcTime.Month);
RtcWrite (RTC_ADDRESS_YEAR, (UINT8) RtcTime.Year);
- RtcWrite (RTC_ADDRESS_CENTURY, Century);

//
// Allow updates of the RTC registers @@ -564,7 +556,6 @@ PcRtcGetWakeupTime (
EFI_STATUS Status;
RTC_REGISTER_B RegisterB;
RTC_REGISTER_C RegisterC;
- UINT8 Century;
EFI_TIME RtcTime;
UINTN DataSize;

@@ -612,8 +603,6 @@ PcRtcGetWakeupTime (
Time->TimeZone = Global->SavedTimeZone;
Time->Daylight = Global->Daylight;

- Century = RtcRead (RTC_ADDRESS_CENTURY);
-
//
// Get the alarm info from variable
//
@@ -644,7 +633,7 @@ PcRtcGetWakeupTime (
//
// Make sure all field values are in correct range
//
- Status = ConvertRtcTimeToEfiTime (Time, Century, RegisterB);
+ Status = ConvertRtcTimeToEfiTime (Time, RegisterB);
if (!EFI_ERROR (Status)) {
Status = RtcTimeFieldsValid (Time);
}
@@ -680,7 +669,6 @@ PcRtcSetWakeupTime (
EFI_STATUS Status;
EFI_TIME RtcTime;
RTC_REGISTER_B RegisterB;
- UINT8 Century;
EFI_TIME_CAPABILITIES Capabilities;

ZeroMem (&RtcTime, sizeof (RtcTime)); @@ -736,7 +724,7 @@ PcRtcSetWakeupTime (
RegisterB.Data = RtcRead (RTC_ADDRESS_REGISTER_B);

if (Enable) {
- ConvertEfiTimeToRtcTime (&RtcTime, RegisterB, &Century);
+ ConvertEfiTimeToRtcTime (&RtcTime, RegisterB);
} else {
//
// if the alarm is disable, record the current setting.
@@ -837,7 +825,6 @@ CheckAndConvertBcd8ToDecimal8 (

@param Time On input, the time data read from RTC to convert
On output, the time converted to UEFI format
- @param Century Value of century read from RTC.
@param RegisterB Value of Register B of RTC, indicating data mode
and hour format.

@@ -848,11 +835,11 @@ CheckAndConvertBcd8ToDecimal8 ( EFI_STATUS ConvertRtcTimeToEfiTime (
IN OUT EFI_TIME *Time,
- IN UINT8 Century,
IN RTC_REGISTER_B RegisterB
)
{
BOOLEAN IsPM;
+ UINT8 Century;

if ((Time->Hour & 0x80) != 0) {
IsPM = TRUE;
@@ -870,14 +857,21 @@ ConvertRtcTimeToEfiTime (
Time->Minute = CheckAndConvertBcd8ToDecimal8 (Time->Minute);
Time->Second = CheckAndConvertBcd8ToDecimal8 (Time->Second);
}
- Century = CheckAndConvertBcd8ToDecimal8 (Century);

if (Time->Year == 0xff || Time->Month == 0xff || Time->Day == 0xff ||
- Time->Hour == 0xff || Time->Minute == 0xff || Time->Second == 0xff ||
- Century == 0xff) {
+ Time->Hour == 0xff || Time->Minute == 0xff || Time->Second ==
+ 0xff) {
return EFI_INVALID_PARAMETER;
}

+ //
+ // For minimal/maximum year range [1970, 2069],
+ // Century is 19 if RTC year >= 70,
+ // Century is 20 otherwise.
+ //
+ Century = (UINT8) (PcdGet16 (PcdMinimalValidYear) / 100); if
+ (Time->Year < PcdGet16 (PcdMinimalValidYear) % 100) {
+ Century++;
+ }
Time->Year = (UINT16) (Century * 100 + Time->Year);

//
@@ -1053,14 +1047,11 @@ IsLeapYear (
@param Time On input, the time data read from UEFI to convert
On output, the time converted to RTC format
@param RegisterB Value of Register B of RTC, indicating data mode
- @param Century It is set according to EFI_TIME Time.
-
**/
VOID
ConvertEfiTimeToRtcTime (
IN OUT EFI_TIME *Time,
- IN RTC_REGISTER_B RegisterB,
- OUT UINT8 *Century
+ IN RTC_REGISTER_B RegisterB
)
{
BOOLEAN IsPM;
@@ -1081,10 +1072,8 @@ ConvertEfiTimeToRtcTime (
}
}
//
- // Set the Time/Date/Daylight Savings values.
+ // Set the Time/Date values.
//
- *Century = DecimalToBcd8 ((UINT8) (Time->Year / 100));
-
Time->Year = (UINT16) (Time->Year % 100);

if (RegisterB.Bits.Dm == 0) {
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
index 020d715..026c108 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
@@ -1,7 +1,7 @@
/** @file
Header file for real time clock driver.

-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -61,7 +61,6 @@ typedef struct {
#define RTC_ADDRESS_REGISTER_B 11 // R/W
#define RTC_ADDRESS_REGISTER_C 12 // RO
#define RTC_ADDRESS_REGISTER_D 13 // RO
-#define RTC_ADDRESS_CENTURY 50 // R/W Range 19..20 Bit 8 is R/W
//
// Date and time initial values.
// They are used if the RTC values are invalid during driver initialization @@ -71,7 +70,6 @@ typedef struct {
#define RTC_INIT_HOUR 0
#define RTC_INIT_DAY 1
#define RTC_INIT_MONTH 1
-#define RTC_INIT_YEAR 2001

//
// Register initial values
@@ -287,14 +285,11 @@ RtcTimeFieldsValid (
@param Time On input, the time data read from UEFI to convert
On output, the time converted to RTC format
@param RegisterB Value of Register B of RTC, indicating data mode
- @param Century It is set according to EFI_TIME Time.
-
**/
VOID
ConvertEfiTimeToRtcTime (
IN OUT EFI_TIME *Time,
- IN RTC_REGISTER_B RegisterB,
- OUT UINT8 *Century
+ IN RTC_REGISTER_B RegisterB
);


@@ -308,7 +303,6 @@ ConvertEfiTimeToRtcTime (

@param Time On input, the time data read from RTC to convert
On output, the time converted to UEFI format
- @param Century Value of century read from RTC.
@param RegisterB Value of Register B of RTC, indicating data mode
and hour format.

@@ -319,7 +313,6 @@ ConvertEfiTimeToRtcTime ( EFI_STATUS ConvertRtcTimeToEfiTime (
IN OUT EFI_TIME *Time,
- IN UINT8 Century,
IN RTC_REGISTER_B RegisterB
);

--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Laszlo Ersek
2015-06-11 15:17:21 UTC
Permalink
Post by Ruiyu Ni
The original driver cannot handle the case when system time runs from 1999/12/31 23:59:59
to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this bug.
The patch limits the driver to only support year in 100 range and decide the century value based
on the supporting range: Century either equals to PcdMinimalYear / 100 or equals to PcdMinimalYear / 100 + 1.
The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31 23:59:59,
the next second system time will become 1998/1/1 0:0:0. I think it's a acceptable limitation.
Contributed-under: TianoCore Contribution Agreement 1.0
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55 +++++++++-------------
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@
## This PCD specifies the maximal valid year in RTC.
- gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x0000000E
build.py...
: error C0DE: Unknown fatal error when processing [.../PcAtChipsetPkg/PcAtChipsetPkg.dec]
File ".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py", line 2032, in Main
MyBuild.Launch()
File ".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py", line 1788, in Launch
self._MultiThreadBuildPlatform()
File ".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py", line 1583, in _MultiThreadBuildPlatform
self.Progress
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 175, in __new__
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 357, in _Init
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py", line 1487, in _GetPcds
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py", line 1521, in _GetPcd
validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
File ".../BaseTools/Source/Python/Workspace/MetaFileParser.py", line 380, in GetValidExpression
return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
File ".../BaseTools/Source/Python/Workspace/MetaFileTable.py", line 246, in GetValidExpression
expressions.append(comment.split("|")[1].strip())
IndexError: list index out of range
- Failed -
@Expression's should have a number (I guess a bitmask of flags?) associated with them, and that number should be separated from the actual expression with a filter bar (|). Example:

MdePkg/MdePkg.dec: # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0

The above @Expression in "PcAtChipsetPkg/PcAtChipsetPkg.dec" lacks the bitmask and the "|" separator. (Which makes me question if this patch was ever build tested.)

Thanks
Laszlo

------------------------------------------------------------------------------
Ni, Ruiyu
2015-06-12 01:15:31 UTC
Permalink
Laszlo,
Yes I can reproduce this build failure.
I did build without the expression comments but didn't do that again after adding the expression comments in DEC. I thought it was only comments and not checked by tool.
We are working on patch to fix the build failure.

Thanks,
Ray
Post by Tian, Feng
-----Original Message-----
Sent: Thursday, June 11, 2015 11:17 PM
To: Ni, Ruiyu
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug
Post by Ruiyu Ni
The original driver cannot handle the case when system time runs from
1999/12/31 23:59:59
Post by Ruiyu Ni
to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this
bug.
Post by Ruiyu Ni
The patch limits the driver to only support year in 100 range and decide the
century value based
Post by Ruiyu Ni
on the supporting range: Century either equals to PcdMinimalYear / 100 or
equals to PcdMinimalYear / 100 + 1.
Post by Ruiyu Ni
The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31
23:59:59,
Post by Ruiyu Ni
the next second system time will become 1998/1/1 0:0:0. I think it's a
acceptable limitation.
Post by Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55
+++++++++-------------
Post by Ruiyu Ni
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec
b/PcAtChipsetPkg/PcAtChipsetPkg.dec
Post by Ruiyu Ni
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@
## This PCD specifies the maximal valid year in RTC.
-
gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x000
0000E
< gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
Post by Ruiyu Ni
build.py...
: error C0DE: Unknown fatal error when processing
[.../PcAtChipsetPkg/PcAtChipsetPkg.dec]
following call stack trace!)
Post by Ruiyu Ni
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
line 2032, in Main
Post by Ruiyu Ni
MyBuild.Launch()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
line 1788, in Launch
Post by Ruiyu Ni
self._MultiThreadBuildPlatform()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
line 1583, in _MultiThreadBuildPlatform
Post by Ruiyu Ni
self.Progress
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 175, in
__new__
Post by Ruiyu Ni
if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain,
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 357, in
_Init
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1487, in _GetPcds
Post by Ruiyu Ni
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1521, in _GetPcd
Post by Ruiyu Ni
validateranges, validlists, expressions =
self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/MetaFileParser.py", line
380, in GetValidExpression
Post by Ruiyu Ni
return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
File ".../BaseTools/Source/Python/Workspace/MetaFileTable.py", line
246, in GetValidExpression
Post by Ruiyu Ni
expressions.append(comment.split("|")[1].strip())
IndexError: list index out of range
- Failed -
@Expression's should have a number (I guess a bitmask of flags?) associated
with them, and that number should be separated from the actual expression
(gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
bitmask and the "|" separator. (Which makes me question if this patch was
ever build tested.)
Thanks
Laszlo
------------------------------------------------------------------------------
Feng, Bob C
2015-06-16 02:35:51 UTC
Permalink
Hello Laszlo and Ray,

I created a patch to fix the build crash. When the build tool find there is incorrect syntax in @expression, @ValidList and @ValidRange in DEC file, the build tool will break and report an error message. Please review.

Thanks,
Bob

-----Original Message-----
From: Ni, Ruiyu [mailto:***@intel.com]
Sent: Friday, June 12, 2015 9:16 AM
To: Laszlo Ersek
Cc: edk2-***@lists.sourceforge.net; Gerd Hoffmann (GMail address)
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug

Laszlo,
Yes I can reproduce this build failure.
I did build without the expression comments but didn't do that again after adding the expression comments in DEC. I thought it was only comments and not checked by tool.
We are working on patch to fix the build failure.

Thanks,
Ray
Post by Tian, Feng
-----Original Message-----
Sent: Thursday, June 11, 2015 11:17 PM
To: Ni, Ruiyu
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug
Post by Ruiyu Ni
The original driver cannot handle the case when system time runs from
1999/12/31 23:59:59
Post by Ruiyu Ni
to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this
bug.
Post by Ruiyu Ni
The patch limits the driver to only support year in 100 range and decide the
century value based
Post by Ruiyu Ni
on the supporting range: Century either equals to PcdMinimalYear / 100 or
equals to PcdMinimalYear / 100 + 1.
Post by Ruiyu Ni
The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31
23:59:59,
Post by Ruiyu Ni
the next second system time will become 1998/1/1 0:0:0. I think it's a
acceptable limitation.
Post by Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55
+++++++++-------------
Post by Ruiyu Ni
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec
b/PcAtChipsetPkg/PcAtChipsetPkg.dec
Post by Ruiyu Ni
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@
## This PCD specifies the maximal valid year in RTC.
-
gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x000
0000E
< gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
Post by Ruiyu Ni
build.py...
: error C0DE: Unknown fatal error when processing
[.../PcAtChipsetPkg/PcAtChipsetPkg.dec]
following call stack trace!)
Post by Ruiyu Ni
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y",
line 2032, in Main
Post by Ruiyu Ni
MyBuild.Launch()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y",
line 1788, in Launch
Post by Ruiyu Ni
self._MultiThreadBuildPlatform()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y", line 1583, in _MultiThreadBuildPlatform
Post by Ruiyu Ni
self.Progress
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 175, in
__new__
Post by Ruiyu Ni
if not AutoGenObject._Init(Workspace, MetaFile, Target,
Toolchain,
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 357, in
_Init
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1487, in _GetPcds
Post by Ruiyu Ni
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1521, in _GetPcd
Post by Ruiyu Ni
validateranges, validlists, expressions =
self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/MetaFileParser.py", line
380, in GetValidExpression
Post by Ruiyu Ni
return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
File ".../BaseTools/Source/Python/Workspace/MetaFileTable.py", line
246, in GetValidExpression
Post by Ruiyu Ni
expressions.append(comment.split("|")[1].strip())
IndexError: list index out of range
- Failed -
@Expression's should have a number (I guess a bitmask of flags?)
associated with them, and that number should be separated from the
(gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
bitmask and the "|" separator. (Which makes me question if this patch
was ever build tested.)
Thanks
Laszlo
------------------------------------------------------------------------------
Laszlo Ersek
2015-06-16 14:18:34 UTC
Permalink
Post by Feng, Bob C
Hello Laszlo and Ray,
I created a patch to fix the build crash. When the build tool find
in DEC file, the build tool will break and report an error message.
Please review.
Looks good to me.

Reviewed-by: Laszlo Ersek <***@redhat.com>

I also tested it, by locally reverting Ray's fix in SVN r17628, applying
your patch, and then attempting to build OVMF. The error message I got
Post by Feng, Bob C
.../PcAtChipsetPkg/PcAtChipsetPkg.dec(126): error 3000: The syntax for
@Expression of PCD gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear
is incorrect
@Expression gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear
< gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
[...]
- Failed -
Tested-by: Laszlo Ersek <***@redhat.com>

Thanks!
Laszlo
Post by Feng, Bob C
Thanks,
Bob
-----Original Message-----
Sent: Friday, June 12, 2015 9:16 AM
To: Laszlo Ersek
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug
Laszlo,
Yes I can reproduce this build failure.
I did build without the expression comments but didn't do that again after adding the expression comments in DEC. I thought it was only comments and not checked by tool.
We are working on patch to fix the build failure.
Thanks,
Ray
Post by Tian, Feng
-----Original Message-----
Sent: Thursday, June 11, 2015 11:17 PM
To: Ni, Ruiyu
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug
Post by Ruiyu Ni
The original driver cannot handle the case when system time runs from
1999/12/31 23:59:59
Post by Ruiyu Ni
to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this
bug.
Post by Ruiyu Ni
The patch limits the driver to only support year in 100 range and decide the
century value based
Post by Ruiyu Ni
on the supporting range: Century either equals to PcdMinimalYear / 100 or
equals to PcdMinimalYear / 100 + 1.
Post by Ruiyu Ni
The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31
23:59:59,
Post by Ruiyu Ni
the next second system time will become 1998/1/1 0:0:0. I think it's a
acceptable limitation.
Post by Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55
+++++++++-------------
Post by Ruiyu Ni
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec
b/PcAtChipsetPkg/PcAtChipsetPkg.dec
Post by Ruiyu Ni
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@
## This PCD specifies the maximal valid year in RTC.
-
gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x000
0000E
< gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
Post by Ruiyu Ni
build.py...
: error C0DE: Unknown fatal error when processing
[.../PcAtChipsetPkg/PcAtChipsetPkg.dec]
following call stack trace!)
Post by Ruiyu Ni
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y",
line 2032, in Main
Post by Ruiyu Ni
MyBuild.Launch()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y",
line 1788, in Launch
Post by Ruiyu Ni
self._MultiThreadBuildPlatform()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y", line 1583, in _MultiThreadBuildPlatform
Post by Ruiyu Ni
self.Progress
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 175, in
__new__
Post by Ruiyu Ni
if not AutoGenObject._Init(Workspace, MetaFile, Target,
Toolchain,
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 357, in
_Init
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1487, in _GetPcds
Post by Ruiyu Ni
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1521, in _GetPcd
Post by Ruiyu Ni
validateranges, validlists, expressions =
self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/MetaFileParser.py", line
380, in GetValidExpression
Post by Ruiyu Ni
return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
File ".../BaseTools/Source/Python/Workspace/MetaFileTable.py", line
246, in GetValidExpression
Post by Ruiyu Ni
expressions.append(comment.split("|")[1].strip())
IndexError: list index out of range
- Failed -
@Expression's should have a number (I guess a bitmask of flags?)
associated with them, and that number should be separated from the
(gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
bitmask and the "|" separator. (Which makes me question if this patch
was ever build tested.)
Thanks
Laszlo
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Gao, Liming
2015-06-23 06:54:42 UTC
Permalink
Reviewed-by: Liming Gao <***@intel.com>

-----Original Message-----
From: Feng, Bob C [mailto:***@intel.com]
Sent: Tuesday, June 16, 2015 10:36 AM
To: edk2-***@lists.sourceforge.net; Laszlo Ersek; Ni, Ruiyu
Cc: Gerd Hoffmann (GMail address)
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug

Hello Laszlo and Ray,

I created a patch to fix the build crash. When the build tool find there is incorrect syntax in @expression, @ValidList and @ValidRange in DEC file, the build tool will break and report an error message. Please review.

Thanks,
Bob

-----Original Message-----
From: Ni, Ruiyu [mailto:***@intel.com]
Sent: Friday, June 12, 2015 9:16 AM
To: Laszlo Ersek
Cc: edk2-***@lists.sourceforge.net; Gerd Hoffmann (GMail address)
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug

Laszlo,
Yes I can reproduce this build failure.
I did build without the expression comments but didn't do that again after adding the expression comments in DEC. I thought it was only comments and not checked by tool.
We are working on patch to fix the build failure.

Thanks,
Ray
Post by Tian, Feng
-----Original Message-----
Sent: Thursday, June 11, 2015 11:17 PM
To: Ni, Ruiyu
Subject: Re: [edk2] [Patch] PcAtChipsetPkg/PcRtc: Fix a Y2K bug
Post by Ruiyu Ni
The original driver cannot handle the case when system time runs from
1999/12/31 23:59:59
Post by Ruiyu Ni
to 2000/1/1 0:0:0.
A simple test to set system time to 1999/12/31 23:59:59 can expose this
bug.
Post by Ruiyu Ni
The patch limits the driver to only support year in 100 range and decide the
century value based
Post by Ruiyu Ni
on the supporting range: Century either equals to PcdMinimalYear / 100 or
equals to PcdMinimalYear / 100 + 1.
Post by Ruiyu Ni
The patch passed the Y2K test.
However with year range [1998, 2097], when system time is 2097/12/31
23:59:59,
Post by Ruiyu Ni
the next second system time will become 1998/1/1 0:0:0. I think it's a
acceptable limitation.
Post by Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +-
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 55
+++++++++-------------
Post by Ruiyu Ni
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h | 11 +----
3 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec
b/PcAtChipsetPkg/PcAtChipsetPkg.dec
Post by Ruiyu Ni
index fb6fb8b..6a1415c 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -123,7 +123,8 @@
## This PCD specifies the maximal valid year in RTC.
-
gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2099|UINT16|0x000
0000E
< gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
Post by Ruiyu Ni
build.py...
: error C0DE: Unknown fatal error when processing
[.../PcAtChipsetPkg/PcAtChipsetPkg.dec]
following call stack trace!)
Post by Ruiyu Ni
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y",
line 2032, in Main
Post by Ruiyu Ni
MyBuild.Launch()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y",
line 1788, in Launch
Post by Ruiyu Ni
self._MultiThreadBuildPlatform()
File
".../BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.p
y", line 1583, in _MultiThreadBuildPlatform
Post by Ruiyu Ni
self.Progress
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 175, in
__new__
Post by Ruiyu Ni
if not AutoGenObject._Init(Workspace, MetaFile, Target,
Toolchain,
File ".../BaseTools/Source/Python/AutoGen/AutoGen.py", line 357, in
_Init
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1487, in _GetPcds
Post by Ruiyu Ni
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
File ".../BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
line 1521, in _GetPcd
Post by Ruiyu Ni
validateranges, validlists, expressions =
self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
Post by Ruiyu Ni
File ".../BaseTools/Source/Python/Workspace/MetaFileParser.py", line
380, in GetValidExpression
Post by Ruiyu Ni
return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
File ".../BaseTools/Source/Python/Workspace/MetaFileTable.py", line
246, in GetValidExpression
Post by Ruiyu Ni
expressions.append(comment.split("|")[1].strip())
IndexError: list index out of range
- Failed -
@Expression's should have a number (I guess a bitmask of flags?)
associated with them, and that number should be separated from the
(gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
bitmask and the "|" separator. (Which makes me question if this patch
was ever build tested.)
Thanks
Laszlo
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Ruiyu Ni
2015-06-12 01:34:28 UTC
Permalink
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Liming Gao <***@intel.com>
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 7 ++++++-
PcAtChipsetPkg/PcAtChipsetPkg.uni | Bin 24384 -> 24586 bytes
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index 6a1415c..cbd5707 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -34,6 +34,11 @@
[Guids]
gPcAtChipsetPkgTokenSpaceGuid = { 0x326ae723, 0xae32, 0x4589, { 0x98, 0xb8, 0xca, 0xc2, 0x3c, 0xdc, 0xc1, 0xb1 } }

+#
+# [Error.gPcAtChipsetPkgTokenSpaceGuid]
+# 0x80000001 | Invalid value provided.
+#
+
[PcdsFeatureFlag]
## Indicates the HPET Timer will be configured to use MSI interrupts if the HPET timer supports them, or use I/O APIC interrupts.<BR><BR>
# TRUE - Configures the HPET Timer to use MSI interrupts if the HPET Timer supports them.<BR>
@@ -123,7 +128,7 @@

## This PCD specifies the maximal valid year in RTC.
# @Prompt Maximal valid year in RTC.
- # @Expression gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear < gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
+ # @Expression 0x80000001 | gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear < gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2097|UINT16|0x0000000E

[PcdsFixedAtBuild, PcdsPatchableInModule]
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.uni b/PcAtChipsetPkg/PcAtChipsetPkg.uni
index e6d91632933bd3c481927a63a54835838afe35a7..0ce08d4733f964ebb2e2597dee0032b1e2b4f4b0 100644
GIT binary patch
delta 84
***@GkFo0j;|7QL$qiN^;;sxqKp4+p!C-&{4JRv_s89Z2z#>}4kjRk3kjaq3puhlO
VmolVIzQ`}kqsO4cz{|h|#sG!O5!(O&

delta 9
QcmeA=z<6LE;|7O#02UJj8UO$Q
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Gao, Liming
2015-06-12 01:42:33 UTC
Permalink
Reviewed-by: Liming Gao <***@intel.com>

-----Original Message-----
From: Ni, Ruiyu
Sent: Friday, June 12, 2015 9:34 AM
To: edk2-***@lists.sourceforge.net
Cc: Ni, Ruiyu; Gao, Liming
Subject: [Patch] PcAtChipsetPkg: Fix PCD expression build failure

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Cc: Liming Gao <***@intel.com>
---
PcAtChipsetPkg/PcAtChipsetPkg.dec | 7 ++++++-
PcAtChipsetPkg/PcAtChipsetPkg.uni | Bin 24384 -> 24586 bytes
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index 6a1415c..cbd5707 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -34,6 +34,11 @@
[Guids]
gPcAtChipsetPkgTokenSpaceGuid = { 0x326ae723, 0xae32, 0x4589, { 0x98, 0xb8, 0xca, 0xc2, 0x3c, 0xdc, 0xc1, 0xb1 } }

+#
+# [Error.gPcAtChipsetPkgTokenSpaceGuid]
+# 0x80000001 | Invalid value provided.
+#
+
[PcdsFeatureFlag]
## Indicates the HPET Timer will be configured to use MSI interrupts if the HPET timer supports them, or use I/O APIC interrupts.<BR><BR>
# TRUE - Configures the HPET Timer to use MSI interrupts if the HPET Timer supports them.<BR>
@@ -123,7 +128,7 @@

## This PCD specifies the maximal valid year in RTC.
# @Prompt Maximal valid year in RTC.
- # @Expression gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear < gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
+ # @Expression 0x80000001 |
+ gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear <
+ gPcAtChipsetPkgTokenSpaceGuid.PcdMinimalValidYear + 100
gPcAtChipsetPkgTokenSpaceGuid.PcdMaximalValidYear|2097|UINT16|0x0000000E

[PcdsFixedAtBuild, PcdsPatchableInModule] diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.uni b/PcAtChipsetPkg/PcAtChipsetPkg.uni
index e6d91632933bd3c481927a63a54835838afe35a7..0ce08d4733f964ebb2e2597dee0032b1e2b4f4b0 100644 GIT binary patch delta 84 ***@GkFo0j;|7QL$qiN^;;sxqKp4+p!C-&{4JRv_s89Z2z#>}4kjRk3kjaq3puhlO
VmolVIzQ`}kqsO4cz{|h|#sG!O5!(O&

delta 9
QcmeA=z<6LE;|7O#02UJj8UO$Q

--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Loading...