Commit dedfd87f authored by G Edhaya Chandran's avatar G Edhaya Chandran Committed by Barton Gao
Browse files

UEFI-SCT: SctPkg: Updated the check for monotonic count after restart

Updated the check for montonic count in the case of after restart

From the UEFI Spec:
"The platform?s monotonic counter is comprised of two parts: the high 32 bits and the low 32 bits.
The low 32-bit value is volatile and is reset to zero on every system reset.
It is increased by 1 on every call to GetNextMonotonicCount().
The high 32-bit value is nonvolatile and is increased by one on
whenever the system resets or the low 32-bit counter overflows."

It was found in one case where the higher 32-bit increased by 2
presumably due to the overflow of lower 32-bit counter.
Update the logic to handle this case and to print a warning.

Please find more details in the ticket:

Cc: Barton Gao <>
Cc: Carolyn Gjertsen <>
Cc: Heinrich Schuchardt <>
Cc: Samer El-Haj-Mahmoud <>

Signed-off-by: G Edhaya Chandran<>
Reviewed-by: default avatarBarton Gao <>
parent d919c4a5
......@@ -1707,12 +1707,20 @@ GetNextMonotonicCountStep2:
if (SctRShiftU64 (Count2, 32) == SctRShiftU64 (Count, 32) + 1) {
} else {
//The new count of upper 32 bits must be atleast 1 more than the old count.
//Pass case: new count is equal to old count + 1
if (SctRShiftU64 (Count2, 32) <= SctRShiftU64 (Count, 32)) {
StandardLib->RecordAssertion (
} else {
//If new count is more that old count + 1, then print warning.
if (SctRShiftU64 (Count2, 32) > SctRShiftU64 (Count, 32) + 1) {
} else {
//new count == old count + 1
StandardLib->RecordAssertion (
Index==0? \
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment