mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-18 17:57:27 +03:00
sd-boot: add overflow check to TSC reads
On some archs the counter is 32bit, and in case of virtualization it might actually overflow, who knows.
This commit is contained in:
parent
1e66a23373
commit
476c0e969a
@ -45,6 +45,10 @@ UINT64 ticks_freq(void) {
|
||||
BS->Stall(1000);
|
||||
ticks_end = ticks_read();
|
||||
|
||||
if (ticks_end < ticks_start) /* Check for an overflow (which is not that unlikely, given on some
|
||||
* archs the value is 32bit) */
|
||||
return 0;
|
||||
|
||||
return (ticks_end - ticks_start) * 1000UL;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user