From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.11781.1680129432728248585 for ; Wed, 29 Mar 2023 15:37:12 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=c3iRwozm; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680129432; x=1711665432; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CIkU7KLy57XgqloKD2tTFYDyvsah8gzy9f1q7/CrABw=; b=c3iRwozmqovHC1xaaHvMuFra3/k+MQRG9dcArya67YvdTWEoHUMlxOS3 eDpd//r1VjxRxemI/cdX//d1GBoH8SdpHYHrFZkJgnxckplcTNopAtYtr 4AaS7n4JdI9AQ1yE9V6W+chXd7FEDsinTcT0KqH5FvoXqozZDElBhJBZP Ong/MmodW3AlguKF//g7uttVIxC7+TZc6cIwoijuMxmHI2/JFwIRo4rGb rdip3hgZMDlkrNk3N7qBu3XuQoiF6Z75jPXy0Gn6g0Jv5nMSJP3lTdT3x WwdbjumGz2lSAU4/ThBphGv7+7aXt/keakFaAVng4xhadx05CED6094oJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="339737020" X-IronPort-AV: E=Sophos;i="5.98,301,1673942400"; d="scan'208";a="339737020" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 15:37:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="748937417" X-IronPort-AV: E=Sophos;i="5.98,301,1673942400"; d="scan'208";a="748937417" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.241.111.139]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 15:37:04 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Ray Ni Subject: [Patch 1/1] PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe: PcdRtcDefaultYear bounds Date: Wed, 29 Mar 2023 15:36:56 -0700 Message-Id: <20230329223656.476-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/d55d73152ebf5c793b645d6ec5bc517d219881cd 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 Signed-off-by: Michael D Kinney --- 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