Kernel: Fix HPET::update_time to set ticks within the valid range

ticks_this_second must be less than the ticks per second (frequency).
This commit is contained in:
Tom 2020-12-29 16:45:01 -07:00 committed by Andreas Kling
parent 675bfb934b
commit c2332780ee
Notes: sideshowbarker 2024-07-19 00:25:19 +09:00

View file

@ -257,7 +257,7 @@ u64 HPET::update_time(u64& seconds_since_boot, u32& ticks_this_second, bool quer
delta_ticks += m_main_counter_last_read - current_value; // the counter wrapped around
u64 ticks_since_last_second = (u64)ticks_this_second + delta_ticks;
auto ticks_per_second = frequency();
if (ticks_since_last_second > ticks_per_second) {
if (ticks_since_last_second >= ticks_per_second) {
seconds_since_boot += ticks_since_last_second / ticks_per_second;
ticks_this_second = ticks_since_last_second % ticks_per_second;
} else {