Reviewed-by: Ray Ni <ray...@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> D Kinney
> Sent: Thursday, March 30, 2023 6:37 AM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray...@intel.com>
> Subject: [edk2-devel] [Patch 1/1]
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe: PcdRtcDefaultYear bounds
> 
> Add bounds checks of PcdRtcDefaultYear to guarantee that the year
> is always between PcdMinimalValidYear and PcdMaximalValidYear.
> This is required to make the following commit a backwards compatible
> change and guarantee and invalid year is never set.
> 
> https://github.com/tianocore/edk2/commit/d55d73152ebf5c793b645d6ec5b
> c517d219881cd
> 
> This is required because use of an expression in the DEC file
> PCD default value is only used to determine the DEC default values.
> If an INF/DSC overrides PcdRtcDefaultYear, then the DEC expression
> for PcdMinimalValidYear is not applied again.
> 
> Cc: Ray Ni <ray...@intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
> ---
>  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> index b059e92f02dc..15759463f2a3 100644
> --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> @@ -317,7 +317,8 @@ PcRtcInit (
>      Time.Hour       = RTC_INIT_HOUR;
>      Time.Day        = RTC_INIT_DAY;
>      Time.Month      = RTC_INIT_MONTH;
> -    Time.Year       = PcdGet16 (PcdRtcDefaultYear);
> +    Time.Year       = MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16
> (PcdMinimalValidYear));
> +    Time.Year       = MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));
>      Time.Nanosecond = 0;
>      Time.TimeZone   = EFI_UNSPECIFIED_TIMEZONE;
>      Time.Daylight   = 0;
> @@ -357,7 +358,8 @@ PcRtcInit (
>    Time.Hour       = RTC_INIT_HOUR;
>    Time.Day        = RTC_INIT_DAY;
>    Time.Month      = RTC_INIT_MONTH;
> -  Time.Year       = PcdGet16 (PcdRtcDefaultYear);
> +  Time.Year       = MAX (PcdGet16 (PcdRtcDefaultYear), PcdGet16
> (PcdMinimalValidYear));
> +  Time.Year       = MIN (Time.Year, PcdGet16 (PcdMaximalValidYear));
>    Time.Nanosecond = 0;
>    Time.TimeZone   = Global->SavedTimeZone;
>    Time.Daylight   = Global->Daylight;
> --
> 2.39.1.windows.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#102144): https://edk2.groups.io/g/devel/message/102144
Mute This Topic: https://groups.io/mt/97939977/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to