timer: Switch mono_time to uint64_t

A 32-bit long storing microseconds will rollover every ~1.19 hours.
This can cause stopwatch to misbehave, causing unexpected failures.

If the current field in stopwatch is near 2^31, the expires field may
rollover when initialized. If this occurs, stopwatch_expired() will
instantly return true.

If current and expires fields are near 2^31, the current field could
rollover before being checked. In this case, stopwatch_expired() will
not return true for over an hour. Also stopwatch_duration_usecs() will
return a large negative duration.

This issue has only been observed in SMM since it never takes more
than 35 minutes to boot.

Switching to uint64_t mitigates this issue since it will not rollover
for over 500K+ years. The raw TSC would rollover sooner than this,
~200 years, depending on the tick frequency.

BUG=b:237082996
BRANCH=All
TEST=Boot Nipperkin

Change-Id: I4c24894718f093ac7cd1e434410bc64e6436869a
Signed-off-by: Rob Barnes <robbarnes@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65403
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Rob Barnes 2022-06-24 10:28:31 -06:00 committed by Martin L Roth
parent 175445b4bb
commit b11f9f7e16
1 changed files with 1 additions and 1 deletions

View File

@ -17,7 +17,7 @@
* outside of the core timer code is not supported. */
struct mono_time {
long microseconds;
uint64_t microseconds;
};
/* A timeout_callback structure is used for the book keeping for scheduling