git: DragonFly_RELEASE_6_4 acpica: Fix unexpected underflow bug in acpi_cputimer.base
Aaron LI
aly at crater.dragonflybsd.org
Wed Aug 27 05:22:17 PDT 2025
commit 870090918f6a68976455b24b4cd12d4ccdb142b3
Author: Aaron LI <aly at aaronly.me>
Date: Mon Aug 25 10:08:03 2025 +0800
acpica: Fix unexpected underflow bug in acpi_cputimer.base
The acpi_timer_construct() might underflow timer->base, and this
underflow was unexpected and not handled by acpi_timer_get_timecount*()
functions. As a result, they might return an extremely huge time count
(e.g., 18446744073706228405) and thus lead to an utterly wrong uptime
(e.g., 42951days ...).
In order to fix the bug and not further complicate the code, introduce
a separate static variable 'acpi_global_offset' to store the offset
between the given 'oldclock' and the initial counter read from the
timer. This 'acpi_global_offset' is then kept intact, and later
_acpi_get_timer{,_safe}() calls would give the delta over the base
'oldclock'. Then we deal with the adjusted counter from
_acpi_get_timer{,_safe}() in the same way as the original counter and
check for wraparounds in acpi_timer_get_timecount*() functions.
In this way, we don't need to worry about the underflow of 'timer->base'
and achieve a time count monotonically increasing from the 'oldclock'
given to the acpi_timer_construct().
Bug: #3299
Reported-by: Aedil, daftaupe
Discussed-with: dillon
Patch-by: dillon
Summary of changes:
sys/dev/acpica/acpi_timer.c | 90 ++++++++++++++++++++++++---------------------
1 file changed, 49 insertions(+), 41 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/870090918f6a68976455b24b4cd12d4ccdb142b3
--
DragonFly BSD source repository
More information about the Commits
mailing list