Bug 299337 - Time is behind in a FreeBSD UTM VM after it wakes up from sleep
Summary: Time is behind in a FreeBSD UTM VM after it wakes up from sleep
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-10-12 16:18 UTC by Yuri Victorovich
Modified: 2026-10-16 16:45 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2026-10-12 16:18:35 UTC
16-CURRENT is running in a UTM VM on a very new MacBook laptop.
Initially the time is synced with an outside NTP server. The time is running fine. ntpd is not running.

How to reproduce the problem:
1. Suspend the host system by closing the laptop lid and disconnecting power.
2. Wake it up after 5 minutes.
3. Observe that the time is behind by ~30 secs.

The problem is reproducible.

It looks like FreeBSD updates the time after it wakes up but it doesn't update it correctly.

The time is behind by 30 secs, not 5 minutes.
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2026-10-12 17:03:13 UTC
IMO, the expected behavior is that there should be correct time adjustment on wake-up without the need of forced NTP update in /etc/rc.resume scripts.
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2026-10-12 20:43:10 UTC
Some relevant sysctl values:

kern.timecounter.nanosleep_precise: 1
kern.timecounter.fast_gettime: 1
kern.timecounter.tick: 1
kern.timecounter.choice: ARM MPCore Timecounter(1000) dummy(-1000000)
kern.timecounter.hardware: ARM MPCore Timecounter
kern.timecounter.alloweddeviation: 5
kern.timecounter.timehands_count: 2
kern.timecounter.stepwarnings: 0
kern.timecounter.tc.ARM MPCore Timecounter.quality: 1000
kern.timecounter.tc.ARM MPCore Timecounter.frequency: 24000000
kern.timecounter.tc.ARM MPCore Timecounter.counter: 818740853
kern.timecounter.tc.ARM MPCore Timecounter.mask: 4294967295
kern.eventtimer.choice: ARM MPCore Eventtimer(1000)
kern.eventtimer.et.ARM MPCore Eventtimer.quality: 1000
kern.eventtimer.et.ARM MPCore Eventtimer.frequency: 24000000
kern.eventtimer.et.ARM MPCore Eventtimer.flags: 6
kern.eventtimer.periodic: 0
kern.eventtimer.timer: ARM MPCore Eventtimer
kern.eventtimer.idletick: 0
kern.eventtimer.singlemul: 4
Comment 3 John Baldwin freebsd_committer freebsd_triage 2026-10-16 16:38:19 UTC
This might be a bug in the hypervisor if it is not skewing the timecounter value sufficiently after a sleep in which case there is not anything FreeBSD as a guest can do about that.  It might be that FreeBSD needs to handle an event from the hypervisor invoked after a wakeup during a resume (I'm not sure if that hypervisor even has such an event), but if such an event did exist, it would need to just trigger NTP.  I don't think there's any real solution to this that doesn't involve NTP in some fashion.
Comment 4 Yuri Victorovich freebsd_committer freebsd_triage 2026-10-16 16:45:31 UTC
QEMU is a hypervisor in UTM on MacOS.