diff options
author | Rob Barnes <robbarnes@google.com> | 2022-06-24 10:28:31 -0600 |
---|---|---|
committer | Martin L Roth <gaumless@gmail.com> | 2022-08-13 17:20:11 +0000 |
commit | b11f9f7e162759cf5ae0f033e125e9158520030d (patch) | |
tree | 6c53aac2b789995fc6ea1af186f53274402310a4 | |
parent | 175445b4bbb16b8eedc2f6bd1b3ec37cb1095bf1 (diff) |
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>
-rw-r--r-- | src/include/timer.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/include/timer.h b/src/include/timer.h index 9b7a05e5fd..0e7104b70e 100644 --- a/src/include/timer.h +++ b/src/include/timer.h @@ -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 |